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: 13 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) PublishGetSMAResponse

func (c *AppController) PublishGetSMAResponse(ctx context.Context, msg GetSMAResponseMessage) error

PublishGetSMAResponse will publish messages to 'cryptellation.indicators.sma.response' channel

func (*AppController) PublishServiceInfoResponse

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

PublishServiceInfoResponse will publish messages to 'cryptellation.indicators.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) SubscribeGetSMARequest

func (c *AppController) SubscribeGetSMARequest(ctx context.Context, fn func(ctx context.Context, msg GetSMARequestMessage)) error

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

SubscribeServiceInfoRequest will subscribe to new messages from 'cryptellation.indicators.service.info.request' channel.

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) UnsubscribeGetSMARequest

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

UnsubscribeGetSMARequest will unsubscribe messages from 'cryptellation.indicators.sma.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.indicators.service.info.request' channel. A timeout can be set in context to avoid blocking operation, if needed.

type AppSubscriber

type AppSubscriber interface {
	// ServiceInfoRequest subscribes to messages placed on the 'cryptellation.indicators.service.info.request' channel
	ServiceInfoRequest(ctx context.Context, msg ServiceInfoRequestMessage)

	// GetSMARequest subscribes to messages placed on the 'cryptellation.indicators.sma.request' channel
	GetSMARequest(ctx context.Context, msg GetSMARequestMessage)
}

AppSubscriber represents all handlers that are expecting 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 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 GetSMARequestMessage

type GetSMARequestMessage 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: Number of periods used
		PeriodNumber NumberOfPeriodsSchema `json:"period_number"`

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

		// Description: Type of price from a candlestick
		PriceType *PriceTypeSchema `json:"price_type"`

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

GetSMARequestMessage is the message expected for 'GetSMARequest' channel

func NewGetSMARequestMessage

func NewGetSMARequestMessage() GetSMARequestMessage

func (GetSMARequestMessage) CorrelationID

func (msg GetSMARequestMessage) CorrelationID() string

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

func (*GetSMARequestMessage) Set

func (msg *GetSMARequestMessage) Set(payload client.SMAPayload)

func (*GetSMARequestMessage) SetAsResponseFrom

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

func (msg *GetSMARequestMessage) SetCorrelationID(id string)

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

func (*GetSMARequestMessage) ToModel

type GetSMAResponseMessage

type GetSMAResponseMessage 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: A list of timed numbers
		Data *NumericTimeSerieSchema `json:"data"`

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

GetSMAResponseMessage is the message expected for 'GetSMAResponse' channel

func NewGetSMAResponseMessage

func NewGetSMAResponseMessage() GetSMAResponseMessage

func (GetSMAResponseMessage) CorrelationID

func (msg GetSMAResponseMessage) CorrelationID() string

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

func (*GetSMAResponseMessage) Set

func (*GetSMAResponseMessage) SetAsResponseFrom

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

func (msg *GetSMAResponseMessage) SetCorrelationID(id string)

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

func (*GetSMAResponseMessage) ToModel

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 MessageWithCorrelationID

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

type NumberOfPeriodsSchema

type NumberOfPeriodsSchema int32

NumberOfPeriodsSchema is a schema from the AsyncAPI specification required in messages Description: Number of periods used

type NumericTimeSerieSchema

type NumericTimeSerieSchema []struct {
	// Description: Date-Time format according to RFC3339
	Time DateSchema `json:"time"`

	// Description: Numerical value
	Value float64 `json:"value"`
}

NumericTimeSerieSchema is a schema from the AsyncAPI specification required in messages Description: A list of timed numbers

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 PriceTypeSchema

type PriceTypeSchema string

PriceTypeSchema is a schema from the AsyncAPI specification required in messages Description: Type of price from a candlestick

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) PublishGetSMARequest

func (c *UserController) PublishGetSMARequest(ctx context.Context, msg GetSMARequestMessage) error

PublishGetSMARequest will publish messages to 'cryptellation.indicators.sma.request' channel

func (*UserController) PublishServiceInfoRequest

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

PublishServiceInfoRequest will publish messages to 'cryptellation.indicators.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) SubscribeGetSMAResponse

func (c *UserController) SubscribeGetSMAResponse(ctx context.Context, fn func(ctx context.Context, msg GetSMAResponseMessage)) error

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

SubscribeServiceInfoResponse will subscribe to new messages from 'cryptellation.indicators.service.info.response' channel.

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) UnsubscribeGetSMAResponse

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

UnsubscribeGetSMAResponse will unsubscribe messages from 'cryptellation.indicators.sma.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.indicators.service.info.response' channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*UserController) WaitForGetSMAResponse

func (c *UserController) WaitForGetSMAResponse(ctx context.Context, publishMsg MessageWithCorrelationID, pub func(ctx context.Context) error) (GetSMAResponseMessage, error)

WaitForGetSMAResponse 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 {
	// ServiceInfoResponse subscribes to messages placed on the 'cryptellation.indicators.service.info.response' channel
	ServiceInfoResponse(ctx context.Context, msg ServiceInfoResponseMessage)

	// GetSMAResponse subscribes to messages placed on the 'cryptellation.indicators.sma.response' channel
	GetSMAResponse(ctx context.Context, msg GetSMAResponseMessage)
}

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