connector

package
v0.0.0-...-7cc5f39 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector interface {
	// Sync is a request for a sync with Fivetran, the response should contain the (partial) sync
	Sync(ctx context.Context, req *Request) (*Response, error)
}

Connector is translates Fivetran sync requests to actual data See also: https://fivetran.com/docs/functions#architecture

func NewConnector

func NewConnector(tables []TableConnector) (Connector, error)

NewConnector creates a new fivetran connector with the given tables and their respective connector

type Request

type Request struct {
	Agent   string  `json:"agent"`
	State   State   `json:"state"`
	Secrets Secrets `json:"secrets"`
}

Request from Fivetran as describe here: https://fivetran.com/docs/functions#requestformat

func NewRequest

func NewRequest() *Request

type Response

type Response struct {
	State   State                           `json:"state"`
	Insert  ResponseInserts                 `json:"insert"`
	Delete  ResponseDeletes                 `json:"delete"`
	Schema  map[string]*ResponseTableSchema `json:"schema"`
	HasMore bool                            `json:"hasMore"`
}

Response to Fivetran as described here https://fivetran.com/docs/functions#responseformat

func NewResponse

func NewResponse() *Response

type ResponseDeletes

type ResponseDeletes map[string][]any

type ResponseInserts

type ResponseInserts map[string][]any

type ResponseTableSchema

type ResponseTableSchema struct {
	PrimaryKey []string `json:"primary_key"`
}

type Secrets

type Secrets map[string]string

type State

type State map[string]string

type Table

type Table struct {
	// Name the name of the table
	Name string

	// State opaque string to represent the current 'state' of the sync, usually a database cursor
	State string

	// PrimaryKey the list of primary keys used for updates and deletes
	PrimaryKey []string

	// InsertRows additional rows to insert or update
	InsertRows []any

	// DeleteRows rows to mark deleted, providing just the id column suffices
	DeleteRows []any

	// HasMore whether the connector could provide more data or all is synced
	HasMore bool
}

Table represents a single synced table

type TableConnector

type TableConnector interface {
	// Name the name of the table
	Name() string

	// Sync synchronizes a table, starting from a previous state and returning the new data
	// as well as an updated state
	Sync(ctx context.Context, state string, secrets map[string]string) (*Table, error)
}

TableConnector is the connector for a single table

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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