kinesis

package
v0.0.0-...-0820d52 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Source        string      `json:"src"`
	TimestampNano int64       `json:"tsn,string"`
	IsTest        bool        `json:"tst,omitempty"`
	UserID        int64       `json:"uid,omitempty"`
	UserUUID      string      `json:"uuid,omitempty"`
	MerchantID    int64       `json:"mid,omitempty"`
	UserName      string      `json:"scuid,omitempty"`
	HTTPData      *HTTPData   `json:"http,omitempty"`
	EventData     interface{} `json:"ed,omitempty"`
}

Event is generic structure for Kinesis event

func NewEvent

func NewEvent() *Event

NewEvent creates an instance of event

func (*Event) WithHTTPRequest

func (e *Event) WithHTTPRequest(r *http.Request) *Event

WithHTTPRequest enriches event with the HTTP request data (like client IP address)

func (*Event) WithIsTest

func (e *Event) WithIsTest(isTest bool) *Event

WithIsTest assigns isTest.

func (*Event) WithUserIDs

func (e *Event) WithUserIDs(userID int64, userUUID strfmt.UUID) *Event

WithUserIDs assigns User ID and UUID.

type EventData

type EventData struct {
	Type        EventType   `json:"type"`
	Successful  bool        `json:"ok"`
	ContextData interface{} `json:"data,omitempty"`
}

EventData holds server event data.

func NewEventData

func NewEventData(t EventType) *EventData

NewEventData creates an instance of EventData.

func (*EventData) MarkAsSuccessful

func (e *EventData) MarkAsSuccessful() *EventData

MarkAsSuccessful marks event as successful.

func (*EventData) WithContextData

func (e *EventData) WithContextData(data interface{}) *EventData

WithContextData assigns data and returns modified server event.

type EventPutter

type EventPutter interface {
	Put(e *Event) (err error)
}

EventPutter is an interface to put events into some processing pipeline

type EventType

type EventType string

EventType is a type for server event.

func (EventType) String

func (t EventType) String() string

type HTTPData

type HTTPData struct {
	ClientIP        string `json:"ip,omitempty"`
	ClientIPCountry string `json:"co,omitempty"`
	UserAgent       string `json:"ua,omitempty"`
}

HTTPData contains data from HTTP request

type LogPutter

type LogPutter struct{}

LogPutter puts all record to log

func NewLogPutter

func NewLogPutter() LogPutter

NewLogPutter creates new instance of LogPutter

func (LogPutter) Put

func (LogPutter) Put(e *Event) (err error)

Put puts event asynchronously to stream. This method is thread-safe.

type MetricsPutter

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

MetricsPutter wraps putter and adds metrics

func AddEventPutterMetrics

func AddEventPutterMetrics(p EventPutter, r *metrics.Registry) *MetricsPutter

AddEventPutterMetrics adds metrics by wrapping handler

func (*MetricsPutter) Put

func (p *MetricsPutter) Put(e *Event) (err error)

Put puts event asynchronously to stream. This method is thread-safe.

type PutterConfig

type PutterConfig struct {
	AwsAccessKey string
	AwsSecretKey string
	AwsRegion    string
	StreamName   string
}

PutterConfig is a configuration for Kinesis putter

type StreamPutter

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

StreamPutter simplifies putting records to Amazon Kinesis

func NewStreamPutter

func NewStreamPutter(cfg PutterConfig) (*StreamPutter, error)

NewStreamPutter creates a new instance of StreamPutter using provided `cfg` (configuration).

func (*StreamPutter) Close

func (p *StreamPutter) Close() error

Close implements io.Closer interface

func (*StreamPutter) Put

func (p *StreamPutter) Put(e *Event) (err error)

Put puts event asynchronously to stream. This method is thread-safe.

Directories

Path Synopsis
Package producer is a generated protocol buffer package.
Package producer is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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