pallas

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

Pallas

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsDebug bool

Functions

func Debug

func Debug(fn func())

func OnStartup

func OnStartup(fn func(app *Application) error) utility.Option[Application]

func WithAddr

func WithAddr(network, addr string) utility.Option[Application]

WithAddr served http and grpc on same address

func WithBeforeStart

func WithBeforeStart(handler StartInterceptor) utility.Option[Application]

func WithDefaultCodecType

func WithDefaultCodecType(typename string) utility.Option[Application]

WithDefaultCodecType is http server defalt Codec type name encoding/json.Type or encoding/xml.Type or custom register Codec type

func WithGrpcMatcher

func WithGrpcMatcher(matcher cmux.MatchWriter) utility.Option[Application]

WithGrpcMatcher custom grpc dispatcher

func WithGrpcOpts

func WithGrpcOpts(gopts ...utility.Option[grpcx.Server]) utility.Option[Application]

WithGrpcOpts accept grpc server options

func WithHttpErrEncoder

func WithHttpErrEncoder(encoder httpx.ErrorEncoder) utility.Option[Application]

func WithHttpOpts

func WithHttpOpts(hopts ...utility.Option[httpx.Server]) utility.Option[Application]

func WithListener

func WithListener(listener net.Listener) utility.Option[Application]

WithListener served http and grpc on same address

func WithLogger

func WithLogger(logger *slog.Logger) utility.Option[Application]

func WithMiddleware

func WithMiddleware(middlewares ...middleware.Middleware) utility.Option[Application]

func WithServices

func WithServices(services ...types.Service) utility.Option[Application]

func WithTCPAddr

func WithTCPAddr(addr string) utility.Option[Application]

WithTCPAddr is WithAddr alias but network using tcp

Types

type Application

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

func NewApp

func NewApp(opts ...utility.Option[Application]) *Application

NewApp returns Application

func (*Application) Address

func (app *Application) Address() net.Addr

Address returns application listen address this address is http and grpc both

func (*Application) RegisterService

func (app *Application) RegisterService(services ...types.Service)

RegisterService add service to http and grpc server

func (*Application) Run

func (app *Application) Run(ctx context.Context) (err error)

Run start the server until terminate

func (*Application) Shutdown

func (app *Application) Shutdown()

type StartInterceptor

type StartInterceptor func(context.Context) (context.Context, error)

Jump to

Keyboard shortcuts

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