Categorygithub.com/AccelByte/messagebus-go-sdk
modulepackage
1.2.0
Repository: https://github.com/accelbyte/messagebus-go-sdk.git
Documentation: pkg.go.dev

# README

Build Status

messagebus-go-sdk

Go SDK to connecting AccelByte's justice Go services over message broker

Supported Message Broker

  • Apache Kafka

Usage

Importing Package

import "github.com/AccelByte/messagebus-go-sdk"

Publish Asynchronous Message

Publish message asynchronously

client.PublishAsync(
		NewPublish().
			Topic("topic").
			MessageType("message type").
			Message("test message").
			Service("service name").
			TraceID("trace id").
			MessageID("message id"))

Publish Synchronous Message

Publish message synchronously with error response

err := client.PublishSync(
		NewPublish().
			Topic("topic").
			MessageType("message type").
			Message("test message").
			Service("service name").
			TraceID("trace id").
			MessageID("message id"))

Publish Message With Response

Publish message and wait a response from consumer (restful api concepts) with timeout.

client.PublishWithResponses(
		NewPublish().
			Topic("topic").
			MessageType("message type").
			Message("test message").
			TraceID("trace id").
			MessageID("message id").
			Callback(func(message *Message, err error))

Set global timeout for publish message with response (in millisecond)

client.SetTimeout(10000)

Register Callback for Subscribe Message

Register callback function for specific topic and message type.

client.Register(
		NewSubscribe().
		    Topic("topic").
		    MessageType("message type").
		    Callback(func(message *Message, err error)))

Authentication

SASL-SCRAM Authentication

Example configuration:

securityConfig := &messagebus.SecurityConfig{
    AuthenticationType: "SASL-SCRAM",
    SASLUsername:       "username",
    SASLPassword:       "password",
}
kafkaClient, err := messagebus.NewKafkaClientWithAuthentication("localhost:9092", "realmName", securityConfig)

# Functions

NewKafkaClient create a new instance of KafkaClient.
NewKafkaClientWithAuthentication create a new instance of KafkaClient with Authentication.
NewPublish create new PublishBuilder instance.
NewSubscribe create new SubscribeBuilder instance.

# Constants

No description provided by the author
No description provided by the author

# Structs

KafkaClient wraps client's functionality for Kafka.
Message defines the structure of response or incoming message.
PublishBuilder defines the structure of message which is sent through message broker.
PublishBuilderEntry defines data structure to use with Kafka client.
No description provided by the author
No description provided by the author
SubscribeBuilder defines the structure of message which is sent through message broker.

# Interfaces

Client is an interface for message broker functionality.