api

package
v0.0.0-...-86af830 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricsNamespace = "op_indexer_api"

	// Endpoint paths
	// NOTE - This can be further broken out over time as new version iterations
	// are implemented
	HealthPath      = "/healthz"
	DepositsPath    = "/api/v0/deposits/"
	WithdrawalsPath = "/api/v0/withdrawals/"

	SupplyPath = "/api/v0/supply"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIService

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

Api ... Indexer API struct TODO : Structured error responses

func NewApi

func NewApi(ctx context.Context, log log.Logger, cfg *Config) (*APIService, error)

NewApi ... Construct a new api instance

func (*APIService) Addr

func (a *APIService) Addr() string

Addr ... returns the address that the HTTP server is listening on (excl. http:// prefix, just the host and port)

func (*APIService) Start

func (a *APIService) Start(ctx context.Context) error

func (*APIService) Stop

func (a *APIService) Stop(ctx context.Context) error

func (*APIService) Stopped

func (a *APIService) Stopped() bool

type Config

type Config struct {
	DB            DBConnector
	HTTPServer    config.ServerConfig
	MetricsServer config.ServerConfig
}

Config for the API service

type DB

type DB struct {
	BridgeTransfers database.BridgeTransfersView
	Closer          func() error
}

DB represents the abstract DB access the API has.

type DBConfigConnector

type DBConfigConnector struct {
	config.DBConfig
}

DBConfigConnector implements a fully config based DBConnector

func (*DBConfigConnector) OpenDB

func (cfg *DBConfigConnector) OpenDB(ctx context.Context, log log.Logger) (*DB, error)

type DBConnector

type DBConnector interface {
	OpenDB(ctx context.Context, log log.Logger) (*DB, error)
}

DBConnector is an interface: the config may provide different ways to access the DB. This is implemented in tests to provide custom DB views, or share the DB with other services.

type TestDBConnector

type TestDBConnector struct {
	BridgeTransfers database.BridgeTransfersView
}

func (*TestDBConnector) OpenDB

func (tdb *TestDBConnector) OpenDB(ctx context.Context, log log.Logger) (*DB, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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