Documentation
¶
Overview ¶
Package "asyncapi" provides primitives to interact with the AsyncAPI specification.
Code generated by github.com/lerenn/asyncapi-codegen version v0.45.0 DO NOT EDIT.
Package "asyncapi" provides primitives to interact with the AsyncAPI specification.
Code generated by github.com/lerenn/asyncapi-codegen version v0.45.0 DO NOT EDIT.
Package "asyncapi" provides primitives to interact with the AsyncAPI specification.
Code generated by github.com/lerenn/asyncapi-codegen version v0.45.0 DO NOT EDIT.
Index ¶
- Constants
- Variables
- type AppController
- func (c *AppController) Close(ctx context.Context)
- func (c *AppController) ReplyToListOperation(ctx context.Context, recvMsg ListRequestMessage, ...) error
- func (c *AppController) ReplyToServiceInfoOperation(ctx context.Context, recvMsg ServiceInfoRequestMessage, ...) error
- func (c *AppController) SendAsReplyToListOperation(ctx context.Context, chanAddr string, msg ListResponseMessage) error
- func (c *AppController) SendAsReplyToServiceInfoOperation(ctx context.Context, chanAddr string, msg ServiceInfoResponseMessage) error
- func (c *AppController) SubscribeToAllChannels(ctx context.Context, as AppSubscriber) error
- func (c *AppController) SubscribeToListOperation(ctx context.Context, ...) error
- func (c *AppController) SubscribeToServiceInfoOperation(ctx context.Context, ...) error
- func (c *AppController) UnsubscribeFromAllChannels(ctx context.Context)
- func (c *AppController) UnsubscribeFromListOperation(ctx context.Context)
- func (c *AppController) UnsubscribeFromServiceInfoOperation(ctx context.Context)
- type AppSubscriber
- type ControllerOption
- type Error
- type ErrorSchema
- type ExchangeNameSchema
- type ExchangeSchema
- type HeadersFromListRequestMessage
- type HeadersFromListResponseMessage
- type HeadersFromServiceInfoRequestMessage
- type HeadersFromServiceInfoResponseMessage
- type ListRequestMessage
- type ListRequestMessagePayload
- type ListResponseMessage
- func (msg ListResponseMessage) CorrelationID() string
- func (msg *ListResponseMessage) Set(exchanges []exchange.Exchange)
- func (msg *ListResponseMessage) SetAsResponseFrom(req MessageWithCorrelationID)
- func (msg *ListResponseMessage) SetCorrelationID(id string)
- func (msg *ListResponseMessage) ToModel() []exchange.Exchange
- type ListResponseMessagePayload
- type MessageWithCorrelationID
- type PairSchema
- type PeriodSchema
- type ServiceInfoRequestMessage
- type ServiceInfoRequestMessagePayload
- type ServiceInfoResponseMessage
- type ServiceInfoResponseMessagePayload
- type UserController
- func (c *UserController) Close(ctx context.Context)
- func (c *UserController) RequestToListOperation(ctx context.Context, msg ListRequestMessage) (ListResponseMessage, error)
- func (c *UserController) RequestToServiceInfoOperation(ctx context.Context, msg ServiceInfoRequestMessage) (ServiceInfoResponseMessage, error)
- func (c *UserController) SendToListOperation(ctx context.Context, msg ListRequestMessage) error
- func (c *UserController) SendToServiceInfoOperation(ctx context.Context, msg ServiceInfoRequestMessage) error
Constants ¶
const ( // ListRequestChannelPath is the constant representing the 'ListRequestChannel' channel path. ListRequestChannelPath = "cryptellation.exchanges.list" // ListResponseChannelPath is the constant representing the 'ListResponseChannel' channel path. ListResponseChannelPath = "" // ServiceInfoRequestChannelPath is the constant representing the 'ServiceInfoRequestChannel' channel path. ServiceInfoRequestChannelPath = "cryptellation.exchanges.service.info" // ServiceInfoResponseChannelPath is the constant representing the 'ServiceInfoResponseChannel' channel path. ServiceInfoResponseChannelPath = "" )
const AsyncAPIVersion = "1.0.0"
AsyncAPIVersion is the version of the used AsyncAPI document
Variables ¶
var ChannelsPaths = []string{ ListRequestChannelPath, ListResponseChannelPath, ServiceInfoRequestChannelPath, ServiceInfoResponseChannelPath, }
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) ReplyToListOperation ¶
func (c *AppController) ReplyToListOperation(ctx context.Context, recvMsg ListRequestMessage, fn func(replyMsg *ListResponseMessage)) error
ReplyToListOperation is a helper function to reply to a ListRequest message with a ListResponse message on ListResponse channel.
func (*AppController) ReplyToServiceInfoOperation ¶
func (c *AppController) ReplyToServiceInfoOperation(ctx context.Context, recvMsg ServiceInfoRequestMessage, fn func(replyMsg *ServiceInfoResponseMessage)) error
ReplyToServiceInfoOperation is a helper function to reply to a ServiceInfoRequest message with a ServiceInfoResponse message on ServiceInfoResponse channel.
func (*AppController) SendAsReplyToListOperation ¶
func (c *AppController) SendAsReplyToListOperation( ctx context.Context, chanAddr string, msg ListResponseMessage, ) error
SendAsReplyToListOperation will send a ListResponse message on ListResponse 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) SendAsReplyToServiceInfoOperation ¶
func (c *AppController) SendAsReplyToServiceInfoOperation( ctx context.Context, chanAddr string, msg ServiceInfoResponseMessage, ) error
SendAsReplyToServiceInfoOperation will send a ServiceInfoResponse message on ServiceInfoResponse 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) SubscribeToListOperation ¶
func (c *AppController) SubscribeToListOperation( ctx context.Context, fn func(ctx context.Context, msg ListRequestMessage) error, ) error
SubscribeToListOperation will receive ListRequest messages from ListRequest 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) SubscribeToServiceInfoOperation ¶
func (c *AppController) SubscribeToServiceInfoOperation( ctx context.Context, fn func(ctx context.Context, msg ServiceInfoRequestMessage) 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) UnsubscribeFromListOperation ¶
func (c *AppController) UnsubscribeFromListOperation( ctx context.Context, )
UnsubscribeFromListOperation will stop the reception of ListRequest messages from ListRequest channel. A timeout can be set in context to avoid blocking operation, if needed.
func (*AppController) UnsubscribeFromServiceInfoOperation ¶
func (c *AppController) UnsubscribeFromServiceInfoOperation( ctx context.Context, )
UnsubscribeFromServiceInfoOperation will stop the reception of ServiceInfoRequest messages from ServiceInfoRequest channel. A timeout can be set in context to avoid blocking operation, if needed.
type AppSubscriber ¶
type AppSubscriber interface { // ListOperationReceived receive all ListRequest messages from ListRequest channel. ListOperationReceived(ctx context.Context, msg ListRequestMessage) error // ServiceInfoOperationReceived receive all ServiceInfoRequest messages from ServiceInfoRequest channel. ServiceInfoOperationReceived(ctx context.Context, msg ServiceInfoRequestMessage) 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 ErrorSchema ¶
type ErrorSchema struct { // Description: Code to identify the error type, based on HTTP errors Code int64 `json:"code"` // Description: Main error reason Message string `json:"message"` }
ErrorSchema is a schema from the AsyncAPI specification required in messages Description: Response to a failed call
type ExchangeNameSchema ¶
type ExchangeNameSchema string
ExchangeNameSchema is a schema from the AsyncAPI specification required in messages Description: Exchange name
type ExchangeSchema ¶
type ExchangeSchema struct { Fees float64 `json:"fees"` // Description: Last synchronisation time in RFC3339 LastSyncTime time.Time `json:"lastSyncTime"` // Description: Exchange name Name ExchangeNameSchema `json:"name"` Pairs []PairSchema `json:"pairs,omitempty"` Periods []PeriodSchema `json:"periods,omitempty"` }
ExchangeSchema is a schema from the AsyncAPI specification required in messages Description: exchange information
type HeadersFromListRequestMessage ¶
type HeadersFromListRequestMessage struct { // Description: Correlation ID set by client CorrelationId *string `json:"correlationId,omitempty"` // Description: Channel used to respond to request ReplyTo string `json:"replyTo"` }
HeadersFromListRequestMessage is a schema from the AsyncAPI specification required in messages
type HeadersFromListResponseMessage ¶
type HeadersFromListResponseMessage struct { // Description: Correlation ID set by client CorrelationId *string `json:"correlationId,omitempty"` }
HeadersFromListResponseMessage is a schema from the AsyncAPI specification required in messages
type HeadersFromServiceInfoRequestMessage ¶
type HeadersFromServiceInfoRequestMessage struct { // Description: Correlation ID set by client CorrelationId *string `json:"correlationId,omitempty"` // Description: Channel used to respond to request ReplyTo string `json:"replyTo"` }
HeadersFromServiceInfoRequestMessage is a schema from the AsyncAPI specification required in messages
type HeadersFromServiceInfoResponseMessage ¶
type HeadersFromServiceInfoResponseMessage struct { // Description: Correlation ID set by client CorrelationId *string `json:"correlationId,omitempty"` }
HeadersFromServiceInfoResponseMessage is a schema from the AsyncAPI specification required in messages
type ListRequestMessage ¶
type ListRequestMessage struct { // Headers will be used to fill the message headers Headers HeadersFromListRequestMessage // Payload will be inserted in the message payload Payload []ExchangeNameSchema }
ListRequestMessage is the message expected for 'ListRequestMessage' channel.
func NewListRequestMessage ¶
func NewListRequestMessage() ListRequestMessage
func (ListRequestMessage) CorrelationID ¶
func (msg ListRequestMessage) CorrelationID() string
CorrelationID will give the correlation ID of the message, based on AsyncAPI spec
func (*ListRequestMessage) Set ¶
func (msg *ListRequestMessage) Set(names ...string)
func (*ListRequestMessage) SetAsResponseFrom ¶
func (msg *ListRequestMessage) 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 (*ListRequestMessage) SetCorrelationID ¶
func (msg *ListRequestMessage) SetCorrelationID(id string)
SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec
func (*ListRequestMessage) ToModel ¶
func (msg *ListRequestMessage) ToModel() []string
type ListRequestMessagePayload ¶
type ListRequestMessagePayload []ExchangeNameSchema
ListRequestMessagePayload is a schema from the AsyncAPI specification required in messages
type ListResponseMessage ¶
type ListResponseMessage struct { // Headers will be used to fill the message headers Headers HeadersFromListResponseMessage // Payload will be inserted in the message payload Payload ListResponseMessagePayload }
ListResponseMessage is the message expected for 'ListResponseMessage' channel.
func NewListResponseMessage ¶
func NewListResponseMessage() ListResponseMessage
func (ListResponseMessage) CorrelationID ¶
func (msg ListResponseMessage) CorrelationID() string
CorrelationID will give the correlation ID of the message, based on AsyncAPI spec
func (*ListResponseMessage) Set ¶
func (msg *ListResponseMessage) Set(exchanges []exchange.Exchange)
func (*ListResponseMessage) SetAsResponseFrom ¶
func (msg *ListResponseMessage) 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 (*ListResponseMessage) SetCorrelationID ¶
func (msg *ListResponseMessage) SetCorrelationID(id string)
SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec
func (*ListResponseMessage) ToModel ¶
func (msg *ListResponseMessage) ToModel() []exchange.Exchange
type ListResponseMessagePayload ¶
type ListResponseMessagePayload struct { // Description: Response to a failed call Error *ErrorSchema `json:"error,omitempty"` Exchanges []ExchangeSchema `json:"exchanges,omitempty"` }
ListResponseMessagePayload is a schema from the AsyncAPI specification required in messages
type PairSchema ¶
type PairSchema string
PairSchema is a schema from the AsyncAPI specification required in messages Description: Pair symbol
type PeriodSchema ¶
type PeriodSchema string
PeriodSchema is a schema from the AsyncAPI specification required in messages Description: Period symbol
type ServiceInfoRequestMessage ¶
type ServiceInfoRequestMessage struct { // Headers will be used to fill the message headers Headers HeadersFromServiceInfoRequestMessage // Payload will be inserted in the message payload Payload ServiceInfoRequestMessagePayload }
ServiceInfoRequestMessage is the message expected for 'ServiceInfoRequestMessage' channel.
func NewServiceInfoRequestMessage ¶
func NewServiceInfoRequestMessage() ServiceInfoRequestMessage
func (ServiceInfoRequestMessage) CorrelationID ¶
func (msg ServiceInfoRequestMessage) CorrelationID() string
CorrelationID will give the correlation ID of the message, based on AsyncAPI spec
func (*ServiceInfoRequestMessage) SetAsResponseFrom ¶
func (msg *ServiceInfoRequestMessage) 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 (*ServiceInfoRequestMessage) SetCorrelationID ¶
func (msg *ServiceInfoRequestMessage) SetCorrelationID(id string)
SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec
type ServiceInfoRequestMessagePayload ¶
type ServiceInfoRequestMessagePayload struct{}
ServiceInfoRequestMessagePayload is a schema from the AsyncAPI specification required in messages
type ServiceInfoResponseMessage ¶
type ServiceInfoResponseMessage struct { // Headers will be used to fill the message headers Headers HeadersFromServiceInfoResponseMessage // Payload will be inserted in the message payload Payload ServiceInfoResponseMessagePayload }
ServiceInfoResponseMessage is the message expected for 'ServiceInfoResponseMessage' channel.
func NewServiceInfoResponseMessage ¶
func NewServiceInfoResponseMessage() ServiceInfoResponseMessage
func (ServiceInfoResponseMessage) CorrelationID ¶
func (msg ServiceInfoResponseMessage) CorrelationID() string
CorrelationID will give the correlation ID of the message, based on AsyncAPI spec
func (*ServiceInfoResponseMessage) SetAsResponseFrom ¶
func (msg *ServiceInfoResponseMessage) 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 (*ServiceInfoResponseMessage) SetCorrelationID ¶
func (msg *ServiceInfoResponseMessage) SetCorrelationID(id string)
SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec
func (ServiceInfoResponseMessage) ToModel ¶
func (m ServiceInfoResponseMessage) ToModel() client.ServiceInfo
type ServiceInfoResponseMessagePayload ¶
type ServiceInfoResponseMessagePayload struct { // Description: Version of the API ApiVersion string `json:"apiVersion"` // Description: Version of the binary BinVersion string `json:"binVersion"` }
ServiceInfoResponseMessagePayload is a schema from the AsyncAPI specification required in messages
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) RequestToListOperation ¶
func (c *UserController) RequestToListOperation( ctx context.Context, msg ListRequestMessage, ) (ListResponseMessage, error)
func (*UserController) RequestToServiceInfoOperation ¶
func (c *UserController) RequestToServiceInfoOperation( ctx context.Context, msg ServiceInfoRequestMessage, ) (ServiceInfoResponseMessage, error)
func (*UserController) SendToListOperation ¶
func (c *UserController) SendToListOperation( ctx context.Context, msg ListRequestMessage, ) error
SendToListOperation will send a ListRequest message on ListRequest 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) SendToServiceInfoOperation ¶
func (c *UserController) SendToServiceInfoOperation( ctx context.Context, msg ServiceInfoRequestMessage, ) error
SendToServiceInfoOperation will send a ServiceInfoRequest message on ServiceInfoRequest 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.