rpc

package
v0.0.0-...-d36796e Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export[Request, Response any](method HandlerFunc[Request, Response])

Export exports a method to RPC. The name of method will be converted to kebab-case.

func ExportName

func ExportName[Request, Response any](name string, method HandlerFunc[Request, Response])

ExportName exports a method to RPC with specified name.

Types

type HandlerFunc

type HandlerFunc[Request, Response any] func(ctx context.Context, req *Request) (resp *Response, err error)

func Compile

func Compile[Request, Response any](method HandlerFunc[Request, Response]) HandlerFunc[Request, Response]

Compile wraps a method with request validator, initer and error handler. The returned method is used in RPC server to handle any request.

Business code should never call Compile unless for test purpose, e.g. writing unit test cases for a RPC method.

type Server

type Server interface {
	Serve(ctx context.Context) error
	Shutdown(ctx context.Context) error
}

Server represents a long running server.

Directories

Path Synopsis
Package httpjson provides utilities to handle Shana-opinioned HTTP JSON requests.
Package httpjson provides utilities to handle Shana-opinioned HTTP JSON requests.

Jump to

Keyboard shortcuts

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