Optional
onA record mapping event types to middleware functions for processing CloudEvents.
When a CloudEvent occurs (e.g., Instance<CloudOrchestrationActor>.cloudevent(Instance<CloudEvent>)
),
the registered function is invoked, transforming and returning data. Use this to convert CloudEvent data
for merging or upserting into the orchestrator's context.
Optional
onA record mapping event types to middleware functions for handling orchestration based on state and snapshot.
This is used to emit a CloudEvent when a specified state is reached. The onState function is called upon state
attainment, and the returned object constructs a CloudEvent. Access these events using Instance<CloudOrchestrationActor>.eventsToEmit
.
// Example middleware options for a cloud orchestrator.
const middlewareOptions: CloudOrchestratorMiddlewares = {
onCloudEvent: {
'evt.books.fetch.success': (event) => ({
type: event.type,
data: {
// Transforming CloudEvent data
content: event.data.content.join(' ')
}
}),
},
onState: {
'fetch_book': (id, state, { context }) => ({
type: 'cmd.books.fetch',
data: { book_id: "some-book.pdf"}
}),
// Nested states
'#regulation.#grounded.check': (id, state, snapshot) => ({...}),
'#regulation.#compliance.check': (id, state, snapshot) => ({...}),
},
};
Generated using TypeDoc
Interface defining middleware options for a Cloud Orchestration Actor, facilitating customization of event processing and orchestration logic. It includes two optional properties: 'onCloudEvent' and 'onState', each mapping event types to their respective middleware functions.