service

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UTF8StringFromBytes

func UTF8StringFromBytes(bs []byte) (string, error)

Checks whether the bytes passed are valid utf8 string bytes. If they are not returns a sanitised string version of the bytes with offending sequences replaced by the utf8 replacement/error rune and an error indicating the offending byte sequences and their position. Note: always returns a valid string regardless of error.

Types

type Consumer

type Consumer struct {
	Config         *config.VentConfig
	Log            *logger.Logger
	Closing        bool
	DB             *sqldb.SQLDB
	GRPCConnection *grpc.ClientConn
	// external events channel used for when vent is leveraged as a library
	EventsChannel chan types.EventData
}

Consumer contains basic configuration for consumer to run

func NewConsumer

func NewConsumer(cfg *config.VentConfig, log *logger.Logger, eventChannel chan types.EventData) *Consumer

NewConsumer constructs a new consumer configuration. The event channel will be passed a collection of rows generated from all of the events in a single block It will be closed by the consumer when it is finished

func (*Consumer) Health

func (c *Consumer) Health() error

Health returns the health status for the consumer

func (*Consumer) Run

func (c *Consumer) Run(projection *sqlsol.Projection, abiSpec *abi.AbiSpec, stream bool) error

Run connects to a grpc service and subscribes to log events, then gets tables structures, maps them & parse event data. Store data in SQL event tables, it runs forever

func (*Consumer) Shutdown

func (c *Consumer) Shutdown()

Shutdown gracefully shuts down the events consumer

type Server

type Server struct {
	Config   *config.VentConfig
	Log      *logger.Logger
	Consumer *Consumer
	// contains filtered or unexported fields
}

Server exposes HTTP endpoints for the service

func NewServer

func NewServer(cfg *config.VentConfig, log *logger.Logger, consumer *Consumer) *Server

NewServer returns a new HTTP server

func (*Server) Run

func (s *Server) Run()

Run starts the HTTP server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP dispatches the HTTP requests using the Server Mux

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown gracefully shuts down the HTTP Server

Jump to

Keyboard shortcuts

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