Class TripletsOperation
The triplets of a server in triplet mode (issue #152) as LiNo documents, so a store behind a LinksServer is used exactly like a local ITriplets<TLinkAddress> store through RemoteLinks.
public abstract record TripletsOperation : IEquatable<TripletsOperation>
- Inheritance
-
TripletsOperation
- Implements
- Derived
- Inherited Members
Remarks
(delete: i), (count: ()) and a substitution query read the same in both worlds, so the shape of a
request cannot tell a triplet from a doublet. That is why triplets are a mode of the server,
Triplets (clink --serve --triplets): a server without it answers exactly
as it always did, and one with it reads every request as triplets.
| Request | Reply |
|---|---|
(count: (index type from to)) | (count: N) |
(each: (index type from to)) | one (index: type from to) per match |
(create: (type from to)) | () ((index: type from to)) |
(create: (0 0 0)) | () ((index: index 0 0)), a point: a triplet that is its own type |
(update: (index type from to)) | ((index: t f t)) ((index: type from to)) |
(delete: index) | ((index: type from to)) () per removed triplet, index first |
(subscribe: (index type from to)) | (subscription: N); later pushes of (notify: N) and its changes |
get-name, set-name, get-by-name, remove-name, unsubscribe and auth are the
same as without triplets (LinksOperation), and the empty request lists every triplet. Any other
document is a substitution query over triplets (TripletsQueryProcessor); its reply names the
references that have a name, like a query over doublets.
A restriction holds up to four parts, matched part by part: the parts it leaves out match anything, as does
*; an empty from or to is 0. The wrappers and pairs that store a triplet in doublets
never appear.
A reply or push in a binary format whose arity holds three references but not the five of
(index: type from to), such as 2..3, carries every triplet as (index: (type from to)), which
travels as one link of three references; see Pack(IReadOnlyList<Link<string>>, MessageFormat). Every parser here reads both forms.
Methods
Canonical(IReadOnlyList<Link<string>>)
The inverse of Pack(IReadOnlyList<Link<string>>, MessageFormat): the canonical text of a triplet reply does not depend on the format that carried it.
public static IReadOnlyList<Link<string>> Canonical(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
- IReadOnlyList<Link<string>>
ChangesDocument(IEnumerable<TripletChange<uint>>)
A reply listing changes, one (before) (after) line each.
public static IReadOnlyList<Link<string>> ChangesDocument(IEnumerable<TripletChange<uint>> changes)
Parameters
changesIEnumerable<TripletChange<uint>>
Returns
- IReadOnlyList<Link<string>>
Execute(ITriplets<uint>)
Runs the operation against triplets and returns the reply document.
public abstract IReadOnlyList<Link<string>> Execute(ITriplets<uint> triplets)
Parameters
Returns
- IReadOnlyList<Link<string>>
ExecuteRequest(ITriplets<uint>, IReadOnlyList<Link<string>>)
Answers one request of a server in triplet mode against triplets; failures produce an
ErrorDocument(string). The counterpart of ExecuteRequest(INamedTypesLinks<uint>, IReadOnlyList<Link<string>>, bool).
public static IReadOnlyList<Link<string>> ExecuteRequest(ITriplets<uint> triplets, IReadOnlyList<Link<string>> document)
Parameters
tripletsITriplets<uint>documentIReadOnlyList<Link<string>>
Returns
- IReadOnlyList<Link<string>>
FromDocument(IReadOnlyList<Link<string>>)
Recognises a triplet operation; null for any other document, such as a substitution query or a request about names.
public static TripletsOperation? FromDocument(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
Exceptions
- LinoProtocolException
The document names an operation but its argument is malformed.
Matches(Triplet<uint>, LinksRestriction)
Whether triplet matches restriction, part by part.
public static bool Matches(Triplet<uint> triplet, LinksRestriction restriction)
Parameters
tripletTriplet<uint>restrictionLinksRestriction
Returns
NotificationDocument(uint, IEnumerable<TripletChange<uint>>)
A push: (notify: N) followed by one (before) (after) line per change.
public static IReadOnlyList<Link<string>> NotificationDocument(uint subscription, IEnumerable<TripletChange<uint>> changes)
Parameters
subscriptionuintchangesIEnumerable<TripletChange<uint>>
Returns
- IReadOnlyList<Link<string>>
Pack(IReadOnlyList<Link<string>>, MessageFormat)
Rewrites every triplet of document so it fits format: in a binary format
whose arity holds three references but not five, (index: type from to) becomes
(index: (type from to)), whose second part travels as one link of three references. Under any other
format the document stays as it is.
public static IReadOnlyList<Link<string>> Pack(IReadOnlyList<Link<string>> document, MessageFormat format)
Parameters
documentIReadOnlyList<Link<string>>formatMessageFormat
Returns
- IReadOnlyList<Link<string>>
Remarks
(index: type from to) needs a link of five references, the marker of a named link and the index included,
so under 2..3 the mapping would spell it as a chain of doublets: nothing would gain from the arity.
ParseChanges(IReadOnlyList<Link<string>>)
The (before) (after) pairs of a create, update or delete reply.
public static IReadOnlyList<TripletChange<uint>> ParseChanges(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
ParseNotification(IReadOnlyList<Link<string>>)
The subscription and the changes of a NotificationDocument(uint, IEnumerable<TripletChange<uint>>).
public static TripletsNotification ParseNotification(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
ParseTriplet(Link<string>)
A triplet, as (index: type from to) or as Pack(IReadOnlyList<Link<string>>, MessageFormat) writes it.
public static Triplet<uint> ParseTriplet(Link<string> link)
Parameters
linkLink<string>
Returns
ParseTriplets(IReadOnlyList<Link<string>>)
The triplets of an each reply.
public static IReadOnlyList<Triplet<uint>> ParseTriplets(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
Query(LinksRestriction)
The query a restriction asks for; the parts it leaves out match anything.
public static TripletQuery<uint> Query(LinksRestriction restriction)
Parameters
restrictionLinksRestriction
Returns
RestrictionOf(TripletQuery<uint>)
The restriction of query, in the order of the wire.
public static LinksRestriction RestrictionOf(TripletQuery<uint> query)
Parameters
queryTripletQuery<uint>
Returns
ToDocument()
The request document for this operation.
public IReadOnlyList<Link<string>> ToDocument()
Returns
- IReadOnlyList<Link<string>>
TripletLino(Triplet<uint>)
(index: type from to) with plain numbers.
public static Link<string> TripletLino(Triplet<uint> triplet)
Parameters
Returns
- Link<string>