events

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePublishMessageFromEventAndPayload

func CreatePublishMessageFromEventAndPayload(event Event, payload []byte) mqenv.MQPublishMessage

CreatePublishMessageFromEventAndPayload creates

Types

type AbstractEvent

type AbstractEvent struct {
	Identifier       string            `json:"id"`
	Status           int               `json:"code"`
	Description      string            `json:"message"`
	Category         string            `json:"category"`
	From             string            `json:"from"`
	AppID            string            `json:"appId"`
	UserID           string            `json:"userId"`
	TimestampMilis   int64             `json:"timestamp"`
	ExpiresMilis     int64             `json:"expires"`
	ShouldRetryTimes int               `json:"retry"`
	RetriedTimes     int               `json:"retried"`
	ReplyTo          string            `json:"replyTo"`
	CorrelationID    string            `json:"correlationId"`
	Headers          map[string]string `json:"headers,omitempty"`
	Payload          interface{}       `json:"payload,omitempty"`
	OriginBody       []byte            `json:"originBody,omitempty"`
	ProcessResult    interface{}       `json:"processResponse,omitempty"`
}

AbstractEvent abstract implement of event

func (*AbstractEvent) ContentType

func (e *AbstractEvent) ContentType() string

CongentType of serializing content

func (*AbstractEvent) GetAppID

func (e *AbstractEvent) GetAppID() string

GetAppID the application id where event comes from

func (*AbstractEvent) GetCategory

func (e *AbstractEvent) GetCategory() string

GetCategory events category

func (*AbstractEvent) GetCorrelationID

func (e *AbstractEvent) GetCorrelationID() string

GetCorrelationID unique message identifier generated by producer from reply to

func (*AbstractEvent) GetDescription

func (e *AbstractEvent) GetDescription() string

GetDescription events result message

func (*AbstractEvent) GetExpirationMilis

func (e *AbstractEvent) GetExpirationMilis() int64

GetExpirationMilis the timestamp(as mili-second) that the event would expired, the event would be considered as no-expires if expiration is 0

func (*AbstractEvent) GetFrom

func (e *AbstractEvent) GetFrom() string

GetFrom the microservice or system where event comes from

func (*AbstractEvent) GetHeaders

func (e *AbstractEvent) GetHeaders() map[string]string

GetHeaders key-value headers

func (*AbstractEvent) GetIdentifier

func (e *AbstractEvent) GetIdentifier() string

GetIdentifier events identifier

func (*AbstractEvent) GetOriginBody

func (e *AbstractEvent) GetOriginBody() []byte

GetOriginBody events origin request data

func (*AbstractEvent) GetPayload

func (e *AbstractEvent) GetPayload() interface{}

GetPayload events payload data

func (*AbstractEvent) GetProcessResult

func (e *AbstractEvent) GetProcessResult() interface{}

GetProcessResult events payload data

func (*AbstractEvent) GetReplyTo

func (e *AbstractEvent) GetReplyTo() string

GetReplyTo if specified, the consumer should reply the process result to the topic of queue that the field specified

func (*AbstractEvent) GetRetriedTimes

func (e *AbstractEvent) GetRetriedTimes() int

GetRetriedTimes the retry times that the event already retried

func (*AbstractEvent) GetSerializationType

func (e *AbstractEvent) GetSerializationType() SerializationType

GetSerializationType for serializing

func (*AbstractEvent) GetShouldRetryTimes

func (e *AbstractEvent) GetShouldRetryTimes() int

GetShouldRetryTimes how many times that the event should be retried

func (*AbstractEvent) GetStatus

func (e *AbstractEvent) GetStatus() int

GetStatus events status code

func (*AbstractEvent) GetTimestampMilis

func (e *AbstractEvent) GetTimestampMilis() int64

GetTimestampMilis the timestamp(as mili-second) that the event created

func (*AbstractEvent) GetUserID

func (e *AbstractEvent) GetUserID() string

GetUserID the user id where event comes from

func (*AbstractEvent) Initialize

func (e *AbstractEvent) Initialize(category, from string, expireDurationAsSeconds int64, payload interface{}) bool

Initialize members

func (*AbstractEvent) IsExpired

func (e *AbstractEvent) IsExpired() bool

IsExpired if the event were expired

func (*AbstractEvent) OnRetry

func (e *AbstractEvent) OnRetry()

OnRetry triggers that the event were retried

func (*AbstractEvent) ParseFrom

func (e *AbstractEvent) ParseFrom(body []byte) error

ParseFrom parses the body buffer and filles to event data

func (*AbstractEvent) Serialize

func (e *AbstractEvent) Serialize() ([]byte, error)

