Documentation ¶
Index ¶
- func Register(service ServiceType, srvce Service) bool
- func Remove(service ServiceType)
- func ServiceTypeInSlice(str ServiceType, list []ServiceType) bool
- func SetGlobalBaseService(base *BaseService)
- type BaseService
- func (s *BaseService) Dependencies() map[DependencyName]Option
- func (s *BaseService) DependencyLoaded(name DependencyName) bool
- func (s *BaseService) GetAccountUnpacker() *accounts.Unpacker
- func (s *BaseService) GetBindManager() *bindings.Manager
- func (s *BaseService) GetCache() *cache.Redis
- func (s *BaseService) GetClickhouseDbAdapter() db.Adapter
- func (s *BaseService) GetCompiler() *solc.Solc
- func (s *BaseService) GetCtx() context.Context
- func (s *BaseService) GetDbAdapter() db.Adapter
- func (s *BaseService) GetEtherscanProvider() *etherscan.Provider
- func (s *BaseService) GetLabels() *labels.LabelManager
- func (s *BaseService) GetNats() *nats.Conn
- func (s *BaseService) GetPool() *clients.ClientPool
- func (s *BaseService) GetPostgresDbAdapter() db.Adapter
- func (s *BaseService) GetPprof() *pprof.Pprof
- func (s *BaseService) GetRestServer() *rest.Server
- func (s *BaseService) GetRpcServer() *rpc.Server
- func (s *BaseService) GetSourcify() *sourcify.Client
- func (s *BaseService) GetState() *state.State
- func (s *BaseService) GetStats() *stats.Prometheus
- func (s *BaseService) GetStorage() *storage.Storage
- func (s *BaseService) GetSubscribersManager() *subscribers.Manager
- func (s *BaseService) GetUnpacker() *unpacker.Unpacker
- func (s *BaseService) RegisterDependency(name DependencyName, opt Option) error
- func (s *BaseService) Start(network utils.Network, networkId utils.NetworkID) error
- func (s *BaseService) Stop() error
- func (s *BaseService) SyncCompilerReleases(syncEvery time.Duration) error
- type DependencyName
- type Option
- func WithBindManager(bindManager *bindings.Manager) Option
- func WithCache(cache *cache.Redis) Option
- func WithDB(db db.Adapter) Option
- func WithEtherscan(etherscan *etherscan.Provider) Option
- func WithNATS(nats *nats.Conn) Option
- func WithPool(pool *clients.ClientPool) Option
- func WithPprof(pprof *pprof.Pprof) Option
- func WithSourcify(sourcify *sourcify.Client) Option
- func WithState(state *state.State) Option
- func WithStats(stats *stats.Prometheus) Option
- func WithSubscribers(subs *subscribers.Manager) Option
- func WithUnpacker(unpacker *unpacker.Unpacker) Option
- type OptionFn
- type Service
- type ServiceType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(service ServiceType, srvce Service) bool
Register adds a service to the registry if it doesn't already exist. It returns true if the service was successfully registered, false otherwise.
func ServiceTypeInSlice ¶
func ServiceTypeInSlice(str ServiceType, list []ServiceType) bool
ServiceTypeInSlice checks whether a ServiceType is present in a slice of ServiceType's.
func SetGlobalBaseService ¶
func SetGlobalBaseService(base *BaseService)
Types ¶
type BaseService ¶
type BaseService struct {
// contains filtered or unexported fields
}
BaseService represents a base service implementation.
func S ¶
func S() *BaseService
func ToBaseService ¶
func ToBaseService(service Service) *BaseService
func (*BaseService) Dependencies ¶
func (s *BaseService) Dependencies() map[DependencyName]Option
Dependencies return the dependencies of the base service.
func (*BaseService) DependencyLoaded ¶
func (s *BaseService) DependencyLoaded(name DependencyName) bool
func (*BaseService) GetAccountUnpacker ¶
func (s *BaseService) GetAccountUnpacker() *accounts.Unpacker
GetAccountUnpacker returns the account unpacker.
func (*BaseService) GetBindManager ¶
func (s *BaseService) GetBindManager() *bindings.Manager
GetBindManager returns the bindings manager.
func (*BaseService) GetCache ¶
func (s *BaseService) GetCache() *cache.Redis
GetCache returns the Redis cache.
func (*BaseService) GetClickhouseDbAdapter ¶
func (s *BaseService) GetClickhouseDbAdapter() db.Adapter
GetClickhouseDbAdapter returns the clickhouse database adapter.
func (*BaseService) GetCompiler ¶
func (s *BaseService) GetCompiler() *solc.Solc
func (*BaseService) GetCtx ¶
func (s *BaseService) GetCtx() context.Context
GetCtx returns the context of the base service.
func (*BaseService) GetDbAdapter ¶
func (s *BaseService) GetDbAdapter() db.Adapter
GetDbAdapter returns the default postgres database adapter.
func (*BaseService) GetEtherscanProvider ¶
func (s *BaseService) GetEtherscanProvider() *etherscan.Provider
GetEtherscanProvider returns the etherscan provider.
func (*BaseService) GetLabels ¶
func (s *BaseService) GetLabels() *labels.LabelManager
func (*BaseService) GetNats ¶
func (s *BaseService) GetNats() *nats.Conn
GetNats returns the NATS connection.
func (*BaseService) GetPool ¶
func (s *BaseService) GetPool() *clients.ClientPool
GetPool returns the client pool.
func (*BaseService) GetPostgresDbAdapter ¶
func (s *BaseService) GetPostgresDbAdapter() db.Adapter
GetPostgresDbAdapter returns the postgres database adapter.
func (*BaseService) GetPprof ¶
func (s *BaseService) GetPprof() *pprof.Pprof
GetPprof returns the Pprof handler.
func (*BaseService) GetRestServer ¶ added in v0.9.7
func (s *BaseService) GetRestServer() *rest.Server
func (*BaseService) GetRpcServer ¶
func (s *BaseService) GetRpcServer() *rpc.Server
func (*BaseService) GetSourcify ¶
func (s *BaseService) GetSourcify() *sourcify.Client
GetSourcify returns the Sourcify client.
func (*BaseService) GetState ¶
func (s *BaseService) GetState() *state.State
GetState returns the state manager.
func (*BaseService) GetStats ¶
func (s *BaseService) GetStats() *stats.Prometheus
GetStats returns the Prometheus stats collector.
func (*BaseService) GetStorage ¶
func (s *BaseService) GetStorage() *storage.Storage
func (*BaseService) GetSubscribersManager ¶
func (s *BaseService) GetSubscribersManager() *subscribers.Manager
GetSubscribersManager returns the subscribers manager.
func (*BaseService) GetUnpacker ¶
func (s *BaseService) GetUnpacker() *unpacker.Unpacker
GetUnpacker returns the unpacker.
func (*BaseService) RegisterDependency ¶
func (s *BaseService) RegisterDependency(name DependencyName, opt Option) error
func (*BaseService) SyncCompilerReleases ¶
func (s *BaseService) SyncCompilerReleases(syncEvery time.Duration) error
SyncCompilerReleases syncs solc releases based on custom delay (should be at a minimum an hour or a day)
type DependencyName ¶
type DependencyName string
func (DependencyName) String ¶
func (d DependencyName) String() string
type Option ¶
type Option func(*BaseService)
Option defines a function type for configuring BaseService options.
func WithBindManager ¶
WithBindManager sets the bindings manager for the BaseService.
func WithEtherscan ¶
WithEtherscan sets the Etherscan provider for the BaseService.
func WithNATS ¶
func WithNATS(nats *nats.Conn) Option
WithNATS sets the NATS connection for the BaseService.
func WithPool ¶
func WithPool(pool *clients.ClientPool) Option
WithPool sets the client pool for the BaseService.
func WithSourcify ¶
func WithSourcify(sourcify *sourcify.Client) Option
WithSourcify sets the sourcify client for the BaseService.
func WithStats ¶
func WithStats(stats *stats.Prometheus) Option
WithStats sets the Prometheus stats for the BaseService.
func WithSubscribers ¶
func WithSubscribers(subs *subscribers.Manager) Option
WithSubscribers sets the subscribers manager for the BaseService.
func WithUnpacker ¶
WithUnpacker sets the unpacker for the BaseService.
type OptionFn ¶
type OptionFn func(s *BaseService)
type Service ¶
type Service interface { // Dependencies returns the dependencies of the service. Dependencies() map[DependencyName]Option // Start starts the service. Start(network utils.Network, networkId utils.NetworkID) error // Stop stops the service. Stop() error }
Service represents an interface for services.
func NewBaseService ¶
func NewBaseService(ctx *cli.Context, services []ServiceType, bsOpts ...Option) (Service, error)
NewBaseService creates a new base service instance.
type ServiceType ¶
type ServiceType string
ServiceType represents the type of service.
var ( // IndexerServiceType represents the indexer service type. IndexerServiceType ServiceType = "indexer" // AclServiceType represents the ACL (Access Control Lists) service type. AclServiceType ServiceType = "acl" // RpcServiceType represents the RPC service type. RpcServiceType ServiceType = "rpc" // RestServiceType represents the REST service type. RestServiceType ServiceType = "rest" // GraphQlServiceType represents the query (graphql) service type. GraphQlServiceType ServiceType = "graphql" // StatusServiceType represents general statistics service. StatusServiceType ServiceType = "status" // SyncerServiceType represents general syncer service. SyncerServiceType ServiceType = "syncer" )
func Exists ¶
func Exists(service ...ServiceType) (*ServiceType, bool)
Exists checks if a service exists in the registry. It returns true if the service exists, false otherwise.
func ListAvailableServices ¶
func ListAvailableServices() []ServiceType
ListAvailableServices retrieves a list of all registered services.
func SliceToServices ¶
func SliceToServices(slice []string) (services []ServiceType)
SliceToServices converts a slice of strings representing service types into a slice of ServiceType. It takes a slice of strings as input and returns a slice of ServiceType.
func (ServiceType) String ¶
func (s ServiceType) String() string
String returns the string representation of the ServiceType.