server

package
v0.0.0-...-beb73e8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register[T any](
	s *Server,
	handler func(svc T, opts ...connect.HandlerOption) (string, http.Handler),
	svc T, opts ...connect.HandlerOption,
)

Register can be user to register a new sub-service to the server. This is _NOT_ a part of the Server API, because it is generic.

Types

type Server

type Server struct {
	Enforcer *service.Service[validatorrpc.ValidatorServiceClient]
	Bitcoind *service.Service[*server.Bitcoind]
	Wallet   *service.Service[validatorrpc.WalletServiceClient]
	Crypto   *service.Service[cryptorpc.CryptoServiceClient]
	// contains filtered or unexported fields
}

Server exposes a set of Connect APIs over both gRPC and HTTP. Reflection is enabled.

func NewServer

func NewServer(
	ctx context.Context,
	bitcoindConnector service.Connector[*server.Bitcoind],
	walletConnector service.Connector[validatorrpc.WalletServiceClient],
	enforcerConnector service.Connector[validatorrpc.ValidatorServiceClient],
	cryptoConnector service.Connector[cryptorpc.CryptoServiceClient],
	database *sql.DB,
	onShutdown func(),
) (*Server, error)

New creates a new Server with interceptors applied.

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, address string) error

func (*Server) Shutdown

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

Shutdown tries to gracefully stop the server, forcing a shutdown after a timeout if this isn't possible. It is safe to call on a nil server.

Jump to

Keyboard shortcuts

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