Documentation ¶
Index ¶
- Constants
- func EmptyResponse(messageContext messageContext, requestContext context.Context) (bytes []byte, e error)
- func NBBBuildResponse(messageContext messageContext, requestContext context.Context) ([]byte, error)
- func NBBTransformMessage(messageContext messageContext, requestContext context.Context, ...) ([]byte, error)
- func NoTransformation(messageContext messageContext, requestContext context.Context, ...) (bytes []byte, e error)
- type BuildResponseFunc
- type CloseConnectionFunc
- type CommandResult
- type Config
- type EndpointConfig
- type Message
- type Option
- type TransformMessageFunc
Constants ¶
const ( CorrelationIdKey = "nbb-correlationId" MessageIdKey = "nbb-messageId" PublishTimeKey = "nbb-publishTime" SourceKey = "nbb-source" CommandIdKey = "CommandId" UserIdKey = "UserId" CharismaUserIdKey = "CharismaUserId" MetadataKey = "Metadata" CreationDateKey = "CreationDate" UserIdClaimKey = "sub" CharismaIdClaimKey = "charisma_user_id" )
Variables ¶
This section is empty.
Functions ¶
func EmptyResponse ¶ added in v1.1.1
func EmptyResponse(messageContext messageContext, requestContext context.Context) (bytes []byte, e error)
EmptyResponse returns a empty byte[]
func NBBBuildResponse ¶ added in v1.1.1
func NBBBuildResponse(messageContext messageContext, requestContext context.Context) ([]byte, error)
BuildResponse builds the response that is returned by the Gateway after publishing a message
func NBBTransformMessage ¶ added in v1.1.1
func NBBTransformMessage(messageContext messageContext, requestContext context.Context, payloadBytes []byte) ([]byte, error)
TransformMessage transforms a message received in the HTTP request to a format required by the NBB infrastructure. It envelopes the message adding the required metadata such as UserId, CorrelationId, MessageId, PublishTime, Source, etc.
Types ¶
type BuildResponseFunc ¶
type BuildResponseFunc func(messageContext messageContext, requestContext context.Context) ([]byte, error)
BuildResponseFunc builds the response that is returned by the Gateway after publishing a message The returned data will be written to the HTTP response
type CloseConnectionFunc ¶
type CloseConnectionFunc func() error
CloseConnectionFunc is to be called to close the NATS connection
func NewNatsPublisher ¶
NewNatsPublisher creates an instance of the NATS publisher handler. It transforms the received HTTP request using the transformMessageFunc into a message, publishes the message to NATS and returns the http response built using buildResponseFunc
type CommandResult ¶
type CommandResult struct { CommandId uuid.UUID CorrelationId uuid.UUID }
CommandResult is the structure to be returned in the HTTP response
type Config ¶
type Config struct { NatsUrl string `mapstructure:"nats_url"` Cluster string `mapstructure:"cluster"` ClientId string `mapstructure:"client_id"` QGroup string `mapstructure:"q_group"` DurableName string `mapstructure:"durable_name"` TopicPrefix string `mapstructure:"topic_prefix"` Source string `mapstructure:"source"` // contains filtered or unexported fields }
Config is the global NATS configuration
type EndpointConfig ¶
type EndpointConfig struct {
Topic string `mapstructure:"topic"`
}
EndpointConfig is the NATS specific configuration of the endpoint
type Option ¶ added in v1.1.1
func BuildResponse ¶
func BuildResponse(f BuildResponseFunc) Option
BuildResponse adds a BuildResponseFunc to config
func TransformMessage ¶
func TransformMessage(f TransformMessageFunc) Option
TransformMessage adds a TransformMessageFunc to config
type TransformMessageFunc ¶
type TransformMessageFunc func(messageContext messageContext, requestContext context.Context, payloadBytes []byte) ([]byte, error)
TransformMessageFunc transforms a message received in the HTTP request to a format required by the NBB infrastructure. It envelopes the message adding the required metadata such as UserId, CorrelationId, MessageId, PublishTime, Source, etc.