UNPKG

@darlean/core

Version:

Darlean core functionality for creating applications that define, expose and host actors

51 lines (50 loc) 2.36 kB
/// <reference types="node" /> /** * Provides serialization and deserialization for over-the-wire Darlean messages. * * Uses the serialization as provided in {@link @darlean/core/fastproto}. * * ## Format of messages * * Messages consist of the following list of fields written after each other to a buffer: * * MajorVersion - Character ('0' for now) * * MinorVersion - Character ('0' for now) * * TransportReceiver - String * * TransportReturn - String * * TransportFailureCode - String * * TransportFailureMessage - String * * TracingCids - Variant * * TracingTags - String * * RemoteCallId - String * * RemoteCallKind - Character 'c' (call) or 'r' (return) * * CallRequestLazy - Character 't' (true) or 'f' (false) * * CallRequestActorType - String * * CallRequestActionName - String * * CallRequestActorIdNumberParts - UInt * * CallRequestActorIdPart* - String (for each part) * * CallRequestArgumentsCount - UInt * * CallRequestArgument* - Variant (for each arg) * * CallResponseResult - Variant * * CallResponseError - Json * * ## Notes * * Implementations must not continue when the received major version is larger than their own supported major version. */ import { IActorCallRequest, IActorCallResponse } from '@darlean/base'; import { ITransportFailure } from './transport'; import { IDeSer } from '@darlean/utils'; import { ITracingTags, IRemoteCallTags, ITransportTags } from './wiretypes'; /** * Serializes a set of tags into a Buffer. * @param value The set of tags to be serialized * @param deser Serializer that is used when serializing structured data * @returns A buffer containing the serialized data. */ export declare function serialize(value: ITracingTags & ITransportTags & IRemoteCallTags & (IActorCallRequest | IActorCallResponse | ITransportFailure | never), deser: IDeSer): Buffer; /** * Deserializes a binary chunk of data that was previously serialized with {@link serialize}. * @param value The buffer to be deserialized. * @param deser The deserializer to be used for deserializing structured data elements. * @returns The deserialized set of tags. */ export declare function deserialize(value: Buffer, deser: IDeSer): ITracingTags & ITransportTags & IRemoteCallTags & (IActorCallRequest | IActorCallResponse | ITransportFailure | never);