asyncapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

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

Code generated by github.com/lerenn/asyncapi-codegen version v0.30.2 DO NOT EDIT.

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

Code generated by github.com/lerenn/asyncapi-codegen version v0.30.2 DO NOT EDIT.

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

Code generated by github.com/lerenn/asyncapi-codegen version v0.30.2 DO NOT EDIT.

Index

Constants

View Source
const AsyncAPIVersion = "1.0.0"

AsyncAPIVersion is the version of the used AsyncAPI document

Variables

This section is empty.

Functions

This section is empty.

Types

type AppController

type AppController struct {
	// contains filtered or unexported fields
}

AppController is the structure that provides publishing 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) PublishListCandlesticksResponse

func (c *AppController) PublishListCandlesticksResponse(ctx context.Context, msg ListCandlesticksResponseMessage) error

PublishListCandlesticksResponse will publish messages to 'cryptellation.candlesticks.list.response' channel

func (*AppController) PublishServiceInfoResponse

func (c *AppController) PublishServiceInfoResponse(ctx context.Context, msg ServiceInfoResponseMessage) error

PublishServiceInfoResponse will publish messages to 'cryptellation.candlesticks.service.info.response' channel

func (*AppController) SubscribeAll

func (c *AppController) SubscribeAll(ctx context.Context, as AppSubscriber) error

SubscribeAll will subscribe to channels without parameters on which the app is expecting messages. For channels with parameters, they should be subscribed independently.

func (*AppController) SubscribeListCandlesticksRequest

func (c *AppController) SubscribeListCandlesticksRequest(ctx context.Context, fn func(ctx context.Context, msg ListCandlesticksRequestMessage)) error

SubscribeListCandlesticksRequest will subscribe to new messages from 'cryptellation.candlesticks.list.request' channel.

Callback function 'fn' will be called each time a new message is received.

func (*AppController) SubscribeServiceInfoRequest

func (c *AppController) SubscribeServiceInfoRequest(ctx context.Context, fn func(ctx context.Context, msg ServiceInfoRequestMessage)) error

Callback function 'fn' will be called each time a new message is received.

func (*AppController) UnsubscribeAll

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

UnsubscribeAll will unsubscribe all remaining subscribed channels

func (*AppController) UnsubscribeListCandlesticksRequest

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

UnsubscribeListCandlesticksRequest will unsubscribe messages from 'cryptellation.candlesticks.list.request' channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*AppController) UnsubscribeServiceInfoRequest

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

UnsubscribeServiceInfoRequest will unsubscribe messages from 'cryptellation.candlesticks.service.info.request' channel. A timeout can be set in context to avoid blocking operation, if needed.

type AppSubscriber

type AppSubscriber interface {
	// ListCandlesticksRequest subscribes to messages placed on the 'cryptellation.candlesticks.list.request' channel
	ListCandlesticksRequest(ctx context.Context, msg ListCandlesticksRequestMessage)

	// ServiceInfoRequest subscribes to messages placed on the 'cryptellation.candlesticks.service.info.request' channel
	ServiceInfoRequest(ctx context.Context, msg ServiceInfoRequestMessage)
}

AppSubscriber represents all handlers that are expecting messages for App

type CandlestickListSchema

type CandlestickListSchema []CandlestickSchema

CandlestickListSchema is a schema from the AsyncAPI specification required in messages Description: Requested candlestick list

type CandlestickSchema

type CandlestickSchema struct {
	// Description: Candlestick close price
	Close float64 `json:"close"`

	// Description: Candlestick high price
	High float64 `json:"high"`

	// Description: Candlestick low price
	Low float64 `json:"low"`

	// Description: Candlestick open price
	Open float64 `json:"open"`

	// Description: Candlestick date and time
	Time DateSchema `json:"time"`

	// Description: Candlestick volume
	Volume float64 `json:"volume"`
}

CandlestickSchema is a schema from the AsyncAPI specification required in messages

type ControllerOption

type ControllerOption func(controller *controller)

ControllerOption is the type of the options that can be passed when creating a new Controller

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 DateSchema

type DateSchema time.Time

DateSchema is a schema from the AsyncAPI specification required in messages Description: Date-Time format according to RFC3339

func (DateSchema) MarshalJSON

func (t DateSchema) MarshalJSON() ([]byte, error)

MarshalJSON will override the marshal as this is not a normal 'time.Time' type

func (*DateSchema) UnmarshalJSON

