event

package
v0.0.0-...-d5b0b98 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TxStatusRunning TxStatus
	TxStatusRunning comm.TxStatus = 0
	// TxStatusPrepare
	TxStatusPrepare comm.TxStatus = 1
	// TxStatusCommit
	TxStatusCommit comm.TxStatus = 2
	// TxStatusRollback
	TxStatusRollback comm.TxStatus = 3
	// TxStatusSuccess
	TxStatusSuccess comm.TxStatus = 4

	// RetryCount is the number of times
	RetryCount = 20

	// AsyncReportEvent
	AsyncReportEvent = 0
	// AsyncCallBack
	AsyncCallBack = 1

	// CbHeartbeatTimeOut
	CbHeartbeatTimeOut = 60
	// CfHeartbeatTimeOut
	CfHeartbeatTimeOut = 60

	// CbExpire
	CbExpire = -60 * 5

	// TimeStrFormat
	TimeStrFormat = "2006-01-02 15:04:05"

	// PeriodLimit
	PeriodLimit = 10

	// CbCfTypeConfigParam
	CbCfTypeConfigParam CbCfType = 1
	// CbCfTypeConfigPlatform
	CbCfTypeConfigPlatform CbCfType = 2

	// CbCfTypeConfig
	DefaultCbTimeout = 5000
	// DefaultCbInterval
	DefaultCbInterval = 1000 * 60 * 2
)
View Source
const (
	DSNKey = "%v:%v@tcp(%v)/%v?charset=%v&parseTime=True&loc=Local"
)
View Source
const (
	KeyBrokerTopic = "%v%v_%v"
)

Variables

This section is empty.

Functions

func BrokerTopicKey

func BrokerTopicKey(topicPrefix string, appID string, topicID string) string

BrokerTopicKey returns the broker topic

func KeyDSN

func KeyDSN(addr, userName, password, dataBase, charset string) string

KeyDSN returns dsn

func KeyProducerConf

func KeyProducerConf(appID, topicID string) string

KeyProducerConf returns the key of producer group

Types

type CbCfType

type CbCfType int

type DB

type DB struct {

	// Engine is the name of the database
	Engine *gorm.DB
	// contains filtered or unexported fields
}

DB is type of store

func NewDB

func NewDB(c *options.DBConfig) (*DB, error)

NewDB create new db

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event include loops, delays, transactions, and real-time events

func New

func New(opts *options.Options) (*Event, error)

New creates an Event

func (*Event) Commit

func (s *Event) Commit(ctx context.Context, req interface{}) (interface{}, error)

Commit is used to commit a transaction message to the server

func (*Event) InternalHandler

func (s *Event) InternalHandler(ctx context.Context, req interface{}) (interface{}, error)

InternalHandler is used to handle internal messages

func (*Event) Prepare

func (s *Event) Prepare(ctx context.Context, req interface{}) (interface{}, error)

Prepare is used to prepare a transaction message to the server

func (*Event) Report

func (s *Event) Report(ctx context.Context, req interface{}) (interface{}, error)

Report is used to report events to the server

func (*Event) Rollback

func (s *Event) Rollback(ctx context.Context, req interface{}) (interface{}, error)

Rollback is used to roll back a transaction message to the server

func (*Event) Stop

func (s *Event) Stop() error

Stop stops the event gracefully.

type GormLogger

type GormLogger struct{}

func (GormLogger) Error

func (GormLogger) Error(ctx context.Context, s string, i ...interface{})

func (GormLogger) Info

func (GormLogger) Info(ctx context.Context, s string, i ...interface{})

func (GormLogger) LogMode

func (GormLogger) LogMode(level logger.LogLevel) logger.Interface

func (GormLogger) Trace

func (GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (GormLogger) Warn

func (GormLogger) Warn(ctx context.Context, s string, i ...interface{})

type Handler

type Handler struct {
	// DelayConnector is the name of the delay connector
	DelayConnector connector.Connector
	// RealTimeConnector is the name of the real time connector
	RealTimeConnector connector.Connector
	// BizNO is the name of the biz number
	BizNO bizno.Pool
}

Handler is the handler for events

func (*Handler) SendMsg

func (s *Handler) SendMsg(ctx context.Context, brokerTopic string, delayTime time.Duration, orderingKey string, msg []byte) error

SendMsg is the stores that send events

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

Transaction is a way of handling an event

func NewTransaction

func NewTransaction(txConfig *options.TransactionConfig,
	handler *Handler, confInfoList []*cc.ProducerConfInfo) (*Transaction, error)

NewTransaction creates a new transaction

func (*Transaction) AsyncReportEvent

func (s *Transaction) AsyncReportEvent(args interface{})

AsyncReportEvent is used to report events

func (*Transaction) CallBack

func (s *Transaction) CallBack(ctx context.Context, req interface{}) (interface{}, error)

CallBack is used to call back

func (*Transaction) CallBackInternal

func (s *Transaction) CallBackInternal(ctx context.Context, msg *define.TxEventMsg) error

CallBackInternal

func (*Transaction) Commit

func (s *Transaction) Commit(ctx context.Context, req *define.CommitReq) (*comm.Tx, error)

Commit is used to commit a transaction

func (*Transaction) Prepare

func (s *Transaction) Prepare(ctx context.Context, req *define.PrepareReq) (string, error)

Prepare is used to prepare a transaction

func (*Transaction) Rollback

func (s *Transaction) Rollback(ctx context.Context, req *define.RollbackReq) (*comm.Tx, error)

Rollback is used rollback the transaction

func (*Transaction) Run

func (s *Transaction) Run() error

Run is used to run the transaction

func (*Transaction) SendCallBackDelayMsg

func (s *Transaction) SendCallBackDelayMsg(msg *define.TxEventMsg)

SendCallBackDelayMsg is used to send a delay message

func (*Transaction) SetProducerConfList

func (s *Transaction) SetProducerConfList(confInfoList []*cc.ProducerConfInfo)

SetProducerConfList is used to set the list of producers

func (*Transaction) Stop

func (s *Transaction) Stop() error

Stop stops the transaction gracefully.

func (*Transaction) WatchProducerConf

func (s *Transaction) WatchProducerConf(c *cc.ProducerConfInfo, eventType int32) error

WatchProducerConf is used to watch producer configuration

Directories

Path Synopsis
Code generated by sql2gorm.
Code generated by sql2gorm.

Jump to

Keyboard shortcuts

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