transformer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserTransformerStage = "user_transformer"
	DestTransformerStage = "dest_transformer"
)

Variables

This section is empty.

Functions

func GetVersion

func GetVersion() (transformerBuildVersion string)

GetVersion gets the transformer version by asking it on /transfomerBuildVersion. if there is any error it returns empty string

Types

type HandleT

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

HandleT is the handle for this class

func NewTransformer

func NewTransformer() *HandleT

NewTransformer creates a new transformer

func (*HandleT) Setup

func (trans *HandleT) Setup()

Setup initializes this class

func (*HandleT) Transform

func (trans *HandleT) Transform(clientEvents []TransformerEventT,
	url string, batchSize int) ResponseT

Transform function is used to invoke transformer API Transformer is not thread safe. If performance becomes an issue we can create multiple transformer instances but given that they are hitting the same NodeJS process it may not be an issue if batch sizes (len clientEvents) are big enough to saturate NodeJS. Right now the transformer instance is shared between both user specific transformation code and destination transformation code.

type MetadataT

type MetadataT struct {
	SourceID        string `json:"sourceId"`
	WorkspaceID     string `json:"workspaceId"`
	Namespace       string `json:"namespace"`
	InstanceID      string `json:"instanceId"`
	SourceType      string `json:"sourceType"`
	SourceCategory  string `json:"sourceCategory"`
	DestinationID   string `json:"destinationId"`
	JobRunID        string `json: "jobRunId"`
	JobID           int64  `json:"jobId"`
	SourceBatchID   string `json:"sourceBatchId"`
	SourceJobID     string `json:"sourceJobId"`
	SourceJobRunID  string `json:"sourceJobRunId"`
	SourceTaskID    string `json:"sourceTaskId"`
	SourceTaskRunID string `json:"sourceTaskRunId"`
	DestinationType string `json:"destinationType"`
	MessageID       string `json:"messageId"`
	// set by user_transformer to indicate transformed event is part of group indicated by messageIDs
	MessageIDs []string `json:"messageIds"`
	RudderID   string   `json:"rudderId"`
	SessionID  string   `json:"sessionId,omitempty"`
	ReceivedAt string   `json:"receivedAt"`
	EventName  string   `json:"eventName"`
	EventType  string   `json:"eventType"`
}

type ResponseT

type ResponseT struct {
	Events       []TransformerResponseT
	FailedEvents []TransformerResponseT
}

ResponseT represents a Transformer response

type Transformer

type Transformer interface {
	Setup()
	Transform(clientEvents []TransformerEventT, url string, batchSize int) ResponseT
}

Transformer provides methods to transform events

type TransformerEventT

type TransformerEventT struct {
	Message     types.SingularEventT       `json:"message"`
	Metadata    MetadataT                  `json:"metadata"`
	Destination backendconfig.DestinationT `json:"destination"`
	SessionID   string                     `json:"session_id,omitempty"`
	Libraries   []backendconfig.LibraryT   `json:"libraries"`
}

type TransformerResponseT

type TransformerResponseT struct {
	// Not marking this Singular Event, since this not a RudderEvent
	Output     map[string]interface{} `json:"output"`
	Metadata   MetadataT              `json:"metadata"`
	StatusCode int                    `json:"statusCode"`
	Error      string                 `json:"error"`
}

Jump to

Keyboard shortcuts

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