micro

package
v1.1.3 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 *Context, subject 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
	Context() *Context
}

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 Context added in v1.1.3

type Context struct {
	context.Context
	NatsClient  *NatsClient
	NatsSubject string
}

func EmptyContext added in v1.1.3

func EmptyContext() *Context

func NewContext added in v1.1.3

func NewContext(natsClient *NatsClient, baseSub string) *Context

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 Module added in v1.1.2

type Module[T any] interface {
	network.BaseModule[T]
	Controllers() []Controller
}

type NatsClient

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

func NewNatsClient

func NewNatsClient(config *Config) *NatsClient

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