edp

package
v0.0.0-...-f99419a Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventInvalidRequest    = errors.New("invalid request")                                     // 400
	ErrEventMissingParameters = errors.New("namespace, dataStream or dataTenant not found")       // 404
	ErrEventPayloadTooLarge   = errors.New("payload too large, maximum allowed data size is 1MB") // 413
	ErrEventUnknown           = errors.New("unknown error")
	ErrEventMarshal           = errors.New("marshal error")
	ErrEventHTTPRequest       = errors.New("HTTP request error")
)

Functions

This section is empty.

Types

type Client

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

Client has all the context and parameters needed to run a EDP worker pool.

func NewClient

func NewClient(c *Config, httpClient *http.Client, eventsChannel <-chan *Event, logger log.Logger) *Client

NewClient constructs a EDP client from the provided config.

func (*Client) Start

func (c *Client) Start(ctx context.Context)

Start starts worker processes, which wait for event to process from the queue.

func (*Client) Write

func (c *Client) Write(parentctx context.Context, event *Event, logger log.Logger) error

Write sends events(json) to EDP server.

type Config

type Config struct {
	URL               string        `kong:"help='EDP base URL',env='EDP_URL',default='https://input.yevents.io',required=true"`
	Token             string        `kong:"help='EDP source token',placeholder='SECRET',env='EDP_TOKEN',required=true"`
	Namespace         string        `kong:"help='EDP Namespace',env='EDP_NAMESPACE',required=true"`
	DataStream        string        `kong:"help='EDP data stream name',env='EDP_DATASTREAM_NAME',required=true"`
	DataStreamVersion string        `kong:"help='EDP data stream version',env='EDP_DATASTREAM_VERSION',required=true"`
	DataStreamEnv     string        `kong:"help='EDP data stream environment',env='EDP_DATASTREAM_ENV',required=true"`
	Timeout           time.Duration `kong:"help='Time limit for requests made by the EDP client',env='EDP_TIMEOUT',required=true,default='30s'"`
	Buffer            int           `kong:"help='Number of events that the buffer can have.',env='EDP_BUFFER',required=true,default=100"`
	Workers           int           `kong:"help='Number of workers to send metrics.',env='EDP_WORKERS',required=true,default=5"`
	EventRetry        int           `kong:"help='Number of retries for sending event.',env='EDP_RETRY',required=true,default=5"`
}

Config holds EDP clients configuration.

type Event

type Event struct {
	// Datatenant defines the tenant the event belongs to.
	Datatenant string

	// Data represent the provider specific event details in raw json, to delay json decoding.
	Data *json.RawMessage
}

Event has the information needed to send an event to EDP.

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

MarshalJSON is a helper function to marshal custom provider data and add timestamp field.

Jump to

Keyboard shortcuts

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