issue145

package
v0.45.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package "issue145" provides primitives to interact with the AsyncAPI specification.

Code generated by github.com/lerenn/asyncapi-codegen version (devel) DO NOT EDIT.

Index

Constants

View Source
const (
	// PingChannelPath is the constant representing the 'PingChannel' channel path.
	PingChannelPath = "v3.issue145.ping"
	// PongChannelPath is the constant representing the 'PongChannel' channel path.
	PongChannelPath = ""
)
View Source
const AsyncAPIVersion = "1.0.0"

AsyncAPIVersion is the version of the used AsyncAPI document

Variables

View Source
var ChannelsPaths = []string{
	PingChannelPath,
	PongChannelPath,
}

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) ReplyToPingRequestOperation added in v0.34.0

func (c *AppController) ReplyToPingRequestOperation(ctx context.Context, recvMsg PingMessage, fn func(replyMsg *PongMessage)) error

ReplyToPingRequestOperation is a helper function to reply to a Ping message with a Pong message on Pong channel.

func (*AppController) SendAsReplyToPingRequestOperation added in v0.34.0

func (c *AppController) SendAsReplyToPingRequestOperation(
	ctx context.Context,
	chanAddr string,
	msg PongMessage,
) error

SendAsReplyToPingRequestOperation 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) 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) SubscribeToPingRequestOperation added in v0.34.0

func (c *AppController) SubscribeToPingRequestOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg PingMessage) error,
) error

SubscribeToPingRequestOperation 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) UnsubscribeFromAllChannels

func (c *AppController) UnsubscribeFromAllChannels(ctx context.Context)

UnsubscribeFromAllChannels will stop the subscription of all remaining subscribed channels

func (*AppController) UnsubscribeFromPingRequestOperation added in v0.34.0

func (c *AppController) UnsubscribeFromPingRequestOperation(
	ctx context.Context,
)

UnsubscribeFromPingRequestOperation will stop the reception of Ping messages from Ping channel. A timeout can be set in context to avoid blocking operation, if needed.

type AppSubscriber

type AppSubscriber interface {
	// PingRequestOperationReceived receive all Ping messages from Ping channel.
	PingRequestOperationReceived(ctx context.Context, msg PingMessage) 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 Error

type Error struct {
	Channel string
	Err     error
}

func (*Error) Error

func (e *Error) Error() string

type HeadersFromPingMessage added in v0.38.0

type HeadersFromPingMessage struct {
	// Description: Provide path to which reply must be provided
	ReplyTo *string `json:"replyTo,omitempty"`

	// Description: Provide request id that you will use to identify the reply match
	RequestId *string `json:"requestId,omitempty"`
}

HeadersFromPingMessage is a schema from the AsyncAPI specification required in messages

type HeadersFromPongMessage added in v0.38.0

type HeadersFromPongMessage struct {
	// Description: Reply message must contain id of the request message
	RequestId *string `json:"requestId,omitempty"`
}

HeadersFromPongMessage is a schema from the AsyncAPI specification required in messages

type MessageWithCorrelationID

type MessageWithCorrelationID interface {
	CorrelationID() string
	SetCorrelationID(id string)
}

type PingMessage

type PingMessage struct {
	// Headers will be used to fill the message headers
	Headers HeadersFromPingMessage

	// 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,omitempty" validate:"omitempty,eq=ping"`
}

PingMessagePayload is a schema from the AsyncAPI specification required in messages

type PongMessage

type PongMessage struct {
	// Headers will be used to fill the message headers
	Headers HeadersFromPongMessage

	// 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,omitempty" validate:"omitempty,eq=pong"`
}

PongMessagePayload 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) RequestToPingRequestOperation added in v0.34.0

func (c *UserController) RequestToPingRequestOperation(
	ctx context.Context,
	msg PingMessage,
) (PongMessage, error)

func (*UserController) SendToPingRequestOperation added in v0.34.0

func (c *UserController) SendToPingRequestOperation(
	ctx context.Context,
	msg PingMessage,
) error

SendToPingRequestOperation 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.

Jump to

Keyboard shortcuts

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