server

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetRoute = "/get/"
	PutRoute = "/put/"
	Put      = "put"

	CommitmentModeKey = "commitment_mode"
)

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func LoadStoreRouter added in v1.3.0

func LoadStoreRouter(ctx context.Context, cfg CLIConfig, log log.Logger) (store.IRouter, error)

LoadStoreRouter ... creates storage backend clients and instruments them into a storage routing abstraction

func ReadCommitmentMeta added in v1.5.0

func ReadCommitmentMeta(r *http.Request) (commitments.CommitmentMeta, error)

Read both commitment mode and version

func ReadCommitmentMode added in v1.2.0

func ReadCommitmentMode(r *http.Request) (commitments.CommitmentMode, error)

func ReadCommitmentVersion added in v1.5.0

func ReadCommitmentVersion(r *http.Request, mode commitments.CommitmentMode) (byte, error)

func WithLogging

func WithLogging(
	handleFn func(http.ResponseWriter, *http.Request) error,
	log log.Logger,
) func(http.ResponseWriter, *http.Request)

WithLogging is a middleware that logs the request method and URL.

func WithMetrics

WithMetrics is a middleware that records metrics for the route path.

Types

type CLIConfig

type CLIConfig struct {
	EigenDAConfig Config
	MetricsCfg    opmetrics.CLIConfig
}

func ReadCLIConfig

func ReadCLIConfig(ctx *cli.Context) CLIConfig

func (CLIConfig) Check

func (c CLIConfig) Check() error

type Config added in v1.2.0

type Config struct {
	EdaClientConfig clients.EigenDAClientConfig
	VerifierConfig  verify.Config

	MemstoreEnabled bool
	MemstoreConfig  memstore.Config

	// routing
	FallbackTargets []string
	CacheTargets    []string

	// secondary storage
	RedisConfig redis.Config
	S3Config    s3.Config
}

func ReadConfig added in v1.2.0

func ReadConfig(ctx *cli.Context) Config

ReadConfig ... parses the Config from the provided flags or environment variables.

func (*Config) Check added in v1.2.0

func (cfg *Config) Check() error

Check ... verifies that configuration values are adequately set

type MetaError added in v1.5.0

type MetaError struct {
	Err  error
	Meta commitments.CommitmentMeta
}

MetaError includes both an error and commitment metadata

func NewMetaError added in v1.5.0

func NewMetaError(err error, meta commitments.CommitmentMeta) MetaError

NewMetaError creates a new MetaError

func (MetaError) Error added in v1.5.0

func (me MetaError) Error() string

type Server

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

func NewServer

func NewServer(host string, port int, router store.IRouter, log log.Logger,
	m metrics.Metricer) *Server

func (*Server) Endpoint

func (svr *Server) Endpoint() string

func (*Server) GetEigenDAStats added in v1.4.1

func (svr *Server) GetEigenDAStats() *store.Stats

func (*Server) GetS3Stats added in v1.3.0

func (svr *Server) GetS3Stats() *store.Stats

func (*Server) GetStoreStats added in v1.5.0

func (svr *Server) GetStoreStats(bt store.BackendType) (*store.Stats, error)

func (*Server) HandleGet

HandleGet handles the GET request for commitments. Note: even when an error is returned, the commitment meta is still returned, because it is needed for metrics (see the WithMetrics middleware). TODO: we should change this behavior and instead use a custom error that contains the commitment meta.

func (*Server) HandlePut

HandlePut handles the PUT request for commitments. Note: even when an error is returned, the commitment meta is still returned, because it is needed for metrics (see the WithMetrics middleware). TODO: we should change this behavior and instead use a custom error that contains the commitment meta.

func (*Server) Health

func (svr *Server) Health(w http.ResponseWriter, _ *http.Request) error

func (*Server) Port added in v1.1.1

func (svr *Server) Port() int

func (*Server) Start

func (svr *Server) Start() error

func (*Server) Stop

func (svr *Server) Stop() error

func (*Server) WriteBadRequest

func (svr *Server) WriteBadRequest(w http.ResponseWriter, err error)

func (*Server) WriteInternalError

func (svr *Server) WriteInternalError(w http.ResponseWriter, err error)

func (*Server) WriteNotFound

func (svr *Server) WriteNotFound(w http.ResponseWriter, err error)

func (*Server) WriteResponse

func (svr *Server) WriteResponse(w http.ResponseWriter, data []byte)

Jump to

Keyboard shortcuts

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