eventbusclient

package module
v0.0.0-...-c228acb Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 6 Imported by: 0

README

EventBus client library

import "github.com/best-expendables-v2/eventbus-client"

Usage

Check _example folder

Documentation

Index

Constants

View Source
const (
	MessageStatusAck    = "ack"
	MessageStatusReject = "reject"
	MessageStatusNack   = "nack"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host         string `envconfig:"EVENTBUS_HOST" required:"true"`
	Port         string `envconfig:"EVENTBUS_PORT" required:"true"`
	Username     string `envconfig:"EVENTBUS_USERNAME" required:"true"`
	Password     string `envconfig:"EVENTBUS_PASSWORD" required:"true"`
	PrefectCount int    `envconfig:"EVENTBUS_PREFECT_COUNT" required:"false" default:"50"`
}

Config Eventbus config

func GetAppConfigFromEnv

func GetAppConfigFromEnv() Config

GetAppConfigFromEnv Read system environment to get config

func (Config) GetURL

func (c Config) GetURL() string

GetURL from config, build connection string

type Header struct {
	Timestamp   time.Time `json:"timestamp" validate:"required"`
	Publisher   string    `json:"publisher" validate:"required"`
	EventName   string    `json:"eventName" validate:"required"`
	TraceId     string    `json:"traceId"`
	UserId      string    `json:"userId"`
	XRetryCount int16     `json:"xRetryCount,omitempty"`
}

func (*Header) FromMap

func (h *Header) FromMap(headers map[string]interface{}) error

func (*Header) ToMap

func (h *Header) ToMap() map[string]interface{}

ToMap return map of string data from header

type Message

type Message struct {
	Id         string
	Exchange   string
	RoutingKey string
	Header     Header
	Payload    Payload `validate:"required,dive"`
	Status     string
	Error      error
}

Message message send to eventbus

type Payload

type Payload struct {
	EntityId string      `json:"entityId"`
	Data     interface{} `json:"data" validate:"required"`
}

Payload message's data

type RetryErrorType

type RetryErrorType interface {
	IsRetryErrorType() bool
	Error() string
}

func NewRetryError

func NewRetryError(err error) RetryErrorType

Jump to

Keyboard shortcuts

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