aether

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FullMethodNameCtxKey = "fullMethodName"

FullMethodNameCtxKey is the key of the full method name in the context passed into interceptor functions. This allows interceptor functions to access the full method name from `ctx`.

Variables

This section is empty.

Functions

func GetFullMethodNameFromContext

func GetFullMethodNameFromContext(ctx context.Context) string

GetFullMethodNameFromContext gets the full method name from the context passed into an interceptor function.

func NotYetImplementedError

func NotYetImplementedError(msg string) error

NotYetImplementedError returns an UNIMPLEMNTED error plus a message.

func RunOrExit

func RunOrExit(configure func(c *ServerConfig) error, port int)

RunOrExit runs the provided gRPC server on the specified port. `configure` is a function that can be used to set up resources and configure the server before running.

func UnauthenticatedError

func UnauthenticatedError() error

UnauthenticatedError returns an UNAUTHENTICATED error.

func ValidationError

func ValidationError(msg string) error

ValidationError returns an INVALID_ARGUMENT error plus a message.

Types

type ConfigureFunc

type ConfigureFunc func(c *ServerConfig) error

ConfigureFunc is a function that is used to set up an Aether server. It is passed a pointer to a ServerConfig, which can be used to add interceptors, register services, and more.

type Interceptor

type Interceptor = func(context.Context, interface{}) error

Interceptor is a function that is run before a request or after a response.

type Module

type Module interface {
	// Configure is a function that will be called as Aether sets up the server. Configure is passed
	// a pointer to a ServerConfig, which can be used to add interceptors, register gRPC services, and more.
	Configure(c *ServerConfig) error
	Name() string
}

Module is an interface that represents an Aether Module. A module is a self-contained, reuseable piece of functionality that servers can install. It is the fundamental building block of an Aether server.

type ServerConfig

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

func (*ServerConfig) AddMethodRequestInterceptor

func (*ServerConfig) AddMethodRequestInterceptor(methodName string, interceptor Interceptor)

AddMethodRequestInterceptor adds a function that will be called with an incoming request before the specified method is called. Interceptors are called in FIFO order: interceptors added first will be called first. The `methodName` is the full RPC method string, i.e., /package.service/method.

func (*ServerConfig) AddMethodResponseInterceptor

func (*ServerConfig) AddMethodResponseInterceptor(methodName string, interceptor Interceptor)

AddMethodResponseInterceptor adds a function that will be called with an outgoing response from a specified method before it's sent to the caller. Interceptors are called in FIFO order: interceptors added first will be called first.

func (*ServerConfig) AddRequestInterceptor

func (*ServerConfig) AddRequestInterceptor(interceptor Interceptor)

AddRequestInterceptor adds a function that will be called with an incoming request before the handler is called. Interceptors are called in FIFO order: interceptors added first will be called first.

func (*ServerConfig) AddResponseInterceptor

func (*ServerConfig) AddResponseInterceptor(interceptor Interceptor)

AddResponseInterceptor adds a function that will be called with an outgoing response before it's sent to the caller. Interceptors are called in FIFO order: interceptors added first will be called first.

func (*ServerConfig) GetGRPCServer

func (s *ServerConfig) GetGRPCServer() *grpc.Server

GetGRPCServer gets a reference to the current gRPC server. Useful for registering services.

func (*ServerConfig) InstallModule

func (s *ServerConfig) InstallModule(module Module)

InstallModule installs an Aether Module on the current server.

type Service

type Service interface {
	Service() interface{}
	ServiceDesc() *grpc.ServiceDesc
}

Jump to

Keyboard shortcuts

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