Documentation
¶
Index ¶
- Constants
- func InstrumentMetricsUnaryServerInterceptor(mtr metric.Meter, log *slog.Logger) grpc.UnaryServerInterceptor
- func NewGRPCServer(node partitionNode, obs Observability, opts ...Option) (*grpcServer, error)
- func NewHTTPServer(conf *ServerConfiguration, obs Observability, registrars ...Registrar) (*http.Server, error)
- func NewRESTServer(addr string, maxBodySize int64, obs Observability, registrars ...Registrar) *http.Serverdeprecated
- func WriteCBORError(w http.ResponseWriter, e error, code int, log *slog.Logger)
- func WriteCBORResponse(w http.ResponseWriter, response any, statusCode int, log *slog.Logger)
- type API
- type Observability
- type Option
- type Options
- type Registrar
- type RegistrarFunc
- type ServerConfiguration
- type StateAPI
- func (s *StateAPI) GetRoundNumber(ctx context.Context) (uint64, error)
- func (s *StateAPI) GetTransactionProof(txHash string) ([]byte, error)
- func (s *StateAPI) GetUnit(unitID string) (state.UnitData, error)
- func (s *StateAPI) GetUnitsByOwnerID(ownerID string) ([]state.UnitData, error)
- func (s *StateAPI) SendTransaction(tx []byte) error
Constants ¶
View Source
const ( MetricsScopeGRPCAPI = "grpc_api" DefaultMaxBodyBytes int64 = 4194304 // 4MB DefaultBatchItemLimit int = 1000 DefaultBatchResponseSizeLimit int = int(DefaultMaxBodyBytes) )
Variables ¶
This section is empty.
Functions ¶
func NewGRPCServer ¶
func NewGRPCServer(node partitionNode, obs Observability, opts ...Option) (*grpcServer, error)
func NewHTTPServer ¶
func NewHTTPServer(conf *ServerConfiguration, obs Observability, registrars ...Registrar) (*http.Server, error)
func NewRESTServer
deprecated
func WriteCBORError ¶
WriteCBORError replies to the request with the specified error message and HTTP code. It does not otherwise end the request; the caller should ensure no further writes are done to w.
func WriteCBORResponse ¶
WriteCBORResponse replies to the request with the given response and HTTP code.
Types ¶
type Observability ¶
type Observability interface {
Meter(name string, opts ...metric.MeterOption) metric.Meter
PrometheusRegisterer() prometheus.Registerer
Logger() *slog.Logger
}
type RegistrarFunc ¶
RegistrarFunc type is an adapter to allow the use of ordinary function as Registrar.
func InfoEndpoints ¶
func MetricsEndpoints ¶
func MetricsEndpoints(pr prometheus.Registerer) RegistrarFunc
func NodeEndpoints ¶
func NodeEndpoints(node partitionNode, unitProofDB keyvaluedb.KeyValueDB, obs Observability) RegistrarFunc
func (RegistrarFunc) Register ¶
func (f RegistrarFunc) Register(r *mux.Router)
type ServerConfiguration ¶
type ServerConfiguration struct {
// Address specifies the TCP address for the server to listen on, in the form "host:port".
// REST server isn't initialised if Address is empty.
Address string
// ReadTimeout is the maximum duration for reading the entire request, including the body. A zero or negative
// value means there will be no timeout.
ReadTimeout time.Duration
// ReadHeaderTimeout is the amount of time allowed to read request headers. If ReadHeaderTimeout is zero, the
// value of ReadTimeout is used. If both are zero, there is no timeout.
ReadHeaderTimeout time.Duration
// WriteTimeout is the maximum duration before timing out writes of the response. A zero or negative value means
// there will be no timeout.
WriteTimeout time.Duration
// IdleTimeout is the maximum amount of time to wait for the next request when keep-alives are enabled. If
// IdleTimeout is zero, the value of ReadTimeout is used. If both are zero, there is no timeout.
IdleTimeout time.Duration
// MaxHeaderBytes controls the maximum number of bytes the server will read parsing the request header's keys
// and values, including the request line. It does not limit the size of the request body. If zero,
// http.DefaultMaxHeaderBytes is used.
MaxHeaderBytes int
// MaxHeaderBytes controls the maximum number of bytes the server will read parsing the request body. If zero,
// MaxBodyBytes is used.
MaxBodyBytes int64
// BatchItemLimit is the maximum number of requests in a batch.
BatchItemLimit int
// BatchResponseSizeLimit is the maximum number of response bytes across all requests in a batch.
BatchResponseSizeLimit int
Router Registrar
// APIs contains is an array of enabled RPC services.
APIs []API
}
ServerConfiguration is a common configuration for RPC servers.
func (*ServerConfiguration) IsAddressEmpty ¶
func (c *ServerConfiguration) IsAddressEmpty() bool
type StateAPI ¶
type StateAPI struct {
// contains filtered or unexported fields
}
func NewStateAPI ¶
func (*StateAPI) GetRoundNumber ¶
Returns the round number of the latest UC seen by node.
func (*StateAPI) GetTransactionProof ¶
func (*StateAPI) GetUnitsByOwnerID ¶
func (*StateAPI) SendTransaction ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.