rpc

package module
v6.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 17 Imported by: 0

README

Documentation

Index

Constants

View Source
const PluginName = "rpc"

PluginName contains default plugin name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Listen - address string (tcp://host:port or unix://file.sock).
	Listen string `mapstructure:"listen"`
	// RequestTimeout caps the read phases of an RPC request (header + body
	// reads). Handler execution itself is bounded per-call by the request's
	// context deadline. Streaming RPCs are not bounded by this value.
	RequestTimeout time.Duration `mapstructure:"request_timeout"`
	// TLS material; when set, both Cert and Key are required.
	TLS *TLS `mapstructure:"tls"`
}

Config defines RPC service config.

func (*Config) Dialer

func (c *Config) Dialer() (net.Conn, error)

Dialer creates rpc socket Dialer.

func (*Config) InitDefaults

func (c *Config) InitDefaults()

InitDefaults allows init blank config with a pre-defined set of default values.

func (*Config) Listener

func (c *Config) Listener() (net.Listener, error)

Listener creates new rpc socket Listener.

func (*Config) Valid

func (c *Config) Valid() error

Valid returns nil if config is valid.

type Configurer

type Configurer interface {
	// RRVersion returns current RR version
	RRVersion() string
	// Unmarshal returns the whole configuration
	Unmarshal(out any) error
	// UnmarshalKey takes a single key and unmarshal it into a Struct.
	UnmarshalKey(name string, out any) error
	// Has checks if config section exists.
	Has(name string) bool
}

type Logger

type Logger interface {
	NamedLogger(name string) *slog.Logger
}

type Plugin

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

Plugin is an RPC service.

func (*Plugin) Collects

func (s *Plugin) Collects() []*dep.In

Collects all plugins which implement Name + RPCer interfaces

func (*Plugin) Init

func (s *Plugin) Init(cfg Configurer, log Logger) error

Init rpc service. Must return true if service is enabled.

func (*Plugin) Name

func (s *Plugin) Name() string

Name contains service name.

func (*Plugin) RPC

func (s *Plugin) RPC() (string, http.Handler)

RPC exposes the rpc plugin's own API surface (Config, Version) so it is served alongside collected plugins.

func (*Plugin) Serve

func (s *Plugin) Serve() chan error

Serve serves the service.

func (*Plugin) Stop

func (s *Plugin) Stop(ctx context.Context) error

Stop stops the service.

func (*Plugin) Weight

func (s *Plugin) Weight() uint

type RPCer

type RPCer interface {
	// Name of the plugin.
	Name() string
	// RPC returns the URL prefix and HTTP handler this plugin wants mounted on
	// the rpc server's mux.
	RPC() (string, http.Handler)
}

RPCer declares the ability to expose a Connect-RPC service. Implementations typically delegate to a generated connect.NewXxxServiceHandler(impl).

type TLS

type TLS struct {
	Cert string `mapstructure:"cert"`
	Key  string `mapstructure:"key"`
}

TLS holds optional TLS material for the rpc listener.

Jump to

Keyboard shortcuts

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