kappa_sdk.EventBus#

class kappa_sdk.EventBus(service_address, access_token, buffer_size=1000, verify_ssl=True)[source]#

KAPPA Automate event bus.

SignalR-based event bus, running in a separate thread.

Note

Should not be instantiated directly.

Parameters:
  • service_address (str) – The address of the Signal-R event bus.

  • buffer_size (int) – The size of the message buffer for retrospective subscription. The event bus will keep a given number of messages and will feed them to each new subscriber, so the subscriber wouldn’t miss the events due to the eventual timing consistency.

  • access_token (str | None)

  • verify_ssl (bool)

Attributes

EventBus.daemon

A boolean value indicating whether this thread is a daemon thread.

EventBus.ident

Thread identifier of this thread or None if it has not been started.

EventBus.name

A string used for identification purposes only.

EventBus.native_id

Native integral thread ID of this thread, or None if it has not been started.

Methods

EventBus.getName()

Return a string used for identification purposes only.

EventBus.isDaemon()

Return whether this thread is a daemon.

EventBus.is_alive()

Return whether the thread is alive.

EventBus.join([timeout])

Wait until the thread terminates.

EventBus.run()

Starts the event bus.

EventBus.setDaemon(daemonic)

Set whether this thread is a daemon.

EventBus.setName(name)

Set the name string for this thread.

EventBus.start()

Start the thread's activity.

EventBus.stop()

Stops the event bus.

EventBus.subscribe(event_handler, event_filter)

Subscribes to events.

EventBus.subscribe_topic(event_handler, ...)

Subscribes to events by topic.

EventBus.unsubscribe(subscription_token)

Unsubscribes the event handler.

__init__(service_address, access_token, buffer_size=1000, verify_ssl=True)[source]#

This constructor should always be called with keyword arguments. Arguments are:

group should be None; reserved for future extension when a ThreadGroup class is implemented.

target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.

name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.

args is a list or tuple of arguments for the target invocation. Defaults to ().

kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.

If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.

Parameters:
  • service_address (str)

  • access_token (str | None)

  • buffer_size (int)

  • verify_ssl (bool)

subscribe(event_handler, event_filter, field_id=None)[source]#

Subscribes to events.

Subscribes to KAPPA Automate events.

Parameters:
  • event_handler (Callable[[Event, str], None]) – Your event handler. When called, your handler will be provided with the kappa_sdk.Event and subscription token.

  • event_filter (Callable[[Event], bool] | None) – Event filter that allows you to subscribe to single or multiple events, based on condition.

  • field_id (str | None) – Identifier of the field that is used to receive field-level events.

Returns:

str – Subscription token that can be used to unsubscribe your handler.

Return type:

str

subscribe_topic(event_handler, event_topic, event_filter=None, field_id=None)[source]#

Subscribes to events by topic.

Subscribes to KAPPA Automate events based on event topic.

Parameters:
  • event_handler (Callable[[Event, str], None]) – Your event handler. When called, your handler will be provided with the kappa_sdk.Event and subscription token.

  • event_topic (str) – Event topic to subscribe to.

  • event_filter (Callable[[Event], bool] | None) – Optional event filter that allows to specify an additional subscription condition.

  • field_id (str | None) – Identifier of the field that is used to receive field-level events.

Returns:

str – Subscription token that can be used to unsubscribe the handler.

Return type:

str

unsubscribe(subscription_token)[source]#

Unsubscribes the event handler.

Unsubscribes your event handler.

Parameters:

subscription_token (str) – Subscription token that was returned when calling “subscribe” or “subscribe_topic” methods.

Return type:

None