package @eventicle/eventicle-utilities

Interfaces

Name Summary

ds.DataQuery

Allow querying against a single field.

Will be mapped to a specific query technology by the underlying Datastore implementation.

ds.DataSorting

Sort a

ds.DataStore

Abstraction around data storage in the form of document style records.

Eventicle contains a built in InMemoryDatastore. Others can be imported as needed.

ds.PagedRecords

ds.Record

ds.TransactionData

Bag of data that is associated with a given Transaction inside the Datastore.

Datastore/ eventClient specific. Can be added to by user code, but data inside it should be considered subject to change between versions

ds.TransactionListener

Datastore implementations that support Transactions will emit events on transaction start and commit. This interface defines the listener for those interfaces.

Notably, eventClient implementations register a TransactionListener in order to commit events after any local database is committed.

ds.TransactionOptions

Control whether a new Datastore transaction is required, and if so, if it should join an existing transaction or create a new one to use.

LockManager_2

Lock abstraction. This interface is used inside of Eventicle to provide semaphore access to shared resources. Notably, this obtains exclusive locks around AggregateRoot instances when processing inside of Commands and Saga steps.

LogApi

Functions

ds.dataStore()

The current implementation that Eventicle uses for internal data. Can be used by application code to obtain a reference if required.

Signature
declare function dataStore(): DataStore;

ds.setDataStore(dataStore)

Set the Datastore implementation that Eventicle will use to persist in.

Parameters
Name Type Description

dataStore

ds.DataStore

Returns

void

Signature
declare function setDataStore(dataStore: DataStore): void;

elasticApmEventicle(apm)

Parameters
Name Type Description

apm

any

Returns

\~ApmApi

Signature
export declare function elasticApmEventicle(apm: any): ApmApi;

getAPM()

Signature
export declare function getAPM(): ApmApi;

getApmCurrentTraceIds()

Signature
export declare function getApmCurrentTraceIds(): any;

getApmTraceparent()

Signature
export declare function getApmTraceparent(): string;

hashCode(str)

Parameters
Name Type Description

str

string

Returns

number

Signature
export declare function hashCode(str: string): number;

lockManager()

Signature
export declare function lockManager(): LockManager;

loggerUtil.getFileNameAndLineNumber(numberOfLinesToFetch)

Parameters
Name Type Description

numberOfLinesToFetch

number

Returns

{ file: any; lineno: any; timestamp: string; }

Signature
export declare function getFileNameAndLineNumber(numberOfLinesToFetch?: number): {
    file: any;
    lineno: any;
    timestamp: string;
};

loggerUtil.handleNestedContextualError(info)

Parameters
Name Type Description

info

any

Returns

any

Signature
export declare function handleNestedContextualError(info: any): any;

loggerUtil.handleTopLevelContextualError(info)

Parameters
Name Type Description

info

any

Returns

any

Signature
export declare function handleTopLevelContextualError(info: any): any;

loggerUtil.isError(data)

Parameters
Name Type Description

data

any

Returns

@eventicle/eventicle-utilities!\~data is Error

Signature
export declare function isError(data: any): data is Error;

loggerUtil.maybeInsertContext(context, source, fields)

Parameters
Name Type Description

context

any

source

any

fields

string[]

Returns

any

Signature
export declare function maybeInsertContext(context: any, source: any, ...fields: string[]): any;

loggerUtil.maybeInsertInlineContext(message, source, fields)

Parameters
Name Type Description

message

string

source

any

fields

string[]

Returns

string

Signature
export declare function maybeInsertInlineContext(message: string, source: any, ...fields: string[]): string;

loggerUtil.maybeRenderError(data)

Parameters
Name Type Description

data

any

Returns

any

Signature
export declare function maybeRenderError(data: any): any;

loggerUtil.proxyLogger(logger, baseDirName)

Parameters
Name Type Description

logger

winston.Logger

baseDirName

string

Returns

winston.Logger

Signature
export declare function proxyLogger(logger: Logger, baseDirName: string): winston.Logger;

pause(ms)

Utility function to pause for a given number of ms.

Parameters
Name Type Description

ms

number

Returns

Promise<void>

Signature
declare function pause(ms: number): Promise<void>;

setEventicleApm(apm)

Parameters
Name Type Description

apm

\~ApmApi

Returns

void

Signature
export declare function setEventicleApm(apm: ApmApi): void;

setLockManager(lockManager)

Parameters
Name Type Description

lockManager

LockManager_2

Returns

void

Signature
export declare function setLockManager(lockManager: LockManager): void;

setLogApi(log)

Parameters
Name Type Description

log

LogApi

Returns

void

Signature
export declare function setLogApi(log: LogApi): void;

span(name, labels, exec)

Parameters
Name Type Description

name

string

labels

{ [key: string]: string; }

exec

(span: \~Span) => Promise<T>

Returns

Promise<T>

Signature
export declare function span<T>(name: string, labels: {
    [key: string]: string;
}, exec: (span: Span) => Promise<T>): Promise<T>;

withAPM(exec)

Parameters
Name Type Description

exec

(apm: \~ApmApi) => Promise<void>

Returns

Promise<void>

Signature
export declare function withAPM(exec: (apm: ApmApi) => Promise<void>): Promise<void>;