Table of Contents

Class LinksClient

Namespace
Foundation.Data.Doublets.Cli.Protocol
Assembly
Foundation.Data.Doublets.Cli.dll

Sends substitution queries to a LiNo server over any ILinoProtocol and any IPC transport.

public sealed class LinksClient : IDisposable
Inheritance
LinksClient
Implements
Inherited Members

Remarks

A server pushes the changes a connection subscribed to between its replies; a pushed document starts with (notify: N). Request(IReadOnlyList<Link<string>>) sets the pushes it meets aside for ReceiveNotification(TimeSpan), so replies and pushes never get mixed up. The client is not thread safe.

Properties

Kind

The transport kind the client is connected through, such as tcp or unix.

public string Kind { get; }

Property Value

string

PendingNotifications

The number of pushes received and not yet taken by ReceiveNotification(TimeSpan).

public int PendingNotifications { get; }

Property Value

int

Protocol

The protocol used for every message.

public ILinoProtocol Protocol { get; }

Property Value

ILinoProtocol

Methods

Authenticate(string)

Sends (auth: token): every later request of the connection runs as the subject the server gives the token, which this returns (issue #149). A token the server does not know raises a Remote error.

public uint Authenticate(string token)

Parameters

token string

Returns

uint

Connect(string, ILinoProtocol)

Connects to an address written as host:port.

public static LinksClient Connect(string endPoint, ILinoProtocol protocol)

Parameters

endPoint string
protocol ILinoProtocol

Returns

LinksClient

Connect(string, int, ILinoProtocol)

Connects to host:port over TCP using protocol.

[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "The created object is owned by the returned stream or listener, and failure paths dispose it.")]
public static LinksClient Connect(string host, int port, ILinoProtocol protocol)

Parameters

host string
port int
protocol ILinoProtocol

Returns

LinksClient

ConnectEndpoint(string, ILinoProtocol)

Connects to an IPC endpoint (see Endpoint), such as 127.0.0.1:8080, unix:/tmp/links.sock, pipe:links or shm:/tmp/links, using protocol.

public static LinksClient ConnectEndpoint(string endpoint, ILinoProtocol protocol)

Parameters

endpoint string
protocol ILinoProtocol

Returns

LinksClient

Exceptions

LinoProtocolException

The endpoint is not valid or cannot be reached, as an Io error.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

FromStream(IpcStream, ILinoProtocol)

Talks to a server through an open IpcStream, which the client then owns.

public static LinksClient FromStream(IpcStream stream, ILinoProtocol protocol)

Parameters

stream IpcStream
protocol ILinoProtocol

Returns

LinksClient

Query(string)

Runs a LiNo substitution query; the empty query reads every link.

public IReadOnlyList<Link<string>> Query(string query)

Parameters

query string

Returns

IReadOnlyList<Link<string>>

QueryLossless(string)

Sends original query text to a peer supporting the explicit query envelope. Never retries a mutation through a different representation.

public IReadOnlyList<Link<string>> QueryLossless(string query)

Parameters

query string

Returns

IReadOnlyList<Link<string>>

QueryText(string)

Like Query(string), returning the reply as canonical text.

public string QueryText(string query)

Parameters

query string

Returns

string

ReceiveNotification(TimeSpan)

The next document the server pushed, (notify: N) and its changes, waiting up to timeout for one; null when none arrived in time.

public IReadOnlyList<Link<string>>? ReceiveNotification(TimeSpan timeout)

Parameters

timeout TimeSpan

Returns

IReadOnlyList<Link<string>>

Exceptions

LinoProtocolException

The connection closed, or the server sent something other than a push while no request was waiting.

Sends a parsed document and returns the reply document. An (error: 'message') reply raises a Remote error.

public IReadOnlyList<Link<string>> Request(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

IReadOnlyList<Link<string>>