emitter

package
v0.0.0-...-c22a57c Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmitIntervalDefault = 1
)

Variables

View Source
var (
	EmitQueue chan EmitObject

	AssetIds    map[string]string
	AssetIdLock sync.RWMutex
)

Functions

func EmitChanges

func EmitChanges(emission Emission)

EmitChanges sends a json payload of cluster changes to a remote endpoint

func EmitChangesSQS

func EmitChangesSQS(emission Emission) error

EmitChangesSQS sends batches of records to SQS at between 1 to 10 at a time.

func EmitChangesVRO

func EmitChangesVRO(emission Emission)

EmitChangesVRO sends a json string payload of cluster changes to a vRO remote endpoint

func SetAssetIds

func SetAssetIds(resources []config.Resource)

SetAssetIds accepts a config.Resource that will be used to determine the assetIds that will need to be included when emitting objects.

func StartEmitter

func StartEmitter(c config.Config, q chan EmitObject)

StartEmitter sets up the emiter based on the configuration provided. If sqs is used, it'll initialize an SQS client used for publishing records to remote queues. It is responsible for polling the emit queue and sending records up to AWS.

func WasEmitted

func WasEmitted(obj EmitObject) bool

WasEmitted looks up an object based on its payload's hash. It returns true if the object was sent previously (is considered duplicate) and false if it was never sent before.

Types

type Emission

type Emission struct {
	Svc           *sqs.SQS
	SqsUrl        string
	HttpUrl       string
	EmitType      string
	Client        http.Client
	Username      string
	Password      string
	Namespaces    []string
	Types         []string
	EmittableList []EmitObject
}

type EmitObject

type EmitObject struct {
	Payload   map[string]interface{}
	ObjType   string
	Key       string
	UID       string
	EventType string
}

type PayloadRoot

type PayloadRoot struct {
	Data     []Wrapper              `json:"data"`
	Metadata map[string]interface{} `json:"meta"`
}

type Wrapper

type Wrapper struct {
	AssetID   string                 `json:"asset_type_id"`
	Data      map[string]interface{} `json:"data"`
	UID       string                 `json:"uniqueId"`
	EventType string                 `json:"event"`
}

Jump to

Keyboard shortcuts

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