Documentation ¶
Overview ¶
Package eventcollector contains business logic for the event collection
Package eventcollector contains business logic for the event collection ¶
Package eventcollector contains business logic for the event collection
Index ¶
- type AddNewsroomWatchersTrigger
- type Config
- type EventCollector
- func (c *EventCollector) AddFilterers(w model.ContractFilterers) error
- func (c *EventCollector) AddWatchers(w model.ContractWatchers) error
- func (c *EventCollector) CheckRetrievedEventsForNewsroom(pastEvents []*model.Event) ([]*model.Event, error)
- func (c *EventCollector) FilterAddedMultiSigContract(multiSigAddr common.Address) ([]*model.Event, error)
- func (c *EventCollector) FilterAddedNewsroomContract(newsroomAddr common.Address) ([]*model.Event, error)
- func (c *EventCollector) RemoveFilterers(w model.ContractFilterers) error
- func (c *EventCollector) RemoveWatchers(w model.ContractWatchers) error
- func (c *EventCollector) StartChan() chan struct{}
- func (c *EventCollector) StartCollection() error
- func (c *EventCollector) StopCollection(unsubWatchers bool) error
- type RemoveNewsroomWatchersTrigger
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddNewsroomWatchersTrigger ¶
type AddNewsroomWatchersTrigger struct{}
AddNewsroomWatchersTrigger is a Trigger that starts up a new watcher for a newly created newsroom.
func (*AddNewsroomWatchersTrigger) Description ¶
func (n *AddNewsroomWatchersTrigger) Description() string
Description returns the description of the trigger
func (*AddNewsroomWatchersTrigger) Run ¶
func (n *AddNewsroomWatchersTrigger) Run(collector *EventCollector, event *model.Event) error
Run returns the triggered code
func (*AddNewsroomWatchersTrigger) ShouldRun ¶
func (n *AddNewsroomWatchersTrigger) ShouldRun(collector *EventCollector, event *model.Event) bool
ShouldRun returns true or false on whether this trigger should be run
type Config ¶
type Config struct { Chain ethereum.ChainReader HTTPClient bind.ContractBackend WsClient bind.ContractBackend WsEthURL string ErrRep cerrors.ErrorReporter Filterers []model.ContractFilterers Watchers []model.ContractWatchers RetrieverPersister model.RetrieverMetaDataPersister ListenerPersister model.ListenerMetaDataPersister EventDataPersister model.EventDataPersister Triggers []Trigger StartBlock uint64 CrawlerPubSub *pubsub.CrawlerPubSub PollingEnabled bool PollingIntervalSecs int PreemptSecs *int }
Config contains the configuration dependencies for the EventCollector NOTES ON WSCLIENT
- If both WsEthURL / WsClient is set, WsClient will be initially used. If there is a failure, the WS connection will be recreated using the WsEthURL.
- If WsClient is nil, will use WsEthURL to create the ws connection.
- If WsEthURL is not set, but WsClient is, it will continue to try and use the given connection even on error (at your own risk).
- If both are nil, will disable the event listeners.
type EventCollector ¶
type EventCollector struct {
// contains filtered or unexported fields
}
EventCollector handles logic for getting historical and live events
func NewEventCollector ¶
func NewEventCollector(config *Config) *EventCollector
NewEventCollector creates a new event collector
func (*EventCollector) AddFilterers ¶
func (c *EventCollector) AddFilterers(w model.ContractFilterers) error
AddFilterers will add filterer to the embedded retriever.
func (*EventCollector) AddWatchers ¶
func (c *EventCollector) AddWatchers(w model.ContractWatchers) error
AddWatchers will add watchers to the embedded listener.
func (*EventCollector) CheckRetrievedEventsForNewsroom ¶
func (c *EventCollector) CheckRetrievedEventsForNewsroom(pastEvents []*model.Event) ( []*model.Event, error)
CheckRetrievedEventsForNewsroom checks pastEvents for TCR events that may include new newsroom events, creates new Newsroom filterers and watchers upon valid events, filters for events, and then returns those events.
func (*EventCollector) FilterAddedMultiSigContract ¶
func (c *EventCollector) FilterAddedMultiSigContract(multiSigAddr common.Address) ([]*model.Event, error)
FilterAddedMultiSigContract runs a filterer on the newly watched multisig contract to ensure we have all events.
func (*EventCollector) FilterAddedNewsroomContract ¶
func (c *EventCollector) FilterAddedNewsroomContract(newsroomAddr common.Address) ([]*model.Event, error)
FilterAddedNewsroomContract runs a filterer on the newly watched newsroom contract to ensure we have all events.
func (*EventCollector) RemoveFilterers ¶
func (c *EventCollector) RemoveFilterers(w model.ContractFilterers) error
RemoveFilterers will remove given filterer from the embedded retriever.
func (*EventCollector) RemoveWatchers ¶
func (c *EventCollector) RemoveWatchers(w model.ContractWatchers) error
RemoveWatchers will remove given watcher from the embedded listener.
func (*EventCollector) StartChan ¶
func (c *EventCollector) StartChan() chan struct{}
StartChan returns the channel will send a "event collector started" signal
func (*EventCollector) StartCollection ¶
func (c *EventCollector) StartCollection() error
StartCollection contains logic to run retriever and listener.
func (*EventCollector) StopCollection ¶
func (c *EventCollector) StopCollection(unsubWatchers bool) error
StopCollection is for stopping the listener
type RemoveNewsroomWatchersTrigger ¶
type RemoveNewsroomWatchersTrigger struct{}
RemoveNewsroomWatchersTrigger is a Trigger that removes a new watcher for a newsroom to be delisted.
func (*RemoveNewsroomWatchersTrigger) Description ¶
func (n *RemoveNewsroomWatchersTrigger) Description() string
Description returns the description of the trigger
func (*RemoveNewsroomWatchersTrigger) Run ¶
func (n *RemoveNewsroomWatchersTrigger) Run(collector *EventCollector, event *model.Event) error
Run returns the triggered code
func (*RemoveNewsroomWatchersTrigger) ShouldRun ¶
func (n *RemoveNewsroomWatchersTrigger) ShouldRun(collector *EventCollector, event *model.Event) bool
ShouldRun returns true or false on whether this trigger should be run
type Trigger ¶
type Trigger interface { // Description returns the description of the trigger Description() string // ShouldRun returns true or false on whether this trigger should be run ShouldRun(collector *EventCollector, event *model.Event) bool // Run returns the triggered code Run(collector *EventCollector, event *model.Event) error }
Trigger is an interface for triggering code to run upon receiving an event type