choreo/event_publisher

1.0.2

Overview

This is a Choreo client that can be used to publish Choreo events to a configured WebSub hub topic.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

  • Configure a topic in WebSub hub and obtain the WebSub hub URL and topic name

Quickstart

To use the Choreo event publisher in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

First, import the choreo/event_publisher module into the Ballerina project.

Copy
import choreo/event_publisher;

Step 2: Create a new connector instance

Create a event_publisher:ClientConfiguration with the client configurations details, and initialize the connector with it.

Copy
event_publisher:ClientConfiguration config = {
    // Configure the relevant configs
}
event_publisher:Client publisherClient = check new("<WebSubHubUrl>", "<Topic>", <PollingInterval>, <MaximumQueueLength>, config);

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.

    Following is an example on how to publish a Choreo event to the configured WebSub hub topic using the connector.

    Publish Choreo event

    Copy
    public function main() returns error? {
        publisherClient->publishEvent({
            orgUuid: "<orgUuid>",
            timestamp: "<timestamp>",
            userIdpId: "<userIdpId>",
            projectId: "<projectId>",
            action: "<action>",
            entityType: "<entityType>",
            info: {},
            outcome: event_publisher:SUCCEEDED
        });
    }
  2. Use bal run command to compile and run the Ballerina program.

Import

import choreo/event_publisher;Copy

Metadata

Released date: over 1 year ago

Version: 1.0.2


Compatibility

Platform: any

Ballerina version: 2201.3.1

GraalVM compatible: Yes


Pull count

Total: 30203

Current verison: 326


Weekly downloads


Other versions