cluster

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorConnection = "ERROR_CONNECTION"
	ConfigError     = "ERROR_CONFIG"

	ConfigSendConfigWhenConnected = "CONFIG:SEND_CONFIG_WHEN_CONNECTED"
	ConfigSendConfigChanged       = "CONFIG:SEND_CONFIG_CHANGED"

	ConfigSendRoutesWhenConnected = "CONFIG:SEND_ROUTES_WHEN_CONNECTED"
	ConfigSendRoutesChanged       = "CONFIG:SEND_ROUTES_CHANGED"

	ModuleReady            = "MODULE:READY"
	ModuleSendRequirements = "MODULE:SEND_REQUIREMENTS"
	ModuleSendConfigSchema = "MODULE:SEND_CONFIG_SCHEMA"

	ModuleConnectionSuffix = "MODULE_CONNECTED"
)
View Source
const (
	RequiredAdminPermission = "reqAdminPerm"
)

Variables

This section is empty.

Functions

func GetRequiredAdminPermission

func GetRequiredAdminPermission(desc EndpointDescriptor) (string, bool)

func HideSecrets

func HideSecrets(data []byte) ([]byte, error)

func ModuleConnectedEvent

func ModuleConnectedEvent(moduleName string) string

func RequireAdminPermission

func RequireAdminPermission(perm string) map[string]any

Types

type AddressConfiguration

type AddressConfiguration struct {
	IP   string `json:"ip"`
	Port string `json:"port"`
}

type BackendDeclaration

type BackendDeclaration struct {
	ModuleName      string
	Version         string
	LibVersion      string
	Endpoints       []EndpointDescriptor
	RequiredModules []ModuleDependency
	Address         AddressConfiguration
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(moduleInfo ModuleInfo, configData ConfigData, hosts []string, logger log.Logger) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Healthcheck

func (c *Client) Healthcheck(ctx context.Context) error

func (*Client) Run

func (c *Client) Run(ctx context.Context, eventHandler *EventHandler) error

type ConfigData

type ConfigData struct {
	Version string
	Schema  json.RawMessage
	Config  json.RawMessage
}

type EndpointDescriptor

type EndpointDescriptor struct {
	Path             string
	Inner            bool
	UserAuthRequired bool
	Extra            map[string]any
	Handler          any `json:"-"`
}

type EventHandler

type EventHandler struct {
	// contains filtered or unexported fields
}

func NewEventHandler

func NewEventHandler() *EventHandler

func (*EventHandler) RemoteConfigReceiver

func (h *EventHandler) RemoteConfigReceiver(receiver RemoteConfigReceiver) *EventHandler

func (*EventHandler) RemoteConfigReceiverWithTimeout

func (h *EventHandler) RemoteConfigReceiverWithTimeout(receiver RemoteConfigReceiver, timeout time.Duration) *EventHandler

func (*EventHandler) RequireModule

func (h *EventHandler) RequireModule(moduleName string, upgrader HostsUpgrader) *EventHandler

func (*EventHandler) RoutesReceiver

func (h *EventHandler) RoutesReceiver(receiver RoutesReceiver) *EventHandler

type Handshake

type Handshake struct {
	// contains filtered or unexported fields
}

func NewHandshake

func NewHandshake(
	moduleInfo ModuleInfo,
	configData ConfigData,
	requirements ModuleRequirements,
	confirmer HandshakeConfirmer,
	logger log.Logger,
) *Handshake

func (Handshake) Do

func (h Handshake) Do(ctx context.Context, host string) (w *clientWrapper, err error)

type HandshakeConfirmer

type HandshakeConfirmer interface {
	// contains filtered or unexported methods
}

type HandshakeData

type HandshakeData struct {
	// contains filtered or unexported fields
}

type HostsUpgrader

type HostsUpgrader interface {
	Upgrade(hosts []string)
}

type ModuleDependency

type ModuleDependency struct {
	Name     string
	Required bool
}

type ModuleInfo

type ModuleInfo struct {
	ModuleName       string
	ModuleVersion    string
	LibVersion       string
	GrpcOuterAddress AddressConfiguration
	Endpoints        []EndpointDescriptor
}

type ModuleRequirements

type ModuleRequirements struct {
	RequiredModules []string
	RequireRoutes   bool
}

type RemoteConfigReceiver

type RemoteConfigReceiver interface {
	ReceiveConfig(ctx context.Context, remoteConfig []byte) error
}

type RoutesReceiver

type RoutesReceiver interface {
	ReceiveRoutes(ctx context.Context, routes RoutingConfig) error
}

type RoutingConfig

type RoutingConfig []BackendDeclaration

Jump to

Keyboard shortcuts

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