func (t *DateSchema) UnmarshalJSON(data []byte) error

UnmarshalJSON will override the unmarshal as this is not a normal 'time.Time' type

type Error

type Error struct {
	Channel string
	Err     error
}

func (*Error) Error

func (e *Error) Error() string

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 LimitSchema

type LimitSchema int32

LimitSchema is a schema from the AsyncAPI specification required in messages Description: The maximum quantity to retrieve (0 = unlimited)

type ListCandlesticksRequestMessage

type ListCandlesticksRequestMessage struct {
	// Headers will be used to fill the message headers
	Headers struct {
		// Description: Correlation ID set by client
		CorrelationId *string `json:"correlation_id"`
	}

	// Payload will be inserted in the message payload
	Payload struct {
		// Description: Date-time for the newest candlestick (RFC3339)
		End *DateSchema `json:"end"`

		// Description: Requested candlesticks exchange name
		ExchangeName ExchangeNameSchema `json:"exchange_name"`

		// Description: The maximum candlesticks to retrieve (0 = unlimited)
		Limit LimitSchema `json:"limit"`

		// Description: Requested candlesticks pair symbol
		PairSymbol PairSymbolSchema `json:"pair_symbol"`

		// Description: Requested candlesticks period symbol
		PeriodSymbol PeriodSymbolSchema `json:"period_symbol"`

		// Description: Date-time for the oldest candlestick (RFC3339)
		Start *DateSchema `json:"start"`
	}
}

ListCandlesticksRequestMessage is the message expected for 'ListCandlesticksRequest' channel

func NewListCandlesticksRequestMessage

func NewListCandlesticksRequestMessage() ListCandlesticksRequestMessage

func (ListCandlesticksRequestMessage) CorrelationID

func (msg ListCandlesticksRequestMessage) CorrelationID() string

CorrelationID will give the correlation ID of the message, based on AsyncAPI spec

func (*ListCandlesticksRequestMessage) Set

func (*ListCandlesticksRequestMessage) SetAsResponseFrom

func (msg *ListCandlesticksRequestMessage) 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 (*ListCandlesticksRequestMessage) SetCorrelationID

func (msg *ListCandlesticksRequestMessage) SetCorrelationID(id string)

SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec

func (*ListCandlesticksRequestMessage) ToModel

type ListCandlesticksResponseMessage

type ListCandlesticksResponseMessage struct {
	// Headers will be used to fill the message headers
	Headers struct {
		// Description: Correlation ID set by client on corresponding request
		CorrelationId *string `json:"correlation_id"`
	}

	// Payload will be inserted in the message payload
	Payload struct {
		// Description: Requested candlestick list
		Candlesticks *CandlestickListSchema `json:"candlesticks"`

		// Description: Response to a failed call
		Error *ErrorSchema `json:"error"`
	}
}

ListCandlesticksResponseMessage is the message expected for 'ListCandlesticksResponse' channel

func NewListCandlesticksResponseMessage

func NewListCandlesticksResponseMessage() ListCandlesticksResponseMessage

func (ListCandlesticksResponseMessage) CorrelationID

func (msg ListCandlesticksResponseMessage) CorrelationID() string

CorrelationID will give the correlation ID of the message, based on AsyncAPI spec

func (*ListCandlesticksResponseMessage) Set

func (*ListCandlesticksResponseMessage) SetAsResponseFrom

func (msg *ListCandlesticksResponseMessage) 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 (*ListCandlesticksResponseMessage) SetCorrelationID

func (msg *ListCandlesticksResponseMessage) SetCorrelationID(id string)

SetCorrelationID will set the correlation ID of the message, based on AsyncAPI spec

func (*ListCandlesticksResponseMessage) ToModel

func (msg *ListCandlesticksResponseMessage) ToModel(exchange, pair string, symbol period.Symbol) (*candlestick.List, error)

type MessageWithCorrelationID

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

type PairSymbolSchema

type PairSymbolSchema string

PairSymbolSchema is a schema from the AsyncAPI specification required in messages Description: Pair symbol

type PeriodSymbolSchema

type PeriodSymbolSchema string

PeriodSymbolSchema 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 struct {
		// Description: Correlation ID set by client
		CorrelationId *string `json:"correlation_id"`
	}

	// Payload will be inserted in the message payload
	Payload struct{}
}

ServiceInfoRequestMessage is the message expected for 'ServiceInfoRequest' 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 ServiceInfoResponseMessage

