Skip to main content

SkipServiceBroker

Wrapper providing a method-call interface to the Skip service HTTP APIs.

Skip services, as started by runService, support an HTTP interface for reading from resources and writing to input collections. SkipServiceBroker provides a method-call interface to the backing HTTP interface.

Constructors​

new SkipServiceBroker()​

new SkipServiceBroker(entrypoint, timeout?): SkipServiceBroker

Construct a broker for a Skip service at the given entry point.

Parameters​

ParameterTypeDescription
entrypointEntrypointEntry point of backing service.
timeout?numberTimeout for request, in milliseconds. Defaults to 1000ms.

Returns​

SkipServiceBroker

Method-call broker to service.

Methods​

deleteKey()​

deleteKey<K>(collection, key): Promise<void>

Remove all values associated with a key in a collection.

Type Parameters​

Type ParameterDescription
K extends JsonType of keys.

Parameters​

ParameterTypeDescription
collectionstringName of the input collection to update, must be a key of the Inputs type parameter of the SkipService running at entrypoint.
keyKKey of entry to delete.

Returns​

Promise<void>


deleteUUID()​

deleteUUID(uuid): Promise<void>

Destroy a resource instance.

Under normal circumstances, resource instances are deleted automatically after some period of inactivity; this method enables immediately deleting live streams under exceptional circumstances.

Parameters​

ParameterTypeDescription
uuidstringResource instance UUID.

Returns​

Promise<void>


getAll()​

getAll<K, V>(resource, params): Promise<Entry<K, V>[]>

Read the entire contents of a resource.

Type Parameters​

Type ParameterDescription
K extends JsonType of keys.
V extends JsonType of values.

Parameters​

ParameterTypeDescription
resourcestringName of resource, must be a key of the resources field of the SkipService running at entrypoint.
paramsJsonResource instance parameters.

Returns​

Promise<Entry<K, V>[]>

All entries in resource.


getArray()​

getArray<K, V>(
resource,
params,
key): Promise<V[]>

Read the values a resource associates with a single key.

Type Parameters​

Type ParameterDescription
K extends JsonType of keys.
V extends JsonType of values.

Parameters​

ParameterTypeDescription
resourcestringName of resource, must be a key of the resources field of the SkipService running at entrypoint.
paramsJsonResource instance parameters.
keyKKey to read.

Returns​

Promise<V[]>

The values associated to the key.


getStreamUUID()​

getStreamUUID(resource, params): Promise<string>

Create a resource instance UUID.

Parameters​

ParameterTypeDescription
resourcestringName of resource, must be a key of the resources field of the SkipService running at entrypoint.
paramsJsonResource instance parameters.

Returns​

Promise<string>

UUID that can be used to subscribe to updates to resource instance.


getUnique()​

getUnique<K, V>(
resource,
params,
key): Promise<V>

Read the single value a resource associates with a key.

Type Parameters​

Type ParameterDescription
K extends JsonType of keys.
V extends JsonType of values.

Parameters​

ParameterTypeDescription
resourcestringName of resource, must be a key of the resources field of the SkipService running at entrypoint.
paramsJsonResource instance parameters.
keyKKey to read.

Returns​

Promise<V>

The value associated to the key.

Throws​

when the key is associated to either zero or multiple values.


update()​

update<K, V>(collection, entries): Promise<void>

Write multiple entries to a collection.

Type Parameters​

Type ParameterDescription
K extends JsonType of keys.
V extends JsonType of values.

Parameters​

ParameterTypeDescription
collectionstringName of the input collection to update, must be a key of the Inputs type parameter of the SkipService running at entrypoint.
entriesEntry<K, V>[]Entries to write.

Returns​

Promise<void>