Documentation
¶
Overview ¶
Package "requestreply" provides primitives to interact with the AsyncAPI specification.
Code generated by github.com/lerenn/asyncapi-codegen version (devel) DO NOT EDIT.
Index ¶
- Constants
- Variables
- type AppController
- func (c *AppController) Close(ctx context.Context)
- func (c *AppController) ReplyToPingOperation(ctx context.Context, recvMsg PingMessage, fn func(replyMsg *PongMessage)) error
- func (c *AppController) ReplyToPingWithIDOperation(ctx context.Context, recvMsg PingWithIDMessage, ...) error
- func (c *AppController) SendAsReplyToPingOperation(ctx context.Context, msg PongMessage) error
- func (c *AppController) SendAsReplyToPingWithIDOperation(ctx context.Context, msg PongWithIDMessage) error
- func (c *AppController) SubscribeToAllChannels(ctx context.Context, as AppSubscriber) error
- func (c *AppController) SubscribeToPingOperation(ctx context.Context, fn func(ctx context.Context, msg PingMessage) error) error
- func (c *AppController) SubscribeToPingWithIDOperation(ctx context.Context, fn func(ctx context.Context, msg PingWithIDMessage) error) error
- func (c *AppController) UnsubscribeFromAllChannels(ctx context.Context)
- func (c *AppController) UnsubscribeFromPingOperation(ctx context.Context)
- func (c *AppController) UnsubscribeFromPingWithIDOperation(ctx context.Context)
- type AppSubscriber
- type ControllerOption
- type Error
- type HeadersFromPingWithIDMessage
- type HeadersFromPongWithIDMessage
- type MessageWithCorrelationID
- type PingMessage
- type PingMessagePayload
- type PingWithIDMessage
- type PingWithIDMessagePayload
- type PongMessage
- type PongMessagePayload
- type PongWithIDMessage
- type PongWithIDMessagePayload
- type Suite
- type UserController
- func (c *UserController) Close(ctx context.Context)
- func (c *UserController) RequestToPingOperation(ctx context.Context, msg PingMessage) (PongMessage, error)
- func (c *UserController) RequestToPingWithIDOperation(ctx context.Context, msg PingWithIDMessage) (PongWithIDMessage, error)
- func (c *UserController) SendToPingOperation(ctx context.Context, msg PingMessage) error
- func (c *UserController) SendToPingWithIDOperation(ctx context.Context, msg PingWithIDMessage) error
Constants ¶
const ( // PingChannelPath is the constant representing the 'PingChannel' channel path. PingChannelPath = "v3.issue130.ping" // PingWithIDChannelPath is the constant representing the 'PingWithIDChannel' channel path. PingWithIDChannelPath = "v3.issue130.pingWithID" // PongChannelPath is the constant representing the 'PongChannel' channel path. PongChannelPath = "v3.issue130.pong" // PongWithIDChannelPath is the constant representing the 'PongWithIDChannel' channel path. PongWithIDChannelPath = "v3.issue130.pongWithID" )
const AsyncAPIVersion = ""
AsyncAPIVersion is the version of the used AsyncAPI document
Variables ¶
var ChannelsPaths = []string{ PingChannelPath, PingWithIDChannelPath, PongChannelPath, PongWithIDChannelPath, }
ChannelsPaths is an array of all channels paths
Functions ¶
This section is empty.
Types ¶
type AppController ¶
type AppController struct {
// contains filtered or unexported fields
}
AppController is the structure that provides sending capabilities to the developer and and connect the broker with the App
func NewAppController ¶
func NewAppController(bc extensions.BrokerController, options ...ControllerOption) (*AppController, error)
NewAppController links the App to the broker
func (*AppController) Close ¶
func (c *AppController) Close(ctx context.Context)
Close will clean up any existing resources on the controller
func (*AppController) ReplyToPingOperation ¶ added in v0.34.0
func (c *AppController) ReplyToPingOperation(ctx context.Context, recvMsg PingMessage, fn func(replyMsg *PongMessage)) error
ReplyToPingOperation is a helper function to reply to a Ping message with a Pong message on Pong channel.
func (*AppController) ReplyToPingWithIDOperation ¶ added in v0.34.0
func (c *AppController) ReplyToPingWithIDOperation(ctx context.Context, recvMsg PingWithIDMessage, fn func(replyMsg *PongWithIDMessage)) error
ReplyToPingWithIDOperation is a helper function to reply to a PingWithID message with a PongWithID message on PongWithID channel.
func (*AppController) SendAsReplyToPingOperation ¶ added in v0.34.0
func (c *AppController) SendAsReplyToPingOperation( ctx context.Context, msg PongMessage, ) error
SendAsReplyToPingOperation will send a Pong message on Pong channel.
NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.
func (*AppController) SendAsReplyToPingWithIDOperation ¶ added in v0.34.0
func (c *AppController) SendAsReplyToPingWithIDOperation( ctx context.Context, msg PongWithIDMessage, ) error
SendAsReplyToPingWithIDOperation will send a PongWithID message on PongWithID channel.
NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.
func (*AppController) SubscribeToAllChannels ¶
func (c *AppController) SubscribeToAllChannels(ctx context.Context, as AppSubscriber) error
SubscribeToAllChannels will receive messages from channels where channel has no parameter on which the app is expecting messages. For channels with parameters, they should be subscribed independently.
func (*AppController) SubscribeToPingOperation ¶ added in v0.34.0
func (c *AppController) SubscribeToPingOperation( ctx context.Context, fn func(ctx context.Context, msg PingMessage) error, ) error
SubscribeToPingOperation will receive Ping messages from Ping channel.
Callback function 'fn' will be called each time a new message is received.
NOTE: for now, this only support the first message from AsyncAPI list.
NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.
func (*AppController) SubscribeToPingWithIDOperation ¶ added in v0.34.0
func (c *AppController) SubscribeToPingWithIDOperation( ctx context.Context, fn func(ctx context.Context, msg PingWithIDMessage) error, ) error
Callback function 'fn' will be called each time a new message is received.
NOTE: for now, this only support the first message from AsyncAPI list.
NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.
func (*AppController) UnsubscribeFromAllChannels ¶
func (c *AppController) UnsubscribeFromAllChannels(ctx context.Context)
UnsubscribeFromAllChannels will stop the subscription of all remaining subscribed channels
func (*AppController) UnsubscribeFromPingOperation ¶ added in v0.34.0
func (c *AppController) UnsubscribeFromPingOperation( ctx context.Context, )
UnsubscribeFromPingOperation will stop the reception of Ping messages from Ping channel. A timeout can be set in context to avoid blocking operation, if needed.
func (*AppController) UnsubscribeFromPingWithIDOperation ¶ added in v0.34.0
func (c *AppController) UnsubscribeFromPingWithIDOperation( ctx context.Context, )
UnsubscribeFromPingWithIDOperation will stop the reception of PingWithID messages from PingWithID channel. A timeout can be set in context to avoid blocking operation, if needed.
type AppSubscriber ¶
type AppSubscriber interface { // PingOperationReceived receive all Ping messages from Ping channel. PingOperationReceived(ctx context.Context, msg PingMessage) error // PingWithIDOperationReceived receive all PingWithID messages from PingWithID channel. PingWithIDOperationReceived(ctx context.Context, msg PingWithIDMessage) error }
AppSubscriber contains all handlers that are listening messages for App
type ControllerOption ¶
type ControllerOption func(controller *controller)
ControllerOption is the type of the options that can be passed when creating a new Controller
func WithErrorHandler ¶ added in v0.35.0
func WithErrorHandler(handler extensions.ErrorHandler) ControllerOption
WithErrorHandler attaches a errorhandler to handle errors from subscriber functions
func WithLogger ¶
func WithLogger(logger extensions.Logger) ControllerOption
WithLogger attaches a logger to the controller
func WithMiddlewares ¶
func WithMiddlewares(middlewares ...extensions.Middleware) ControllerOption
WithMiddlewares attaches middlewares that will be executed when sending or receiving messages
type HeadersFromPingWithIDMessage ¶ added in v0.38.0
type HeadersFromPingWithIDMessage struct { // Description: Correlation ID set by user CorrelationId *string `json:"correlationId"` }
HeadersFromPingWithIDMessage is a schema from the AsyncAPI specification required in messages
type HeadersFromPongWithIDMessage ¶ added in v0.38.0
type HeadersFromPongWithIDMessage struct { // Description: Correlation ID set by user CorrelationId *string `json:"correlationId"` }
HeadersFromPongWithIDMessage is a schema from the AsyncAPI specification required in messages
type PingMessage ¶
type PingMessage struct { // Payload will be inserted in the message payload Payload PingMessagePayload }
PingMessage is the message expected for 'PingMessage' channel.
func NewPingMessage ¶
func NewPingMessage() PingMessage
type PingMessagePayload ¶ added in v0.35.1
type PingMessagePayload struct {
Event *string `json:"event"`
}
PingMessagePayload is a schema from the AsyncAPI specification required in messages
type PingWithIDMessage ¶
type PingWithIDMessage struct { // Headers will be used to fill the message headers Headers HeadersFromPingWithIDMessage // Payload will be inserted in the message payload Payload PingWithIDMessagePayload }
PingWithIDMessage is the message expected for 'PingWithIDMessage' channel.
func NewPingWithIDMessage ¶
func NewPingWithIDMessage() PingWithIDMessage
func (PingWithIDMessage) CorrelationID ¶
func (msg PingWithIDMessage) CorrelationID() string
CorrelationID will give the correlation ID of the message, based on AsyncAPI spec
func (*PingWithIDMessage) SetAsResponseFrom ¶
func (msg *PingWithIDMessage) SetAsResponseFrom(req MessageWithCorrelationID)
SetAsResponseFrom will correlate the message with the one passed in parameter. It will assign the 'req' message correlation ID to the message correlation ID, both specified in AsyncAPI spec.
func (*PingWithIDMessage) SetCorrelationID ¶
func (msg *PingWithIDMessage) SetCorrelationID(id string)
SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec
type PingWithIDMessagePayload ¶ added in v0.35.1
type PingWithIDMessagePayload struct {
Event *string `json:"event"`
}
PingWithIDMessagePayload is a schema from the AsyncAPI specification required in messages
type PongMessage ¶
type PongMessage struct { // Payload will be inserted in the message payload Payload PongMessagePayload }
PongMessage is the message expected for 'PongMessage' channel.
func NewPongMessage ¶
func NewPongMessage() PongMessage
type PongMessagePayload ¶ added in v0.35.1
type PongMessagePayload struct {
Event *string `json:"event"`
}
PongMessagePayload is a schema from the AsyncAPI specification required in messages
type PongWithIDMessage ¶
type PongWithIDMessage struct { // Headers will be used to fill the message headers Headers HeadersFromPongWithIDMessage // Payload will be inserted in the message payload Payload PongWithIDMessagePayload }
PongWithIDMessage is the message expected for 'PongWithIDMessage' channel.
func NewPongWithIDMessage ¶
func NewPongWithIDMessage() PongWithIDMessage
func (PongWithIDMessage) CorrelationID ¶
func (msg PongWithIDMessage) CorrelationID() string
CorrelationID will give the correlation ID of the message, based on AsyncAPI spec
func (*PongWithIDMessage) SetAsResponseFrom ¶
func (msg *PongWithIDMessage) SetAsResponseFrom(req MessageWithCorrelationID)
SetAsResponseFrom will correlate the message with the one passed in parameter. It will assign the 'req' message correlation ID to the message correlation ID, both specified in AsyncAPI spec.
func (*PongWithIDMessage) SetCorrelationID ¶
func (msg *PongWithIDMessage) SetCorrelationID(id string)
SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec
type PongWithIDMessagePayload ¶ added in v0.35.1
type PongWithIDMessagePayload struct {
Event *string `json:"event"`
}
PongWithIDMessagePayload is a schema from the AsyncAPI specification required in messages
type Suite ¶
func NewSuite ¶
func NewSuite(broker extensions.BrokerController) *Suite
func (*Suite) TearDownTest ¶
func (suite *Suite) TearDownTest()
func (*Suite) TestRequestReply ¶
func (suite *Suite) TestRequestReply()
func (*Suite) TestRequestReplyWithID ¶
func (suite *Suite) TestRequestReplyWithID()
type UserController ¶
type UserController struct {
// contains filtered or unexported fields
}
UserController is the structure that provides sending capabilities to the developer and and connect the broker with the User
func NewUserController ¶
func NewUserController(bc extensions.BrokerController, options ...ControllerOption) (*UserController, error)
NewUserController links the User to the broker
func (*UserController) Close ¶
func (c *UserController) Close(ctx context.Context)
Close will clean up any existing resources on the controller
func (*UserController) RequestToPingOperation ¶ added in v0.34.0
func (c *UserController) RequestToPingOperation( ctx context.Context, msg PingMessage, ) (PongMessage, error)
func (*UserController) RequestToPingWithIDOperation ¶ added in v0.34.0
func (c *UserController) RequestToPingWithIDOperation( ctx context.Context, msg PingWithIDMessage, ) (PongWithIDMessage, error)
func (*UserController) SendToPingOperation ¶ added in v0.34.0
func (c *UserController) SendToPingOperation( ctx context.Context, msg PingMessage, ) error
SendToPingOperation will send a Ping message on Ping channel.
NOTE: this won't wait for reply, use the normal version to get the reply or do the catching reply manually. NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.
func (*UserController) SendToPingWithIDOperation ¶ added in v0.34.0
func (c *UserController) SendToPingWithIDOperation( ctx context.Context, msg PingWithIDMessage, ) error
SendToPingWithIDOperation will send a PingWithID message on PingWithID channel.
NOTE: this won't wait for reply, use the normal version to get the reply or do the catching reply manually. NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.