visitor

package
v0.0.0-...-f80b70b Latest Latest
Warning

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

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

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acker

type Acker interface {
	Ack()
	Nack()
}

Acker is for QoS.

type AutoAckMessage

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

func (*AutoAckMessage) Do

func (a *AutoAckMessage) Do(doFunc DoFunc) error

type DelayActor

type DelayActor struct {
	*timingwheel.TimingWheel
	time.Duration
	// contains filtered or unexported fields
}

DelayActor take an timingwheel and use it for its own delay setting.

func NewDelayActor

func NewDelayActor(msg Visitor, timingWheel *timingwheel.TimingWheel) *DelayActor

func (DelayActor) Do

func (d DelayActor) Do(doFunc DoFunc) error

type DoFunc

type DoFunc func(ctx context.Context, request interface{}) (err error)

type FailedHandler

type FailedHandler struct {
	CallTimes int
	MaxTimes  int
}

func (*FailedHandler) FailedDo

func (fh *FailedHandler) FailedDo(context.Context, interface{}) error

type Middleware

type Middleware func(Visitor) Visitor

Below middleware code from go-kit visitor. https://github.com/go-kit/kit/blob/master/endpoint/endpoint.go

func Chain

func Chain(outer Middleware, others ...Middleware) Middleware

Chain is a helper function for composing middlewares. Requests will traverse them in the order they're declared. That is, the first middleware is treated as the outermost middleware.

func WithRetry

func WithRetry(retryTimes int) Middleware

type NameVisitor

type NameVisitor struct {
	Name string
}

func (*NameVisitor) Do

func (nop *NameVisitor) Do(fn DoFunc) error

type RetryActor

type RetryActor struct {
	*retry.Params
	// contains filtered or unexported fields
}
Example
Actor := NewRetryMessage(&Message{})
// Publish: warning: this publisher only pub protocol to stdout, so example does not work in real world.
publish := func(ctx context.Context, r interface{}) error {
	log.Println("this pre log to console: ", ctx, r)
	defer log.Println("this post log to console: ", ctx, r)
	return nil
}

err := Actor.Do(publish)
log.Println(err)

func NewRetryMessage

func NewRetryMessage(msg Visitor) *RetryActor

func (*RetryActor) Do

func (m *RetryActor) Do(fn DoFunc) error

func (*RetryActor) NoRetry

func (m *RetryActor) NoRetry(err error) bool

IfRetry(err), when err == nil, not retry is true. Then check for m.noRetryErr slice. If you set error no need to retry.

type Visitor

type Visitor interface {
	Do(DoFunc) error
}
Example
var m Message
// warning: this publisher only pub protocol to console, so example does not work in real world.
var p = &ExampleImplPublisher{}

err := m.Do(p.Publish)
log.Println("err is ", err)

Jump to

Keyboard shortcuts

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