substratum

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 18 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 {
	//
	// Invoked when registering component.
	//
	// Return the component name.
	Name() string

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

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

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

	// Register service.
	RegisterService(service.Authenticator, service.Implementor) error

	//
	// Invoked when serving.
	//
	// Run queue consume workers.
	RunQueueWorker(queue.Queue) error

	// Schedule cron tasks.
	ScheduleCronTask(task.Task) error
}

Service component.

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

Return server context.

func (*Server) GetGRPCServer

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

Get gRPC server of the specified visible scope.

func (*Server) GetGatewayMux

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

Get 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

Return the stream server interceptor for local gateway handler server.

func (*Server) UnaryInterceptor

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

Return 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

	// Scoped http handler.
	Handle(scope permission.VisibleScope, pattern string, handler http.Handler)

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

	// Add 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

Directories

Path Synopsis
util
scheduler
https://github.com/robfig/cron/blob/v3.0.1/constantdelay.go https://github.com/robfig/cron/blob/v3.0.1/parser.go https://github.com/robfig/cron/blob/v3.0.1/spec.go
https://github.com/robfig/cron/blob/v3.0.1/constantdelay.go https://github.com/robfig/cron/blob/v3.0.1/parser.go https://github.com/robfig/cron/blob/v3.0.1/spec.go

Jump to

Keyboard shortcuts

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