You're viewing archived documentation for @imqueue/rpc v2.1.0. APIs may differ from the current release. View the latest version ↗

rpc package

Classes

Class

Description

Description

IMQCache

Generic cache registry

IMQDelay

IMQLock

Class IMQLock. Implements promise-based locks.

IMQMetadata

IMQRPCDescription

RedisCache

Class RedisCache. Implements cache engine over redis.

Abstract Classes

Abstract Class

Description

IMQClient

Class IMQClient - base abstract class for service clients.

IMQService

Class IMQService Basic abstract service (server-side) implementation

Functions

Function

Description

currentMetadata()

Returns the metadata of the in-flight IMQ request for the current async execution, if any. Returns undefined outside of a runWithRequest() scope. The transport carries metadata as an opaque bag; callers interpret its fields.

{IMQMetadata | undefined}

expose()

Expose decorator factory

{( target: object, methodName: (string), descriptor: TypedPropertyDescriptor<(...args: any[]) => any> ) => void} - decorator function

fileExists(path)

Checks if file exists at given path

forgetPid(name, id, logger, path)

Removes pid file for a given name and id

imqCallRejector(reject, req, client)

Builds and returns call rejector, which supports after call optional hook

imqCallResolver(resolve, req, client)

Builds and returns call resolver, which supports after call optional hook

IMQError(code, message, stack, method, args, original)

Builds JSON representation of IMQ Error

indexed(indexTypedef)

Implements '@indexed' decorator factory This is used to specify complex service types which are need to expose types containing indexed definition, for example:

lock(enabledOrOptions)

@lock() decorator implementation Will make all simultaneous similar method calls locked to be resolved with the first obtained values. Similarity is identified by a bypassed method argument values.

logged(options)

Logger decorator factory for class methods. Will try, catch and log errors during method calls. If logger is bypassed, will use given logger, otherwise will try to use logger defined on class dynamically or statically or will fallback to console.

mkdir(path)

Async mkdir

osUuid()

Returns machine UUID

pid(name, path)

Returns increment-based process identifier for a given name

property(type, isOptional)

Implements '@property' decorator factory This is used to specify complex service types to be exposed

remote()

Implements '@remote' decorator factory

{( target: any, methodName: (string), descriptor: TypedPropertyDescriptor<(...args: any[]) => any> ) => void}

runWithRequest(request, fn)

Runs the given function with request bound to the current async execution context, so any code reached from it (and its asynchronous continuations) can access the in-flight request's metadata via currentMetadata() without threading it through call signatures.

The binding is scoped to the function: it is established for the duration of the call and automatically removed afterwards, which keeps concurrent requests isolated from one another.

send(request, response, service)

Sends IMQ response with support of after call optional hook

signature(className, methodName, args)

Constructs and returns hash string for a given set of className, methodName and arguments.

writeFile(path, content)

Async writeFile

Interfaces

Interface

Description

ArgDescription

Method argument description

CacheDecorator

CacheDecoratorOptions

ICache

ICacheConstructor

IMQAfterCall

IMQBeforeCall

IMQClientOptions

IMQLockMetadata

IMQLockMetadataItem

IMQMetricsServerOptions

IMQRPCError

Response error data structure, which service returns if error occurred during service method execution.

IMQRPCRequest

Request message data structure expected to be handled by a service

IMQRPCResponse

Response message data structure, which service replies to handled requests.

IMQServiceOptions

IRedisCacheOptions

LockOptions

LoggedDecoratorOptions

MethodDescription

Method description

MethodsCollectionDescription

Methods collection description

PropertyDescription

Service type description

ReturnValueDescription

Return value description

ServiceClassDescription

Service class description

ServiceDescription

Service description

Thunk

TypeDescription

Service types description

TypesDescription

Entire service types metadata structure

Variables

Variable

Description

AFTER_HOOK_ERROR

BEFORE_HOOK_ERROR

cache

DEFAULT_IMQ_CLIENT_OPTIONS

Default client options

{IMQClientOptions}

DEFAULT_IMQ_METRICS_SERVER_OPTIONS

Default metric server options

{NonNullable}

DEFAULT_IMQ_SERVICE_OPTIONS

Default service options

{IMQServiceOptions}

DEFAULT_REDIS_CACHE_OPTIONS

IMQ_PID_DIR

IMQ_TMP_DIR

REDIS_CLIENT_INIT_ERROR

SIGNALS

Type Aliases

Type Alias

Description

AcquiredLock

ICacheAdapter

IMQLockQueue

IMQLockTask

LoggedLogLevel