Class RemoteLinks<T>
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>>INamedTypes<T>
- Derived
- Inherited Members
- Extension Methods
Remarks
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
RemoteLinks(LinksClient)
Uses an existing connection, which the store then owns.
public RemoteLinks(LinksClient client)
Parameters
clientLinksClient
Properties
Constants
The constants of the UnitedMemoryLinks a server stores its links in.
public LinksConstants<T> Constants { get; }
Property Value
- LinksConstants<T>
Methods
Connect(string, ILinoProtocol)
Connects to a server at an address written as host:port.
public static RemoteLinks<T> Connect(string endPoint, ILinoProtocol protocol)
Parameters
endPointstringprotocolILinoProtocol
Returns
- RemoteLinks<T>
ConnectEndpoint(string, ILinoProtocol)
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
endpointstringprotocolILinoProtocol
Returns
- RemoteLinks<T>
Count(IList<T>?)
Counts and returns the total number of links in the storage that meet the specified restriction.
Подсчитывает и возвращает общее число связей находящихся в хранилище, соответствующих указанному ограничению.
public T Count(IList<T>? restriction)
Parameters
restrictionIList<T>Restriction on the contents of links.
Ограничение на содержимое связей.
Returns
- T
The total number of links in the storage that meet the specified restriction.
Общее число связей находящихся в хранилище, соответствующих указанному ограничению.
Create(IList<T>?, WriteHandler<T>?)
Creates an empty (index: 0 0) link, like every UnitedMemoryLinks.
public T Create(IList<T>? substitution, WriteHandler<T>? handler)
Parameters
substitutionIList<T>handlerWriteHandler<T>
Returns
- T
Delete(IList<T>?, WriteHandler<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
restrictionIList<T>handlerWriteHandler<T>
Returns
- T
Exceptions
- ArgumentException
The restriction holds no index.
Dispose()
Closes the connection.
public void Dispose()
Dispose(bool)
Closes the owned connection when disposing managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
Each(IList<T>?, ReadHandler<T>?)
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
restrictionIList<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..∞ конкретный индекс связи.
handlerReadHandler<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 в обратном случае.
Execute(LinksOperation<T>)
Runs one operation on the server and returns its reply.
public IReadOnlyList<Link<string>> Execute(LinksOperation<T> operation)
Parameters
operationLinksOperation<T>
Returns
- IReadOnlyList<Link<string>>
GetByName(string)
The link named name, or 0 when there is none.
public T GetByName(string name)
Parameters
namestring
Returns
- T
GetName(T)
public string? GetName(T link)
Parameters
linkT
Returns
RemoveName(T)
public void RemoveName(T link)
Parameters
linkT
SetName(T, string)
public T SetName(T link, string name)
Parameters
linkTnamestring
Returns
- T
Update(IList<T>?, IList<T>?, WriteHandler<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
Returns
- T
Exceptions
- ArgumentException
The restriction or substitution is not of that shape.