events

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2023 License: MIT Imports: 3 Imported by: 3

README

fc-bus

A golang package for simplifying message bus communication in fc-hosting

Requirements

A kubemq installation in the kubemq namespace of your cluster

Usage

// create context
ctx := context.Background()

// initialize bus
bus := events.Bus{
	Channel: "channel-name", // kubemq channel name
	ClientId: "test", // client id
	Context: ctx, // context
	TransportType: kubemq.TransportTypeGRPC, // set transport type
}

// connect to bus
// returns a kubemq.QueuesClient & an error
client, err := bus.Connect()

if err != nil {
	// ...
}

// register handler for messages on that queue
// returns a channel of type struct{} or an error
done, err := bus.Subscribe(client, func(msgs *kubemq.ReceiveQueueMessagesResponse, subscribeError error) {
	// process message
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	Channel       string
	ClientId      string
	Context       context.Context
	TransportType kubemq.TransportType
}

func (*Bus) Connect

func (b *Bus) Connect() (kubemq.QueuesClient, error)

func (*Bus) Subscribe

func (b *Bus) Subscribe(client kubemq.QueuesClient, handler func(msg *kubemq.ReceiveQueueMessagesResponse, err error)) (chan struct{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL