substratum

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: MIT Imports: 19 Imported by: 0

README

substratum

Documentation

Index

Constants

View Source
const (
	DefaultClientRpcPort     = 8080
	DefaultClientGatewayPort = 8081
	DefaultServerRpcPort     = 8088
	DefaultServerGatewayPort = 8089
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {

	// Name returns the component name.
	Name() string

	// Init component.
	Init(configure.Configure) error

	// InitStorage entry.
	InitStorage(storage.Storage) error

	// RegisterHandler registers HTTP handler.
	RegisterHandler(outer, inner *http.ServeMux) error

	// RegisterService registers the service.
	RegisterService(service.Authenticator, service.Implementor) error

	// RunQueueWorker will run the registered queue consumers.
	RunQueueWorker(queue.Queue) error

	// ScheduleCronTask schedules the cron tasks.
	ScheduleCronTask(task.Task) error
}

Component interface.

type Server

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

func (*Server) AddMux

func (s *Server) AddMux(scope permission.VisibleScope, rpcPort, gatewayPort uint16) error

func (*Server) Context

func (s *Server) Context() context.Context

Context returns the service context.

func (*Server) GetGRPCServer

func (s *Server) GetGRPCServer(scope permission.VisibleScope) []*grpc.Server

GetGRPCServer returns gRPC server of the specified visible scope.

func (*Server) GetGatewayMux

func (s *Server) GetGatewayMux(scope permission.VisibleScope) []*runtime.ServeMux

GetGatewayMux returns gateway mux of the specified visible scope.

func (*Server) Handle

func (s *Server) Handle(scope permission.VisibleScope, pattern string, handler http.Handler)

func (*Server) HandleFunc

func (s *Server) HandleFunc(scope permission.VisibleScope, pattern string, handler http.HandlerFunc)

func (*Server) Register

func (s *Server) Register(comp Component, rpcs ...string) error

func (*Server) Serve

func (s *Server) Serve(isolate ...bool) error

func (*Server) StreamInterceptor

func (s *Server) StreamInterceptor() grpc.StreamServerInterceptor

StreamInterceptor returns the stream server interceptor for local gateway handler server.

func (*Server) UnaryInterceptor

func (s *Server) UnaryInterceptor() grpc.UnaryServerInterceptor

UnaryInterceptor returns the unary server interceptor for local gateway handler server.

type ServerOption

type ServerOption func(*Server)

func WithContext

func WithContext(ctx context.Context) ServerOption

func WithDefaultClientMux

func WithDefaultClientMux() ServerOption

func WithDefaultServerMux

func WithDefaultServerMux() ServerOption

func WithKeepAliveTTL

func WithKeepAliveTTL(ttl time.Duration) ServerOption

func WithMux

func WithMux(scope permission.VisibleScope, rpcPort, gatewayPort uint16) ServerOption

type Service

type Service interface {
	service.Implementor

	// Handle registers the scoped http handler.
	Handle(scope permission.VisibleScope, pattern string, handler http.Handler)

	// HandleFunc registers the scoped http handle function.
	HandleFunc(scope permission.VisibleScope, pattern string, handler http.HandlerFunc)

	// AddMux adds scoped ServeMux.
	AddMux(permission.VisibleScope, uint16, uint16) error

	// Register component.
	Register(Component, ...string) error

	// Serve start the mux server.
	Serve(isolate ...bool) error
}

func NewServer

func NewServer(opts ...ServerOption) Service

Jump to

Keyboard shortcuts

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