railgun

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 消息正常处理
	MsgPolicyNormal = MsgPolicy(0)
	// 忽略此消息 后续不再处理
	MsgPolicyIgnore = MsgPolicy(1)
	// 有限重试
	MsgPolicyAttempts = MsgPolicy(2)
	// 无限重试
	MsgPolicyRetryInfinite = MsgPolicy(3)
	// 标记失败 不重试
	MsgPolicyFailure = MsgPolicy(4)
)

Variables

This section is empty.

Functions

func ConsumeWorkerOption

func ConsumeWorkerOption(worker int) func(r *Railgun)

func NewMessage

func NewMessage(ctx context.Context, traceName string, data []byte) (m *message)

Types

type Config

type Config struct {
	// quota 限流资源id 数据源获取到数据后,卡在发送到下游处理之前的限制
	QuotaID string
}

type CronDoFunc

type CronDoFunc func(ctx context.Context) MsgPolicy

处理的业务逻辑

type CronInputer

type CronInputer struct {
	*ManualInputer
	// contains filtered or unexported fields
}

func NewCronInputer

func NewCronInputer(cfg *CronInputerConfig) *CronInputer

type CronInputerConfig

type CronInputerConfig struct {
	/*
			doc: https://github.com/robfig/cron/blob/v1/doc.go

			Field name   | Mandatory? | Allowed values  | Allowed special characters
			----------   | ---------- | --------------  | --------------------------
			Seconds      | Yes        | 0-59            | * / , -
			Minutes      | Yes        | 0-59            | * / , -
			Hours        | Yes        | 0-23            | * / , -
			Day of month | Yes        | 1-31            | * / , - ?
			Month        | Yes        | 1-12 or JAN-DEC | * / , -
			Day of week  | Yes        | 0-6 or SUN-SAT  | * / , - ?

			Entry                  | Description                                | Equivalent To
			-----                  | -----------                                | -------------
			@yearly (or @annually) | Run once a year, midnight, Jan. 1st        | 0 0 0 1 1 *
			@monthly               | Run once a month, midnight, first of month | 0 0 0 1 * *
			@weekly                | Run once a week, midnight between Sat/Sun  | 0 0 0 * * 0
			@daily (or @midnight)  | Run once a day, midnight                   | 0 0 0 * * *
			@hourly                | Run once an hour, beginning of hour        | 0 0 * * * *

		   example:
			@every 5m
			@every 1h30m
	*/
	Spec string
}

type CronProcessor

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

func NewCronProcessor

func NewCronProcessor(config *CronProcessorConfig, do CronDoFunc, opts ...func(*CronProcessor)) (res *CronProcessor)

流程: 定时任务触发处理流程

type CronProcessorConfig

type CronProcessorConfig struct {
	// 上次事件没处理结束的话 是否可以并发执行
	Parallel bool
	// 重试次数
	Attempts int
}

type CronUniqConfig

type CronUniqConfig struct {
}

type Inputer

type Inputer interface {
}

type ManualInputer

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

func NewManualInputer

func NewManualInputer(cfg *ManualInputerConfig) *ManualInputer

func (*ManualInputer) Add

func (d *ManualInputer) Add(ctx context.Context, data []byte) (err error)

func (*ManualInputer) AwesomeRailgun

func (*ManualInputer) AwesomeRailgun()

type ManualInputerConfig

type ManualInputerConfig struct {
	Buffer int
}

type Message

type Message interface {
	Payload() []byte
	Raw() interface{}
}

type MsgPolicy

type MsgPolicy int

func (MsgPolicy) String

func (m MsgPolicy) String() string

type PrivateMessage

type PrivateMessage interface {
	Message
	Ack(err error)
	Context() context.Context
}

type Railgun

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

func NewRailGun

func NewRailGun(name string, cfg *Config, ipt Inputer, processor processor, opts ...func(*Railgun)) *Railgun

func (*Railgun) Close

func (r *Railgun) Close()

func (*Railgun) Start

func (r *Railgun) Start()

Jump to

Keyboard shortcuts

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