type ServiceInfoResponseMessage struct {
	// Headers will be used to fill the message headers
	Headers struct {
		// Description: Correlation ID set by client
		CorrelationId *string `json:"correlation_id"`
	}

	// Payload will be inserted in the message payload
	Payload struct {
		// Description: Version of the API
		ApiVersion string `json:"api_version"`

		// Description: Version of the binary
		BinVersion string `json:"bin_version"`
	}
}

ServiceInfoResponseMessage is the message expected for 'ServiceInfoResponse' 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

type UserController

type UserController struct {
	// contains filtered or unexported fields
}

UserController is the structure that provides publishing 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) PublishListCandlesticksRequest

func (c *UserController) PublishListCandlesticksRequest(ctx context.Context, msg ListCandlesticksRequestMessage) error

PublishListCandlesticksRequest will publish messages to 'cryptellation.candlesticks.list.request' channel

func (*UserController) PublishServiceInfoRequest

func (c *UserController) PublishServiceInfoRequest(ctx context.Context, msg ServiceInfoRequestMessage) error

PublishServiceInfoRequest will publish messages to 'cryptellation.candlesticks.service.info.request' channel

func (*UserController) SubscribeAll

func (c *UserController) SubscribeAll(ctx context.Context, as UserSubscriber) error

SubscribeAll will subscribe to channels without parameters on which the app is expecting messages. For channels with parameters, they should be subscribed independently.

func (*UserController) SubscribeListCandlesticksResponse

func (c *UserController) SubscribeListCandlesticksResponse(ctx context.Context, fn func(ctx context.Context, msg ListCandlesticksResponseMessage)) error

SubscribeListCandlesticksResponse will subscribe to new messages from 'cryptellation.candlesticks.list.response' channel.

Callback function 'fn' will be called each time a new message is received.

func (*UserController) SubscribeServiceInfoResponse

func (c *UserController) SubscribeServiceInfoResponse(ctx context.Context, fn func(ctx context.Context, msg ServiceInfoResponseMessage)) error

Callback function 'fn' will be called each time a new message is received.

func (*UserController) UnsubscribeAll

func (c *UserController) UnsubscribeAll(ctx context.Context)

UnsubscribeAll will unsubscribe all remaining subscribed channels

func (*UserController) UnsubscribeListCandlesticksResponse

func (c *UserController) UnsubscribeListCandlesticksResponse(ctx context.Context)

UnsubscribeListCandlesticksResponse will unsubscribe messages from 'cryptellation.candlesticks.list.response' channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*UserController) UnsubscribeServiceInfoResponse

func (c *UserController) UnsubscribeServiceInfoResponse(ctx context.Context)

UnsubscribeServiceInfoResponse will unsubscribe messages from 'cryptellation.candlesticks.service.info.response' channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*UserController) WaitForListCandlesticksResponse

func (c *UserController) WaitForListCandlesticksResponse(ctx context.Context, publishMsg MessageWithCorrelationID, pub func(ctx context.Context) error) (ListCandlesticksResponseMessage, error)

WaitForListCandlesticksResponse will wait for a specific message by its correlation ID.

The pub function is the publication function that should be used to send the message. It will be called after subscribing to the channel to avoid race condition, and potentially loose the message.

A timeout can be set in context to avoid blocking operation, if needed.

func (*UserController) WaitForServiceInfoResponse

func (c *UserController) WaitForServiceInfoResponse(ctx context.Context, publishMsg MessageWithCorrelationID, pub func(ctx context.Context) error) (ServiceInfoResponseMessage, error)

WaitForServiceInfoResponse will wait for a specific message by its correlation ID.

The pub function is the publication function that should be used to send the message. It will be called after subscribing to the channel to avoid race condition, and potentially loose the message.

A timeout can be set in context to avoid blocking operation, if needed.

type UserSubscriber

type UserSubscriber interface {
	// ListCandlesticksResponse subscribes to messages placed on the 'cryptellation.candlesticks.list.response' channel
	ListCandlesticksResponse(ctx context.Context, msg ListCandlesticksResponseMessage)

	// ServiceInfoResponse subscribes to messages placed on the 'cryptellation.candlesticks.service.info.response' channel
	ServiceInfoResponse(ctx context.Context, msg ServiceInfoResponseMessage)
}

UserSubscriber represents all handlers that are expecting messages for User

Jump to

Keyboard shortcuts

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