service

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

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 Remove

func Remove(service ServiceType)

Remove removes a service from the registry.

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) Start

func (s *BaseService) Start(network utils.Network, networkId utils.NetworkID) error

Start starts the base service.

func (*BaseService) Stop

func (s *BaseService) Stop() error

Stop stops the base service.

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

func WithBindManager(bindManager *bindings.Manager) Option

WithBindManager sets the bindings manager for the BaseService.

func WithCache

func WithCache(cache *cache.Redis) Option

WithCache sets the Redis cache for the BaseService.

func WithDB

func WithDB(db db.Adapter) Option

WithDB sets the database connection for the BaseService.

func WithEtherscan

func WithEtherscan(etherscan *etherscan.Provider) Option

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 WithPprof

func WithPprof(pprof *pprof.Pprof) Option

WithPprof sets the pprof for the BaseService.

func WithSourcify

func WithSourcify(sourcify *sourcify.Client) Option

WithSourcify sets the sourcify client for the BaseService.

func WithState

func WithState(state *state.State) Option

WithState sets the state 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

func WithUnpacker(unpacker *unpacker.Unpacker) Option

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.

Jump to

Keyboard shortcuts

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