Documentation
¶
Index ¶
- Variables
- func IsNotFoundErr(err error) bool
- func NewDefaultLogger(endpoint, id string) *defaultLogger
- func NewLogUploader(ctx context.Context, endpoint string) (*logUploader, error)
- type AckOptionFunc
- type BackOffFunc
- type Config
- type Content
- type DefaultWorker
- type EventID
- type LogCloser
- type Logger
- type Message
- type Metadata
- type NullLogCloser
- type OptionFunc
- func CustomEnvironment(ravenURL, flowID, workerID string) OptionFunc
- func DefaultEnvironment() OptionFunc
- func WithBackOff(fn BackOffFunc) OptionFunc
- func WithCloser(closer io.Closer) OptionFunc
- func WithConsumeTimeout(s string) OptionFunc
- func WithFlowID(s string) (OptionFunc, error)
- func WithLogger(l Logger) (OptionFunc, error)
- func WithMaxIntake(num string) OptionFunc
- func WithRavenURL(urlStr string) (OptionFunc, error)
- func WithWorkerID(s string) (OptionFunc, error)
- type Reference
- type Worker
Constants ¶
This section is empty.
Variables ¶
var DefaultLogger = NewDefaultLogger(os.Getenv("RAVEN_LOG"), os.Getenv("WORKER_ID"))
var EmptyMessage = Message{}
Functions ¶
func IsNotFoundErr ¶ added in v0.2.2
func NewDefaultLogger ¶ added in v0.2.3
func NewDefaultLogger(endpoint, id string) *defaultLogger
NewDefaultLogger creates a JSON logger which outputs to an http endpoint. provide an empty string as endpoint to log to stdout.
Types ¶
type AckOptionFunc ¶ added in v0.2.2
type AckOptionFunc func(r *ackRequest) error
func WithFilter ¶ added in v0.2.2
func WithFilter() AckOptionFunc
WithFilter will keep the flow from processing further.
func WithMessage ¶ added in v0.2.2
func WithMessage(message Message) AckOptionFunc
WithFilter will keep the flow from processing further.
type BackOffFunc ¶ added in v0.2.2
type Content ¶ added in v0.2.2
type Content []byte
func JsonContent ¶ added in v0.2.2
func JsonContent(v interface{}) Content
func StringContent ¶ added in v0.2.2
type DefaultWorker ¶ added in v0.2.2
type DefaultWorker struct {
Config
// contains filtered or unexported fields
}
func (*DefaultWorker) Ack ¶ added in v0.2.2
func (c *DefaultWorker) Ack(ref Reference, options ...AckOptionFunc) error
Ack will acknowledge the message, only consumed messages are allowed.
WithFilter() will filter further processing
func (*DefaultWorker) Close ¶ added in v0.2.3
func (w *DefaultWorker) Close() error
func (*DefaultWorker) Consume ¶ added in v0.2.2
func (c *DefaultWorker) Consume(ctx context.Context) (Reference, error)
Consume retrieves a message from workflow. When there are no messages available, it will retry with a constant interval.
Messages can be retrieved by using Get(message)
Messages can be acknowledged by using Ack(ref)
ref, err := w.Consume()
if err !=nil {
panic(err)
}
message, err := w.Get(ref)
if err !=nil {
panic(err)
}
err := w.Ack(*message)
if err !=nil {
panic(err)
}
Use this function for the 'transform' and 'load' worker types. blocks until it receives a message or 'consumeTimeout' expires.
func (*DefaultWorker) Get ¶ added in v0.2.2
func (c *DefaultWorker) Get(ref Reference) (Message, error)
Get will retrieve the event for reference.
msg, err := Get(ref)
if err != nil {
// handle error
}
func (*DefaultWorker) Produce ¶ added in v0.2.2
func (c *DefaultWorker) Produce(message Message) error
Produce will store a new message in the queue. If an error occurs it will retry using exponential backoff strategy.
message := NewMessage()
.Content([]byte("test"))
err := w.Produce(message)
if err != nil {
panic (err)
}
type Message ¶
func NewMessage ¶ added in v0.2.2
func NewMessage() Message
NewMessage will return a new empty Message struct
message := NewMessage()
func (Message) MarshalJSON ¶ added in v0.2.2
func (*Message) UnmarshalJSON ¶ added in v0.2.2
type NullLogCloser ¶ added in v0.2.3
type NullLogCloser struct {
}
func (NullLogCloser) Close ¶ added in v0.2.3
func (NullLogCloser) Close() error
type OptionFunc ¶ added in v0.2.2
func CustomEnvironment ¶ added in v0.2.2
func CustomEnvironment(ravenURL, flowID, workerID string) OptionFunc
CustomEnvironment returns the optionFunc and takes 'ravenURL', 'flowID' and 'workerID' as string arguments.
func DefaultEnvironment ¶ added in v0.2.2
func DefaultEnvironment() OptionFunc
DefaultEnvironment returns the optionFunc that expects 'RAVEN_URL', 'FLOW_ID' and 'WORKER_ID' as environmental variables 'CONSUME_TIMEOUT' will override the default if set. DefaultLogger is set as the logger.
func WithBackOff ¶ added in v0.2.2
func WithBackOff(fn BackOffFunc) OptionFunc
func WithCloser ¶ added in v0.2.3
func WithCloser(closer io.Closer) OptionFunc
WithCloser adds an 'io.Closer' to the list.
func WithConsumeTimeout ¶ added in v0.2.3
func WithConsumeTimeout(s string) OptionFunc
WithConsumeTimeout time frame to wait for a new message. not setting this equals wait forever.
func WithFlowID ¶ added in v0.2.2
func WithFlowID(s string) (OptionFunc, error)
func WithLogger ¶ added in v0.2.2
func WithLogger(l Logger) (OptionFunc, error)
func WithMaxIntake ¶ added in v0.2.3
func WithMaxIntake(num string) OptionFunc
WithMaxIntake ingest messages until maxIntake is reached.
func WithRavenURL ¶ added in v0.2.2
func WithRavenURL(urlStr string) (OptionFunc, error)
func WithWorkerID ¶ added in v0.2.2
func WithWorkerID(s string) (OptionFunc, error)
type Worker ¶ added in v0.2.2
type Worker interface {
Consume(ctx context.Context) (Reference, error)
Get(Reference) (Message, error)
Ack(Reference, ...AckOptionFunc) error
Produce(Message) error
Close() error
}
func New ¶ added in v0.2.2
func New(opts ...OptionFunc) (Worker, error)
New returns a new configured Raven Worker client