Documentation
¶
Overview ¶
Package api implements the Forky HTTP API as defined by the OpenAPI spec at api/openapi.yaml. The handlers implement the ogen-generated rest.Handler interface and map domain types onto the generated schema types, so the wire format is enforced by the spec.
Index ¶
- type Config
- type EdgeCacheConfig
- type HTTP
- func (h *HTTP) GetEthereumNow(ctx context.Context) (rest.GetEthereumNowRes, error)
- func (h *HTTP) GetEthereumSpec(ctx context.Context) (rest.GetEthereumSpecRes, error)
- func (h *HTTP) GetFrame(ctx context.Context, params rest.GetFrameParams) (rest.GetFrameRes, error)
- func (h *HTTP) Handler() (http.Handler, error)
- func (h *HTTP) ListMetadata(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataRes, error)
- func (h *HTTP) ListMetadataEpochs(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataEpochsRes, error)
- func (h *HTTP) ListMetadataLabels(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataLabelsRes, error)
- func (h *HTTP) ListMetadataNodes(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataNodesRes, error)
- func (h *HTTP) ListMetadataSlots(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataSlotsRes, error)
- func (h *HTTP) NewError(_ context.Context, err error) *rest.UnexpectedErrorStatusCode
- type Metrics
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
EdgeCacheConfig EdgeCacheConfig `yaml:"edge_cache" default:"{}"`
}
type EdgeCacheConfig ¶
type EdgeCacheConfig struct {
Enabled bool `yaml:"enabled" default:"true"`
FrameTTL human.Duration `yaml:"frame_ttl" default:"1440m"`
}
func (*EdgeCacheConfig) Validate ¶
func (c *EdgeCacheConfig) Validate() error
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP serves the Forky API over HTTP.
func NewHTTP ¶
func NewHTTP(log logrus.FieldLogger, svc *service.ForkChoice, config *Config, opts *Options) (*HTTP, error)
NewHTTP creates a new HTTP API around the fork-choice service.
func (*HTTP) GetEthereumNow ¶
GetEthereumNow implements getEthereumNow: the current wall-clock slot and epoch.
func (*HTTP) GetEthereumSpec ¶
GetEthereumSpec implements getEthereumSpec: the configured network name and spec.
func (*HTTP) GetFrame ¶
func (h *HTTP) GetFrame(ctx context.Context, params rest.GetFrameParams) (rest.GetFrameRes, error)
GetFrame implements getFrame: a single fork-choice frame by ID.
func (*HTTP) Handler ¶
Handler returns the http.Handler serving the API, instrumented with per-route metrics.
func (*HTTP) ListMetadata ¶
func (h *HTTP) ListMetadata(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataRes, error)
ListMetadata implements listMetadata: a page of frame metadata.
func (*HTTP) ListMetadataEpochs ¶
func (h *HTTP) ListMetadataEpochs(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataEpochsRes, error)
ListMetadataEpochs implements listMetadataEpochs: distinct epochs.
func (*HTTP) ListMetadataLabels ¶
func (h *HTTP) ListMetadataLabels(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataLabelsRes, error)
ListMetadataLabels implements listMetadataLabels: distinct labels.
func (*HTTP) ListMetadataNodes ¶
func (h *HTTP) ListMetadataNodes(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataNodesRes, error)
ListMetadataNodes implements listMetadataNodes: distinct node names.
func (*HTTP) ListMetadataSlots ¶
func (h *HTTP) ListMetadataSlots(ctx context.Context, req *rest.MetadataQuery) (rest.ListMetadataSlotsRes, error)
ListMetadataSlots implements listMetadataSlots: distinct slots.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics records request/response counts and durations per route.
func NewMetrics ¶
NewMetrics creates the API metrics collectors, registering them when enabled.
func (Metrics) ObserveRequest ¶
ObserveRequest records an incoming request.
type Options ¶
type Options struct {
MetricsEnabled bool
}
func DefaultOptions ¶
func DefaultOptions() *Options