Documentation ¶
Index ¶
- Variables
- func NewLoggerServer(stopCh <-chan os.Signal, addr string, log *logrus.Logger, client Backend, ...) error
- type Backend
- type Config
- type LoggerServer
- func (s *LoggerServer) Add(ctx context.Context, req *logger.AddressReqMessage) (*logger.BlockNumberMessage, error)
- func (s *LoggerServer) Connect(req *logger.ConnectReqMessage, stream grpc.ServerStreamingServer[logger.Log]) error
- func (s *LoggerServer) Info(context.Context, *emptypb.Empty) (*logger.InfoResMessage, error)
- func (s *LoggerServer) Remove(ctx context.Context, req *logger.AddressReqMessage) (*logger.BlockNumberMessage, error)
- func (s *LoggerServer) Start(ctx context.Context, req *logger.BlockNumberMessage) (*emptypb.Empty, error)
- func (s *LoggerServer) Stop(ctx context.Context, _ *emptypb.Empty) (*logger.BlockNumberMessage, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cli.Command{ Name: "event-logger", Flags: []cli.Flag{flags.ConfigFlag}, Action: func(ctx *cli.Context) error { config, err := flags.ReadConfig[Config](ctx) if err != nil { return err } logger, err := config.NewLogger() if err != nil { return err } logger.Info("Set Filter Query from Config...") query, err := config.NewFilterQuery() if err != nil { return err } logger.Info("Dial ETH Client...") client, err := ethclient.DialContext(ctx.Context, config.Chain.URI) if err != nil { return err } defer client.Close() logger.Info("Connect Mongodb...") collection, err := config.ConnectDatabase() if err != nil { return err } defer collection.Database().Client().Disconnect(ctx.Context) stopCh := make(chan os.Signal, 1) signal.Notify(stopCh, syscall.SIGINT, syscall.SIGTERM) defer close(stopCh) logger.Info("Open Query Server...") return NewLoggerServer(stopCh, config.Server.Host, logger, client, collection, query) }, }
Functions ¶
Types ¶
type Config ¶
type Config struct { Chain struct { URI string `toml:"uri"` } `toml:"chain"` Database struct { URI string `toml:"uri"` Database string `toml:"database"` Collection string `toml:"collection"` } `toml:"db"` Server struct { Host string `toml:"host"` } `toml:"server"` Logger struct { Level string `toml:"level"` // panic,fatal,error,warn,info,debug,trace File string `toml:"file"` } `toml:"log"` FilterQuery struct { ScanBlock uint64 `toml:"scan-block"` Addresses []common.Address `toml:"addresses"` } `toml:"filter-query"` }
func (*Config) ConnectDatabase ¶
func (config *Config) ConnectDatabase() (*mongo.Collection, error)
func (*Config) NewFilterQuery ¶
type LoggerServer ¶
type LoggerServer struct { logger.UnimplementedLoggerServer logger.UnimplementedAdminServer // contains filtered or unexported fields }
func (*LoggerServer) Add ¶
func (s *LoggerServer) Add(ctx context.Context, req *logger.AddressReqMessage) (*logger.BlockNumberMessage, error)
func (*LoggerServer) Connect ¶
func (s *LoggerServer) Connect(req *logger.ConnectReqMessage, stream grpc.ServerStreamingServer[logger.Log]) error
func (*LoggerServer) Info ¶
func (s *LoggerServer) Info(context.Context, *emptypb.Empty) (*logger.InfoResMessage, error)
func (*LoggerServer) Remove ¶
func (s *LoggerServer) Remove(ctx context.Context, req *logger.AddressReqMessage) (*logger.BlockNumberMessage, error)
func (*LoggerServer) Start ¶
func (s *LoggerServer) Start(ctx context.Context, req *logger.BlockNumberMessage) (*emptypb.Empty, error)
func (*LoggerServer) Stop ¶
func (s *LoggerServer) Stop(ctx context.Context, _ *emptypb.Empty) (*logger.BlockNumberMessage, error)
Click to show internal directories.
Click to hide internal directories.