Documentation ¶
Overview ¶
Package grpc implements the GRPC netListener through which plugins can expose their services/API to the outside world.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of Plugin.
Functions ¶
func DeclareGRPCPortFlag ¶
func DeclareGRPCPortFlag(pluginName infra.PluginName)
DeclareGRPCPortFlag declares GRPC port (with usage & default value) a flag for a particular plugin name
Types ¶
type Authenticator ¶
Authenticator exposes a function for authenticating requests.
func (Authenticator) Authenticate ¶
Authenticate checks that a token exists and is valid. It stores the user metadata in the returned context and removes the token from the context.
type Config ¶
type Config struct { // Endpoint is an address of GRPC netListener Endpoint string `json:"endpoint"` // Three or four-digit permission setup for unix domain socket file (if used) Permission int `json:"permission"` // If set and unix type network is used, the existing socket file will be always removed and re-created ForceSocketRemoval bool `json:"force-socket-removal"` // Network defaults to "tcp" if unset, and can be set to one of the following values: // "tcp", "tcp4", "tcp6", "unix", "unixpacket" or any other value accepted by net.Listen Network string `json:"network"` // MaxMsgSize returns a ServerOption to set the max message size in bytes for inbound mesages. // If this is not set, gRPC uses the default 4MB. MaxMsgSize int `json:"max-msg-size"` // MaxConcurrentStreams returns a ServerOption that will apply a limit on the number // of concurrent streams to each ServerTransport. MaxConcurrentStreams uint32 `json:"max-concurrent-streams"` }
Config is a configuration for GRPC netListener It is meant to be extended with security (TLS...)
type Deps ¶
type Deps struct { infra.PluginDeps HTTP rest.HTTPHandlers }
Deps is a list of injected dependencies of the GRPC plugin.
type Option ¶ added in v1.5.0
type Option func(*Plugin)
Option is a function that can be used in NewPlugin to customize Plugin.
func UseHTTP ¶ added in v1.5.0
func UseHTTP(h rest.HTTPHandlers) Option
UseHTTP returns Option that sets HTTP handlers.
type Plugin ¶
Plugin maintains the GRPC netListener (see Init, AfterInit, Close methods)
func (*Plugin) IsDisabled ¶ added in v1.3.0
IsDisabled returns *true* if the plugin is not in use due to missing grpc configuration.
type Server ¶
type Server interface { // Server is a getter for accessing grpc.Server (of a GRPC plugin) // // Example usage: // // protocgenerated.RegisterServiceXY(plugin.Deps.GRPC.Server(), &ServiceXYImplP{}) // // type Deps struct { // GRPC grps.Server // inject plugin implementing RegisterHandler // // other dependencies ... // } GetServer() *grpc.Server // Disabled informs other plugins about availability IsDisabled() bool }
Server defines the API for getting grpc.Server instance that is useful for registering new GRPC services
type UserMetadata ¶
type UserMetadata struct {
ID string
}
UserMetadata contains metadata about a user.
func GetUserMetadata ¶
func GetUserMetadata(ctx context.Context) (*UserMetadata, bool)
GetUserMetadata can be used to extract user metadata stored in a context.