lib

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var URLsParsed []string

Functions

func AppendToHistory

func AppendToHistory(metric ExecutionMetric) error

func CreateStateJSON

func CreateStateJSON(config Config) error

/////////////////////////////////////////////////////////// CREATE ///////////////////////////////////////////////////////////

func GenerateDatabaseRecords

func GenerateDatabaseRecords(config Config) ([]interface{}, error)

func GenerateFileRecords

func GenerateFileRecords(config Config) ([]interface{}, error)

func GenerateHtmlRecords

func GenerateHtmlRecords(config Config) ([]interface{}, error)

func GenerateRecordMessage

func GenerateRecordMessage(record interface{}, state *State, config Config) error

func GenerateRestRecords

func GenerateRestRecords(config Config) ([]interface{}, error)

func GenerateSchema

func GenerateSchema(records []interface{}) (map[string]interface{}, error)

/////////////////////////////////////////////////////////// GENERATE JSON SCHEMA ///////////////////////////////////////////////////////////

func GenerateSchemaMessage

func GenerateSchemaMessage(schema map[string]interface{}, config Config) error

func GenerateStateMessage

func GenerateStateMessage(state *State) error

func ProcessRecords

func ProcessRecords(records *[]interface{}, state *State, config Config) error

func StartListening

func StartListening(config Config)

func UpdateState

func UpdateState(records []interface{}, state *State, config Config) error

/////////////////////////////////////////////////////////// UPDATE ///////////////////////////////////////////////////////////

Types

type Config

type Config struct {
	StreamName *string `json:"stream_name,omitempty"`
	SourceType *string `json:"source_type,omitempty"`
	URL        *string `json:"url,omitempty"`
	Records    *struct {
		UniqueKeyPath       *[]string   `json:"unique_key_path,omitempty"`
		PrimaryBookmarkPath *[]string   `json:"primary_bookmark_path,omitempty"`
		SensitivePaths      *[][]string `json:"sensitive_paths,omitempty"`
		IntelligentFields   *[]struct {
			Prefix               *string   `json:"prefix,omitempty"`
			FieldPath            *[]string `json:"field_path,omitempty"`
			Suffix               *string   `json:"suffix,omitempty"`
			MaxTokens            *int      `json:"max_tokens,omitempty"`
			Temperature          *float32  `json:"temperature,omitempty"`
			IntelligentFieldName *string   `json:"intelligent_field_name,omitempty"`
		} `json:"intelligent_fields,omitempty"`
	} `json:"records,omitempty"`
	Database *struct {
		Table *string `json:"table,omitempty"`
	} `json:"db,omitempty"`
	Html *struct {
		ElementsPath *string `json:"elements_path,omitempty"`
		Elements     *[]struct {
			Name *string `json:"name,omitempty"`
			Path *string `json:"path,omitempty"`
		} `json:"elements,omitempty"`
	} `json:"html,omitempty"`
	Listen *struct {
		CollectionInterval *int    `json:"collection_interval,omitempty"`
		Port               *string `json:"port,omitempty"`
	}
	Rest *struct {
		Sleep *int `json:"sleep,omitempty"`
		Auth  *struct {
			Required *bool   `json:"required,omitempty"`
			Strategy *string `json:"strategy,omitempty"`
			Basic    *struct {
				Username *string `json:"username,omitempty"`
				Password *string `json:"password,omitempty"`
			} `json:"basic,omitempty"`
			Token *struct {
				Header      *string `json:"header,omitempty"`
				HeaderValue *string `json:"header_value,omitempty"`
			} `json:"token,omitempty"`
			Oauth *struct {
				ClientID     *string `json:"client_id,omitempty"`
				ClientSecret *string `json:"client_secret,omitempty"`
				RefreshToken *string `json:"refresh_token,omitempty"`
				TokenURL     *string `json:"token_url,omitempty"`
			} `json:"oauth,omitempty"`
		} `json:"auth,omitempty"`
		Response *struct {
			RecordsPath        *[]string `json:"records_path,omitempty"`
			Pagination         *bool     `json:"pagination,omitempty"`
			PaginationStrategy *string   `json:"pagination_strategy,omitempty"`
			PaginationNextPath *[]string `json:"pagination_next_path,omitempty"`
			PaginationQuery    *struct {
				QueryParameter *string `json:"query_parameter,omitempty"`
				QueryValue     *int    `json:"query_value,omitempty"`
				QueryIncrement *int    `json:"query_increment,omitempty"`
			} `json:"pagination_query,omitempty"`
		} `json:"response,omitempty"`
	} `json:"rest,omitempty"`
}

type ExecutionMetric

type ExecutionMetric struct {
	Stream            string
	ExecutionStart    time.Time
	ExecutionEnd      time.Time
	ExecutionDuration time.Duration
	RecordsExtracted  int
	RecordsProcessed  int
}

type Message

type Message struct {
	Type               string                 `json:"type"`
	Record             map[string]interface{} `json:"record,omitempty"`
	Stream             string                 `json:"stream,omitempty"`
	Schema             interface{}            `json:"schema,omitempty"`
	Value              interface{}            `json:"value,omitempty"`
	KeyProperties      []string               `json:"key_properties,omitempty"`
	BookmarkProperties []string               `json:"bookmark_properties,omitempty"`
}

type RecordStore

type RecordStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*RecordStore) AddRecord

func (rs *RecordStore) AddRecord(record interface{})

func (*RecordStore) ClearRecords

func (rs *RecordStore) ClearRecords()

func (*RecordStore) StartTimer

func (rs *RecordStore) StartTimer(config Config)

type State

type State struct {
	Type  string `json:"Type"`
	Value struct {
		Bookmarks map[string]struct {
			BookmarkUpdatedAt string   `json:"bookmark_updated_at"`
			DetectionBookmark []string `json:"detection_bookmark"`
			PrimaryBookmark   string   `json:"primary_bookmark"`
		} `json:"bookmarks"`
	} `json:"Value"`
}

func ParseStateJSON

func ParseStateJSON(config Config) (*State, error)

/////////////////////////////////////////////////////////// PARSE STATE.JSON ///////////////////////////////////////////////////////////

Jump to

Keyboard shortcuts

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