jrpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*jrpcOpt)

func WithCorsOrigins

func WithCorsOrigins(o *cors.Options) Option

WithCorsOrigins is an Option function that allows setting custom CORS options for the JSON-RPC server. It takes a pointer to a cors.Options object and updates the server's configuration to use the provided CORS settings. This function enables the configuration of allowed origins, methods, headers, and other CORS-related options.

Usage example:

server := NewServer(WithCorsOrigins(&cors.Options{
    AllowedOrigins: []string{"https://example.com"},
}))

func WithCustomHeaders

func WithCustomHeaders(headersKey ...string) Option

WithCustomHeaders add custom headers to metadata.MD

func WithReadHeaderTimeout

func WithReadHeaderTimeout(timeout time.Duration) Option

WithReadHeaderTimeout set custom read header timeout

type Server

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

func NewServer

func NewServer(opts ...Option) *Server

NewServer create json rpc server

func (*Server) GracefulStop

func (s *Server) GracefulStop(ctx context.Context) error

GracefulStop stops the JRPC server gracefully. It stops the server from accepting new connections.

func (*Server) RegisterServices

func (s *Server) RegisterServices(svs ...Service)

RegisterServices register jgw servers to jrpc handler

func (*Server) Serve

func (s *Server) Serve(listener net.Listener) error

Serve accepts incoming connections on the listener lis.

type Service

type Service interface {
	Methods() map[string]method
}

Jump to

Keyboard shortcuts

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