Documentation
¶
Index ¶
- Constants
- func HandleEvent(ctx context.Context, eventDataChan chan eventbus.DataEvent, ...) <-chan eventbus.Topic
- type DefaultEventHandler
- func (b *DefaultEventHandler) HandleDelete(payload string) (interface{}, error)
- func (b *DefaultEventHandler) HandleInsert(payload string) (interface{}, error)
- func (b *DefaultEventHandler) HandleUpdate(payload string) (interface{}, error)
- func (b *DefaultEventHandler) HandlerUnknownOperation(payload string) (interface{}, error)
- func (b *DefaultEventHandler) Name() string
- type EventHandler
- type PostgresPubSub
- type PostgresPubSubConfig
Constants ¶
View Source
const ( PG_INSERT_OP = "INSERT" PG_UPDATE_OP = "UPDATE" PG_DELETE_OP = "DELETE" )
* Descreve as operações
Variables ¶
This section is empty.
Functions ¶
func HandleEvent ¶
func HandleEvent(ctx context.Context, eventDataChan chan eventbus.DataEvent, l *zap.SugaredLogger, evHandler EventHandler) <-chan eventbus.Topic
Types ¶
type DefaultEventHandler ¶
type DefaultEventHandler struct{}
DefaultEventHandler implementa gopostgrespubsub.EventHandler e por padrão é o handler do topico `event`.
Como usar: Use a Composição em Golang e sobreescreva o metodo Name() padrão pelo seu metodo Name().
type MyEventHandler struct { gopostgrespubsub.DefaultEventHandler // composition }
func (myEventHandler *MyEventHandler) Name() string { return "anothertopic" }
check if the type satisfies the interface `gopostgrespubsub.EventHandler` var _ gopostgrespubsub.EventHandler = (*MyEventHandler)(nil)
func (*DefaultEventHandler) HandleDelete ¶
func (b *DefaultEventHandler) HandleDelete(payload string) (interface{}, error)
func (*DefaultEventHandler) HandleInsert ¶
func (b *DefaultEventHandler) HandleInsert(payload string) (interface{}, error)
func (*DefaultEventHandler) HandleUpdate ¶
func (b *DefaultEventHandler) HandleUpdate(payload string) (interface{}, error)
func (*DefaultEventHandler) HandlerUnknownOperation ¶
func (b *DefaultEventHandler) HandlerUnknownOperation(payload string) (interface{}, error)
func (*DefaultEventHandler) Name ¶
func (b *DefaultEventHandler) Name() string
type EventHandler ¶
type EventHandler interface { Name() string // O nome retornado é o nome da tabela que é também o nome do topico // HandleInsert recebe uma string json do tipo chave=coluna_tabela e valor=valor_coluna_tabela HandleInsert(string) (interface{}, error) // HandleUpdate recebe uma string json do tipo chave=coluna_tabela e valor=valor_coluna_tabela HandleUpdate(string) (interface{}, error) // HandleDelete recebe uma string json do tipo chave=coluna_tabela e valor=valor_coluna_tabela HandleDelete(string) (interface{}, error) // HandlerUnknownOperation recebe uma string json do tipo chave=coluna_tabela e valor=valor_coluna_tabela HandlerUnknownOperation(string) (interface{}, error) }
EventHandler é uma interface que deve ser atendida para acessar os triggers
type PostgresPubSub ¶
func NewPostgresPubSub ¶
func NewPostgresPubSub(ctx context.Context, config PostgresPubSubConfig) (PostgresPubSub, error)
type PostgresPubSubConfig ¶
Click to show internal directories.
Click to hide internal directories.