Home > @imqueue/rpc

rpc package

Classes

Class

Description

ClusteredRedisQueue

Class ClusteredRedisQueue Implements the possibility to scale queues horizontally between several redis instances.

Description

IMQCache

Generic cache registry

IMQDelay

Represents a delay expressed as a numeric timer value in a given time unit. Used to defer IMQ request processing.

IMQLock

Class IMQLock. Implements promise-based locks.

IMQMetadata

Arbitrary, JSON-serializable metadata bag carried alongside an IMQ request. Each property value must be a valid JSON value.

IMQRPCDescription

RedisCache

Class RedisCache. Implements a cache engine on top of Redis.

RedisQueue

Class RedisQueue Implements a simple messaging queue over redis.

UDPClusterManager

Abstract Classes

Abstract Class

Description

IMQClient

Class IMQClient - base abstract class for service clients.

IMQService

Class IMQService Basic abstract service (server-side) implementation

Enumerations

Enumeration

Description

IMQMode

LogLevel

Functions

Function

Description

classType()

Implements the '@classType' decorator factory.

Applied to a complex-type class, it registers the class's '@property' field definitions into the RPC type description so the type can be exposed to service clients. It is required on any class that uses '@property': standard (TC39) field decorators cannot see the class they belong to, so a class-level decorator is needed to flush the collected properties under the class name.

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. Applied to a service method, it registers that method in the RPC service description. (Complex argument/return types are registered separately via the '@classType' decorator on those classes.)

{(value: any, context: ClassMethodDecoratorContext) => void}

imqCallRejector(reject, req, client)

Builds a call rejector that rejects the pending promise and then runs the optional after-call hook.

imqCallResolver(resolve, req, client)

Builds a call resolver that resolves the pending promise and then runs the optional after-call hook.

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

Builds a JSON representation of an 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)

Creates a @lock() method decorator. Concurrent calls to the decorated method that share the same arguments are coalesced: only the first call is executed, and all the others resolve with its result. Call similarity is determined by the method's argument values. The returned decorator is dual-mode: it works both as a standard (TC39) and as a legacy method decorator.

logDebugInfo({ debugTime, debugArgs, className, args, methodName, start, logger, logLevel, }, input)

Logs debug information about a function call

logged(options)

Creates a @logged() method decorator that wraps the decorated method in a try/catch and logs any error it throws. The logger is resolved in this order: an explicitly passed logger, then a logger defined on the instance or on the class, and finally the global console. By default the error is re-thrown after being logged; pass { doNotThrow: true } to swallow it. The returned decorator is dual-mode: it works both as a standard (TC39) and as a legacy method decorator.

profile(options)

Implements '@profile' decorator.

property(type, isOptional)

registerType(ctor, metadata, indexType)

Flushes definitions collected on a class into the RPC type description. Invoked by class-level decorators once the class (and hence its name) is available.

remote()

Creates a @remote() method decorator for client classes. The decorated method has the remote method name appended to its arguments and is then forwarded to remoteCall(). The returned decorator is dual-mode: it works both as a standard (TC39) and as a legacy (experimentalDecorators) method decorator.

{Function} - a dual-mode method decorator

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

verifyLogLevel(level)

Validates a log level value or returns the default

Interfaces

Interface

Description

ArgDescription

Method argument description

CacheDecorator

CacheDecoratorOptions

DebugInfoOptions

EventMap

ICache

Generic cache adapter interface. Any cache engine implementation must conform to this contract to be usable within IMQ.

ICacheConstructor

Constructor signature for cache adapter implementations.

ILogger

Logger interface

IMessage

Defines a message format.

{IMessage}

IMessageQueue

Generic messaging queue implementation interface

IMessageQueueAuthConnection

IMessageQueueConnection

IMQAfterCall

Hook invoked after a service method call has been handled.

IMQBeforeCall

Hook invoked before a service method call is dispatched.

IMQClientOptions

Options accepted by a generated IMQ client.

IMQLockMetadata

IMQLockMetadataItem

IMQMetricsServerOptions

Options for the built-in metrics server.

IMQOptions

Message queue options

IMQRPCError

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

IMQRPCRequest

Request message data structure to be handled by a service.

IMQRPCResponse

Response message data structure that a service replies with to handled requests.

IMQServiceOptions

Options accepted by an IMQ service.

IRedisCacheOptions

IRedisClient

Extends the default Redis type to allow dynamic properties access on it

{IRedisClient}

IServerInput

JsonArray

Represents JSON-serializable array

JsonObject

Represents JSON serializable object

LockOptions

LoggedDecoratorOptions

MethodDescription

Method description

MethodsCollectionDescription

Methods collection description

ProfileDecoratorOptions

PropertyDescription

Type property description

ReturnValueDescription

Return value description

ServiceClassDescription

Service class description

ServiceDescription

Service description

Thunk

TypeDescription

Type properties collection description

TypesDescription

Entire service types metadata structure

UDPClusterManagerOptions

Variables

Variable

Description

AFTER_HOOK_ERROR

BEFORE_HOOK_ERROR

cache

Creates a @cache() method decorator that memoizes the decorated method's result in a cache adapter (RedisCache by default). On each call the cache is checked first; on a miss the method runs, and its result is stored under a key derived from the class name, method name, and arguments. The returned decorator is dual-mode: it works both as a standard (TC39) and as a legacy method decorator.

DEFAULT_IMQ_CLIENT_OPTIONS

Default client options

{IMQClientOptions}

DEFAULT_IMQ_METRICS_SERVER_OPTIONS

Default metrics server options

{NonNullable}

DEFAULT_IMQ_OPTIONS

DEFAULT_IMQ_SERVICE_OPTIONS

Default service options

{IMQServiceOptions}

DEFAULT_REDIS_CACHE_OPTIONS

DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS

IMQ_CONNECTION_QUIT_TIMEOUT

Grace period (ms) for a graceful QUIT to complete before a channel is forcibly disconnected. A reader blocked on an infinite BRPOP/BLMOVE can never let QUIT through, so without this the socket would leak and keep the process alive.

IMQ_LOG_ARGS

Environment variable IMQ_LOG_ARGS=[1, 0]. Enable or disable logging of profiled call arguments.

{boolean}

IMQ_LOG_LEVEL

IMQ_LOG_TIME_FORMAT

Environment variable IMQ_LOG_TIME_FORMAT. Specifies the format for profiled time logging. Values: 'microseconds', 'milliseconds', 'seconds'. Default: 'microseconds'

{AllowedTimeFormat | string}

IMQ_LOG_TIME

Environment variable IMQ_LOG_TIME=[1, 0]. Enable or disable profiled timing logging.

{boolean}

IMQ_SHUTDOWN_TIMEOUT

REDIS_CLIENT_INIT_ERROR

Type Aliases

Type Alias

Description

AcquiredLock

AllowedTimeFormat

AnyJson

Represents any JSON-serializable value

ICacheAdapter

Accepted cache adapter references: a constructor, an instance, or an adapter name.

IMessageQueueConstructor

IMQLockQueue

IMQLockTask

LoggedLogLevel

UDPWorkerOptions

Subset of the manager options handed over to the UDP worker thread. Only structured-cloneable values may appear here (no logger).