Serialize serializes the event

func (*AbstractEvent) SetAppID

func (e *AbstractEvent) SetAppID(appID string)

SetAppID the application id where event comes from

func (*AbstractEvent) SetCategory

func (e *AbstractEvent) SetCategory(category string)

SetCategory events category

func (*AbstractEvent) SetCorrelationID

func (e *AbstractEvent) SetCorrelationID(correlationID string)

SetCorrelationID unique message identifier generated by producer from reply to

func (*AbstractEvent) SetDescription

func (e *AbstractEvent) SetDescription(message string)

SetDescription events result message

func (*AbstractEvent) SetExpirationMilis

func (e *AbstractEvent) SetExpirationMilis(expiresMilis int64)

SetExpirationMilis the timestamp(as mili-second) that the event would expired, the event would be considered as no-expires if expiration is 0

func (*AbstractEvent) SetFrom

func (e *AbstractEvent) SetFrom(from string)

SetFrom the microservice or system where event comes from

func (*AbstractEvent) SetHeader

func (e *AbstractEvent) SetHeader(name string, value string)

SetHeader with name and value

func (*AbstractEvent) SetIdentifier

func (e *AbstractEvent) SetIdentifier(identifier string)

SetIdentifier events identifier

func (*AbstractEvent) SetOriginBody

func (e *AbstractEvent) SetOriginBody(originBody []byte)

SetOriginBody events origin request data

func (*AbstractEvent) SetPayload

func (e *AbstractEvent) SetPayload(paylaod interface{})

SetPayload events payload data

func (*AbstractEvent) SetProcessResult

func (e *AbstractEvent) SetProcessResult(paylaod interface{})

SetProcessResult events payload data

func (*AbstractEvent) SetReplyTo

func (e *AbstractEvent) SetReplyTo(replyTo string)

SetReplyTo the consumer should reply the process result to the topic of queue

func (*AbstractEvent) SetShouldRetryTimes

func (e *AbstractEvent) SetShouldRetryTimes(retries int)

SetShouldRetryTimes how many times that the event should be retried

func (*AbstractEvent) SetStatus

func (e *AbstractEvent) SetStatus(status int)

SetStatus events status code

func (*AbstractEvent) SetTimestampMilis

func (e *AbstractEvent) SetTimestampMilis(timestampMilis int64)

SetTimestampMilis the timestamp(as mili-second) that the event created

func (*AbstractEvent) SetUserID

func (e *AbstractEvent) SetUserID(userID string)

SetUserID the user id where event comes from

type Event

type Event interface {
	Initialize(category string, from string, expireDurationAsSeconds int64, payload interface{}) bool
	GetIdentifier() string
	SetIdentifier(string)
	GetStatus() int
	SetStatus(int)
	GetDescription() string
	SetDescription(string)
	GetCategory() string
	SetCategory(string)
	GetFrom() string
	SetFrom(string)
	GetAppID() string
	SetAppID(string)
	GetUserID() string
	SetUserID(string)
	GetReplyTo() string
	SetReplyTo(replyTo string)
	GetCorrelationID() string
	SetCorrelationID(string)
	GetTimestampMilis() int64
	SetTimestampMilis(timestampMilis int64)
	GetExpirationMilis() int64
	SetExpirationMilis(expiresMilis int64)
	IsExpired() bool
	GetShouldRetryTimes() int
	SetShouldRetryTimes(retries int)
	GetRetriedTimes() int
	OnRetry()
	GetHeaders() map[string]string
	SetHeader(name string, value string)
	GetPayload() interface{}
	SetPayload(payload interface{})
	GetOriginBody() []byte
	SetOriginBody([]byte)
	GetProcessResult() interface{}
	SetProcessResult(interface{})
	GetSerializationType() SerializationType
	ContentType() string
	Serialize() ([]byte, error)
	ParseFrom([]byte) error
	Clone() Event
}

Event base event interface

func CreateEventFromConsumerMessage

func CreateEventFromConsumerMessage(category string, handleName string, msg mqenv.MQConsumerMessage) Event

CreateEventFromConsumerMessage generates filter event by consumer message

func CreateEventFromConsumerMessageAndPayload

func CreateEventFromConsumerMessageAndPayload(category string, handleName string, msg mqenv.MQConsumerMessage, payloadObject interface{}) Event

CreateEventFromConsumerMessageAndPayload generates filter event by consumer message and payload object

type SerializationType

type SerializationType int

SerializationType for event

const (
	EventSerializationProtobuf SerializationType = iota
	EventSerializationJSON
)

Constants

Jump to

Keyboard shortcuts

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