Documentation
¶
Overview ¶
Package "requestreply" provides primitives to interact with the AsyncAPI specification.
Code generated by github.com/akmalsyrf/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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
type HeadersFromPingWithIDMessage struct {
// Description: Correlation ID set by user
CorrelationId *string `json:"correlationId,omitempty"`
}
HeadersFromPingWithIDMessage is a schema from the AsyncAPI specification required in messages
type HeadersFromPongWithIDMessage ¶
type HeadersFromPongWithIDMessage struct {
// Description: Correlation ID set by user
CorrelationId *string `json:"correlationId,omitempty"`
}
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 ¶
type PingMessagePayload struct {
Event *string `json:"event,omitempty" validate:"omitempty,eq=ping"`
}
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 ¶
type PingWithIDMessagePayload struct {
Event *string `json:"event,omitempty" validate:"omitempty,eq=ping"`
}
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 ¶
type PongMessagePayload struct {
Event *string `json:"event,omitempty" validate:"omitempty,eq=pong"`
}
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 ¶
type PongWithIDMessagePayload struct {
Event *string `json:"event,omitempty" validate:"omitempty,eq=pong"`
}
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 ¶
func (c *UserController) RequestToPingOperation( ctx context.Context, msg PingMessage, ) (PongMessage, error)
func (*UserController) RequestToPingWithIDOperation ¶
func (c *UserController) RequestToPingWithIDOperation( ctx context.Context, msg PingWithIDMessage, ) (PongWithIDMessage, error)
func (*UserController) SendToPingOperation ¶
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 ¶
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.