discovery

package
v0.0.0-...-0174093 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const RequestsTopic = "discovery:request"
View Source
const ResponsesTopic = "discovery:response"

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

type Hub interface {
	Register(ctx context.Context, info ServiceInfo) error
	Load(ctx context.Context) ([]ServiceInfo, error)
}

type Middleware

type Middleware[Service service.Service] struct {
	InfoProvider  func(ctx context.Context, srvc Service) (map[string]any, error)
	Events        *event.Broker
	RequestCodec  codec.Codec[Request, []byte]
	ResponseCodec codec.Codec[Response, []byte]
}

func WithStaticInfo

func WithStaticInfo[Service service.Service](
	info map[string]any,
	events *event.Broker,
	requestCodec codec.Codec[Request, []byte],
	responseCodec codec.Codec[Response, []byte],
) Middleware[Service]

func (Middleware[Service]) BeforeRun

func (m Middleware[Service]) BeforeRun(ctx context.Context, g *errgroup.Group, service service.Service)

type Poller

type Poller struct {
	Hub           Hub
	Events        *event.Broker
	RequestCodec  codec.Codec[Request, []byte]
	ResponseCodec codec.Codec[Response, []byte]
	Interval      time.Duration

	service.Core
}

func (*Poller) Run

func (poller *Poller) Run(ctx context.Context) error

type Request

type Request struct {
	ID string
}

type Responder

type Responder[Service service.Service] struct {
	Service       Service
	InfoProvider  func(ctx context.Context, srvc Service) (map[string]any, error)
	Events        *event.Broker
	RequestCodec  codec.Codec[Request, []byte]
	ResponseCodec codec.Codec[Response, []byte]
}

func (*Responder[Service]) Run

func (responder *Responder[Service]) Run(ctx context.Context) error

type Response

type Response struct {
	RequestID   string
	ServiceInfo ServiceInfo
}

type ServiceInfo

type ServiceInfo struct {
	ID     string
	Name   string
	Info   map[string]any
	Status map[string]any
}

Jump to

Keyboard shortcuts

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