ws

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

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

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

Index

Constants

View Source
const AsyncAPIVersion = "0.0.1"

AsyncAPIVersion is the version of the used AsyncAPI document

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionSchema

type ActionSchema struct {
	Action *string `json2:"action-Boy"`
}

ActionSchema is a schema from the AsyncAPI specification required in messages

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

func (c *AppController) PublishDisconnect(ctx context.Context, msg OkMessage) error

PublishDisconnect will publish messages to '/disconnect' 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) SubscribeDisconnect

func (c *AppController) SubscribeDisconnect(ctx context.Context, fn func(ctx context.Context, msg OkMessage)) error

SubscribeDisconnect will subscribe to new messages from '/disconnect' channel.

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

func (*AppController) SubscribeFoo

func (c *AppController) SubscribeFoo(ctx context.Context, fn func(ctx context.Context, msg FooMessage)) 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) UnsubscribeDisconnect

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

UnsubscribeDisconnect will unsubscribe messages from '/disconnect' channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*AppController) UnsubscribeFoo

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

UnsubscribeFoo will unsubscribe messages from '/foo' channel. A timeout can be set in context to avoid blocking operation, if needed.

type AppSubscriber

type AppSubscriber interface {
	// Disconnect subscribes to messages placed on the '/disconnect' channel
	Disconnect(ctx context.Context, msg OkMessage)

	// Foo subscribes to messages placed on the '/foo' channel
	Foo(ctx context.Context, msg FooMessage)
}

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 Error

type Error struct {
	Channel string
	Err     error
}

func (*Error) Error

func (e *Error) Error() string

type FooMessage

type FooMessage struct {
	// Payload will be inserted in the message payload
	Payload struct {
		// Description: Age of the person.
		Age *int64 `json:"age"`

		// Description: Indicates if the person is female.
		Female *bool `json:"female"`

		// Description: Name of the person.
		Name *string `json:"name"`
	}
}

FooMessage is the message expected for 'Foo' channel

func NewFooMessage

func NewFooMessage() FooMessage

type MessageWithCorrelationID

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

type OkMessage

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

OkMessage is the message expected for 'Ok' channel

func NewOkMessage

func NewOkMessage() OkMessage

type PersonSchema

type PersonSchema struct {
	Action             *string `json2:"action-Boy"`
	AdditionalProperty *string `json:"additional_property"`
}

PersonSchema is a schema from the AsyncAPI specification required in messages

type RegistrationSchema

type RegistrationSchema struct {
	CallId *string `json:"call_id"`
}

RegistrationSchema 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 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) PublishDisconnect

func (c *UserController) PublishDisconnect(ctx context.Context, msg OkMessage) error

PublishDisconnect will publish messages to '/disconnect' channel

func (*UserController) PublishFoo

func (c *UserController) PublishFoo(ctx context.Context, msg FooMessage) error

PublishFoo will publish messages to '/foo' 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) SubscribeDisconnect

func (c *UserController) SubscribeDisconnect(ctx context.Context, fn func(ctx context.Context, msg OkMessage)) error

SubscribeDisconnect will subscribe to new messages from '/disconnect' 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) UnsubscribeDisconnect

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

UnsubscribeDisconnect will unsubscribe messages from '/disconnect' channel. A timeout can be set in context to avoid blocking operation, if needed.

type UserSchema

type UserSchema struct {
	Action             *string `json2:"action-Boy"`
	AdditionalProperty *string `json:"additional_property"`
}

UserSchema is a schema from the AsyncAPI specification required in messages

type UserSubscriber

type UserSubscriber interface {
	// Disconnect subscribes to messages placed on the '/disconnect' channel
	Disconnect(ctx context.Context, msg OkMessage)
}

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