micro

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Request

func Request[T any, V any](ctx *NatsContext, sub string, send *T, receive *V) (*V, error)

func Respond

func Respond[T any](req NatsRequest, data *T, err error)

Types

type BaseController

type BaseController interface {
	network.BaseController
	SetNatsContext(ctx *NatsContext)
	NatsContext() *NatsContext
}

func NewBaseController

func NewBaseController(basePath string, authProvider network.AuthenticationProvider, authorizeProvider network.AuthorizationProvider) BaseController

type Config

type Config struct {
	NatsUrl            string
	NatsServiceName    string
	NatsServiceVersion string
}

type Controller

type Controller interface {
	BaseController
	MountNats(group NatsGroup)
}

type Message

type Message[T any] struct {
	Data  *T      `json:"data,omitempty"`
	Error *string `json:"error,omitempty"`
}

func NewMessage

func NewMessage[T any](data *T, err error) *Message[T]

type NatsClient

type NatsClient struct {
	Conn    *nats.Conn
	Service micro.Service
	Timeout time.Duration
}

func NewNatsClient

func NewNatsClient(config Config) *NatsClient

type NatsContext

type NatsContext struct {
	context.Context
	Client  *NatsClient
	Subject string
}

func NewNatsContext

func NewNatsContext(client *NatsClient, baseSub string) *NatsContext

type NatsGroup

type NatsGroup = micro.Group

type NatsHandlerFunc

type NatsHandlerFunc = micro.HandlerFunc

type NatsRequest

type NatsRequest = micro.Request

type Router

type Router interface {
	network.BaseRouter
	NatsClient() *NatsClient
	Disconnect()
	LoadControllers(controllers []Controller)
}

func NewRouter

func NewRouter(mode string, config Config) Router

Jump to

Keyboard shortcuts

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