KafkaExternalService
An ExternalService
wrapping a Kafka cluster, exposing its topics as collections in the Skip runtime.
This adapter allows to easily create Kafka consumers, subscribing to external event/message streams and exposing their content as eager collections within the Skip runtime.
For a usage example, refer here.
Remarks
Subscription params
may specify a fromBeginning
boolean, which controls whether to consume all Kafka messages from the cluster, or only those sent since the creation of this external resource.
Implements
ExternalService
Constructors
new KafkaExternalService()
new KafkaExternalService(
kafka_config,
messageProcessor,
consumerOptions): KafkaExternalService
Parameters
Parameter | Type |
---|---|
kafka_config | { brokers : object []; clientId : string ; logLevel : logLevel ; } |
kafka_config.brokers | object [] |
kafka_config.clientId | string |
kafka_config.logLevel ? | logLevel |
messageProcessor | (msg ) => Iterable <[Json , Json ]> |
consumerOptions | Omit <ConsumerConfig , "groupId" > |
Returns
Methods
shutdown()
shutdown(): Promise<void>
Shutdown the external service.
Returns
Promise
<void
>
Implementation of
ExternalService.shutdown
subscribe()
subscribe(
instance,
topic,
params,
callbacks): Promise<void>
Subscribe to a resource provided by the external service.
Parameters
Parameter | Type | Description |
---|---|---|
instance | string | Instance identifier of the external resource. |
topic | string | Name of the Kafka topic to expose as a resource. |
params | { fromBeginning : boolean ; } | Parameters of the external resource. |
params.fromBeginning ? | boolean | Controls whether to consume all Kafka messages from the cluster, or only from the creation of this external resource. |
callbacks | { error : (error ) => void ; update : (updates , isInit ) => Promise <void >; } | Callbacks to react on error/update. |
callbacks.error | (error ) => void | Error callback. |
callbacks.update | (updates , isInit ) => Promise <void > | Update callback. |
Returns
Promise
<void
>
Implementation of
ExternalService.subscribe
unsubscribe()
unsubscribe(instance): void
Unsubscribe from a resource provided by the external service.
Parameters
Parameter | Type | Description |
---|---|---|
instance | string | Instance identifier of the external resource. |
Returns
void
Implementation of
ExternalService.unsubscribe