Table of Contents

Class RemoteLinks<T>

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

A links store served by a LinksServer, usable wherever a local store is.

public class RemoteLinks<T> : INamedTypesLinks<T>, ILinks<T>, ILinks<T, LinksConstants<T>>, INamedTypes<T>, IDisposable where T : struct, IBinaryInteger<T>, IUnsignedNumber<T>, IMinMaxValue<T>

Type Parameters

T
Inheritance
RemoteLinks<T>
Implements
ILinks<T>
ILinks<T, LinksConstants<T>>
Derived
Inherited Members
Extension Methods

It implements the same interface as a local store, INamedTypesLinks<TLinkAddress>, so code written against it — the AdvancedMixedQueryProcessor and every ILinks extension included — switches from a local file to a server by swapping one value:

static void Run(INamedTypesLinks<uint> links) =>
    AdvancedMixedQueryProcessor.ProcessQuery(links, new() { Query = "() ((1 1))" });

using (var local = new NamedTypesDecorator<uint>("db.links")) Run(local);
using (var remote = RemoteLinks.Connect("127.0.0.1:8080", new TextLinoProtocol())) Run(remote);

Every call is one LinksOperation round trip, in the documents the Rust RemoteLinks sends, so either port's client works with either port's server. A write handler sees the net change of every link a write touched, not the steps the store behind the server took. A failure of the connection or of the server is a LinoProtocolException. The calls are serialised, so one instance may be shared between threads.

Constructors

Uses an existing connection, which the store then owns.

public RemoteLinks(LinksClient client)

Parameters

client LinksClient

Properties

The constants of the UnitedMemoryLinks a server stores its links in.

public LinksConstants<T> Constants { get; }

Property Value

LinksConstants<T>

Methods

Connects to a server at an address written as host:port.

public static RemoteLinks<T> Connect(string endPoint, ILinoProtocol protocol)

Parameters

endPoint string
protocol ILinoProtocol

Returns

RemoteLinks<T>

Connects to a server at any IPC endpoint, such as unix:/tmp/links.sock or shm:/tmp/links.

public static RemoteLinks<T> ConnectEndpoint(string endpoint, ILinoProtocol protocol)

Parameters

endpoint string
protocol ILinoProtocol

Returns

RemoteLinks<T>

Counts and returns the total number of links in the storage that meet the specified restriction.

Подсчитывает и возвращает общее число связей находящихся в хранилище, соответствующих указанному ограничению.

public T Count(IList<T>? restriction)

Parameters

restriction IList<T>

Restriction on the contents of links.

Ограничение на содержимое связей.

Returns

T

The total number of links in the storage that meet the specified restriction.

Общее число связей находящихся в хранилище, соответствующих указанному ограничению.

Creates an empty (index: 0 0) link, like every UnitedMemoryLinks.

public T Create(IList<T>? substitution, WriteHandler<T>? handler)

Parameters

substitution IList<T>
handler WriteHandler<T>

Returns

T

Deletes the link at the index of restriction, and every link that refers to it.

public T Delete(IList<T>? restriction, WriteHandler<T>? handler)

Parameters

restriction IList<T>
handler WriteHandler<T>

Returns

T

Exceptions

ArgumentException

The restriction holds no index.

Closes the connection.

public void Dispose()

Closes the owned connection when disposing managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Passes through all the links matching the pattern, invoking a handler for each matching link.

Выполняет проход по всем связям, соответствующим шаблону, вызывая обработчик (handler) для каждой подходящей связи.

public T Each(IList<T>? restriction, ReadHandler<T>? handler)

Parameters

restriction IList<T>

Restriction on the contents of links. Each constraint can have values: Constants.Null - the 0th link denoting a reference to the void, Any - the absence of a constraint, 1..∞ a specific link index.

Ограничение на содержимое связей. Каждое ограничение может иметь значения: Constants.Null - 0-я связь, обозначающая ссылку на пустоту, Any - отсутствие ограничения, 1..∞ конкретный индекс связи.

handler ReadHandler<T>

A handler for each matching link.

Обработчик для каждой подходящей связи.

Returns

T

Constants.Continue, if the pass through the links was not interrupted, and Constants.Break otherwise.

Constants.Continue, в случае если проход по связям не был прерван и Constants.Break в обратном случае.

Runs one operation on the server and returns its reply.

public IReadOnlyList<Link<string>> Execute(LinksOperation<T> operation)

Parameters

operation LinksOperation<T>

Returns

IReadOnlyList<Link<string>>

The link named name, or 0 when there is none.

public T GetByName(string name)

Parameters

name string

Returns

T
public string? GetName(T link)

Parameters

link T

Returns

string
public void RemoveName(T link)

Parameters

link T
public T SetName(T link, string name)

Parameters

link T
name string

Returns

T

Updates the link at the index of restriction to (index source target).

public T Update(IList<T>? restriction, IList<T>? substitution, WriteHandler<T>? handler)

Parameters

restriction IList<T>
substitution IList<T>
handler WriteHandler<T>

Returns

T

Exceptions

ArgumentException

The restriction or substitution is not of that shape.