event

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OverID = "_OVER_" // 事件结束 ID
)

Variables

View Source
var (
	ErrPublisherNotFound = errors.New("publisher not found")
)

Functions

func RegisterPublisher

func RegisterPublisher(name string, pub Publisher)

Types

type Event

type Event struct {
	ID         string                 `json:"id"`
	Schema     string                 `json:"schema"`
	Table      string                 `json:"table"`
	Action     string                 `json:"action"`
	Data       map[string]interface{} `json:"data"`
	CommitTime time.Time              `json:"commit_time"`
}

Event event structure for publishing to the NATS server.

func (Event) GetSubject

func (e Event) GetSubject(prefix string) string

GetSubject creates subject name from the prefix, schema and table name.

func (Event) IsOver added in v0.2.0

func (e Event) IsOver() bool

IsOver 判断是否是结束事件

func (Event) MarshalEasyJSON

func (v Event) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Event) MarshalJSON

func (v Event) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Event) UnmarshalEasyJSON

func (v *Event) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Event) UnmarshalJSON

func (v *Event) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Publisher

type Publisher interface {
	Publish(subject string, evt *Event) error
	Close() error
}

Publisher 事件发布接口

func GetPublisher

func GetPublisher(name string) (Publisher, error)

Directories

Path Synopsis
publisher

Jump to

Keyboard shortcuts

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