schema

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MPL-2.0 Imports: 26 Imported by: 366

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

View Source
var (
	ErrorColumnNotEnough = errors.New("column not enough!")

	ErrorRowNotEnough = errors.New("row not enough!")

	ErrorColumnAlreadyExists = errors.New("Column already exists")

	ErrorColumnNotExists = errors.New("column not exists")
)
View Source
var DefaultWorkerNum uint64 = 100

DefaultWorkerNum The default number of threads when the number of worker threads is not specified

Functions ¶

func GetMemoryUsage ¶ added in v0.0.23

func GetMemoryUsage() int

func NewClientMetaRuntime ¶

func NewClientMetaRuntime(ctx context.Context, workspace, providerName, providerVersion string, myClientMeta *ClientMeta, providerConfigViper *viper.Viper, isRunUserMetaInit bool) (runtime *ClientMetaRuntime, diagnostics *Diagnostics)

func NewDataSourcePullExecutor ¶

func NewDataSourcePullExecutor(workerNum uint64, clientMeta *ClientMeta, errorsHandlerMeta *ErrorsHandlerMeta) (*DataSourceExecutor, *Diagnostics)

NewDataSourcePullExecutor Create a data source data pull actuator @params: workerNum Number of working coroutines @wg: Concurrency control

Types ¶

type ClientLogger ¶

type ClientLogger interface {
	Debug(msg string, fields ...zap.Field)
	DebugF(msg string, args ...any)

	Info(msg string, fields ...zap.Field)
	InfoF(msg string, args ...any)

	Warn(msg string, fields ...zap.Field)
	WarnF(msg string, args ...any)

	Error(msg string, fields ...zap.Field)
	ErrorF(msg string, args ...any)

	Fatal(msg string, fields ...zap.Field)
	FatalF(msg string, args ...any)

	LogDiagnostics(prefix string, d *Diagnostics)
}

ClientLogger This Component is used to print logs on the client to facilitate troubleshooting when problems occur

type ClientMeta ¶

type ClientMeta struct {
	ClientLogger

	// If your application calls the API using a client, you can initialize it here, and when you call the API,
	// you pass the client you initialized here, so you don't have to re-initialize the client every time you call the API
	InitClient func(ctx context.Context, clientMeta *ClientMeta, config *viper.Viper) ([]any, *Diagnostics)

	// You can use a custom Logger, otherwise a default Logger will be initialized
	InitLogger func(ctx context.Context, clientMeta *ClientMeta, config *viper.Viper) (ClientLogger, *Diagnostics)
	// contains filtered or unexported fields
}

func (*ClientMeta) ClearItem ¶ added in v0.0.2

func (x *ClientMeta) ClearItem()

func (*ClientMeta) GetClientSlice ¶

func (x *ClientMeta) GetClientSlice() []any

func (*ClientMeta) GetIntItem ¶

func (x *ClientMeta) GetIntItem(itemName string, defaultValue int) int

func (*ClientMeta) GetItem ¶

func (x *ClientMeta) GetItem(itemName string) any

func (*ClientMeta) GetStringItem ¶

func (x *ClientMeta) GetStringItem(itemName, defaultValue string) string

func (*ClientMeta) Runtime ¶

func (x *ClientMeta) Runtime() *ClientMetaRuntime

func (*ClientMeta) SetItem ¶

func (x *ClientMeta) SetItem(itemName string, itemValue any)

type ClientMetaRuntime ¶

type ClientMetaRuntime struct {
	ProviderName    string
	ProviderVersion string
	Workspace       string
	// contains filtered or unexported fields
}

func (*ClientMetaRuntime) ClearItem ¶ added in v0.0.2

func (x *ClientMetaRuntime) ClearItem()

func (*ClientMetaRuntime) GetIntItem ¶

func (x *ClientMetaRuntime) GetIntItem(itemName string, defaultValue int) int

func (*ClientMetaRuntime) GetItem ¶

func (x *ClientMetaRuntime) GetItem(itemName string) any

func (*ClientMetaRuntime) GetStringItem ¶

func (x *ClientMetaRuntime) GetStringItem(itemName, defaultValue string) string

func (*ClientMetaRuntime) SetItem ¶

func (x *ClientMetaRuntime) SetItem(itemName string, itemValue any)

type ClientTaskContext ¶ added in v0.0.2

type ClientTaskContext struct {

	// client use execution task
	Client any

	// client's task
	Task *DataSourcePullTask
}

type Column ¶

type Column struct {

	// Column's name
	ColumnName string

	// Column's type, see schema.ColumnType, Columns must specify a type
	Type ColumnType

	// Column comments will be added to the table when the table is created
	Description string

	// To indicate how to extract the value of this column from the response content of the API
	Extractor ColumnValueExtractor

	// Some options for creating columns, such as uniq, not null
	Options ColumnOptions
	// contains filtered or unexported fields
}

Column one column definition in table

func (*Column) Runtime ¶

func (x *Column) Runtime() *ColumnRuntime

type ColumnOptions ¶

type ColumnOptions struct {

	// Whether the value of this column is unique
	Unique *bool

	// Whether this column is a not-null entry
	NotNull *bool
}

ColumnOptions You can customize the options you configure when creating columns

func (*ColumnOptions) IsNotNull ¶

func (x *ColumnOptions) IsNotNull() bool

func (*ColumnOptions) IsUniq ¶

func (x *ColumnOptions) IsUniq() bool

type ColumnRuntime ¶

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

ColumnRuntime column's runtime

type ColumnType ¶

type ColumnType int

ColumnType The type used to represent the value of the column, which is converted by the specific storage medium at the time of storage

const (

	// ColumnTypeNotAssign The default value is not set. If the value is not set, an error will be detected during initialization
	ColumnTypeNotAssign ColumnType = iota

	ColumnTypeSmallInt
	ColumnTypeInt
	ColumnTypeIntArray
	ColumnTypeBigInt

	ColumnTypeFloat

	ColumnTypeBool

	ColumnTypeString
	ColumnTypeStringArray

	ColumnTypeByteArray

	ColumnTypeTimestamp

	ColumnTypeJSON

	ColumnTypeIp
	ColumnTypeIpArray

	ColumnTypeCIDR
	ColumnTypeCIDRArray

	ColumnTypeMacAddr
	ColumnTypeMacAddrArray
)

func (*ColumnType) String ¶

func (x *ColumnType) String() string

type ColumnValueConvertor ¶

type ColumnValueConvertor interface {

	// Convert The method actually responsible for the type conversion
	//
	// table: The table corresponding to the value to be converted
	// column: The column corresponding to the value to be converted
	// columnValue: The value to convert
	//
	// return:
	//    any: The value of the transformed column
	//    *schema.Diagnostics: Any message you want the user to see. These are usually error reports or warnings
	Convert(table *Table, column *Column, columnValue any) (any, *Diagnostics)
}

ColumnValueConvertor This ColumnValueConvertor is used to convert the extracted column value to the corresponding storage medium value

type ColumnValueExtractor ¶

type ColumnValueExtractor interface {

	// Name The name of this ColumnValueExtractor
	Name() string

	// Extract The method actually responsible for extracting the value
	// ctx:
	// clientMeta:
	// task:
	// row:
	// column:
	// result:
	// return any
	// return *Diagnostics
	Extract(ctx context.Context, clientMeta *ClientMeta, client any, task *DataSourcePullTask, row *Row, column *Column, result any) (any, *Diagnostics)

	// DependencyColumnNames If the values of this class depend on other columns,
	// the data in the same row will also be parsed according to the DAG dependency topology between the columns
	DependencyColumnNames(ctx context.Context, clientMeta *ClientMeta, parentTable *Table, table *Table, column *Column) []string

	// Validate This method is called to check when the runtime is initialized to detect errors as early as possible
	Validate(ctx context.Context, clientMeta *ClientMeta, parentTable *Table, table *Table, column *Column) *Diagnostics
}

ColumnValueExtractor To indicate how to extract the value of this column from the result returned by the API's interface See package transformer.value_extractor for the default implementation

type ConsumerSemaphore ¶ added in v0.0.10

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

ConsumerSemaphore Used to coordinate the work and exit of all consumers

func NewConsumerSemaphore ¶ added in v0.0.10

func NewConsumerSemaphore(clientMeta *ClientMeta) *ConsumerSemaphore

func (*ConsumerSemaphore) Idle ¶ added in v0.0.10

func (x *ConsumerSemaphore) Idle(consumerId uint64)

func (*ConsumerSemaphore) Init ¶ added in v0.0.10

func (x *ConsumerSemaphore) Init(consumerId uint64)

func (*ConsumerSemaphore) IsAllConsumerDone ¶ added in v0.0.10

func (x *ConsumerSemaphore) IsAllConsumerDone() bool

func (*ConsumerSemaphore) Running ¶ added in v0.0.10

func (x *ConsumerSemaphore) Running(consumerId uint64)

type DataSource ¶

type DataSource struct {

	// The pull method is responsible for pulling the data, The pulled data is returned to the resultChannel, one result at a time
	Pull func(ctx context.Context, clientMeta *ClientMeta, client any, task *DataSourcePullTask, resultChannel chan<- any) *Diagnostics
}

DataSource Data sources can produce data

func DataSourceParentRawFieldSliceValue ¶

func DataSourceParentRawFieldSliceValue(structSelector string) DataSource

DataSourceParentRawFieldSliceValue Gets a slice value from the original return result of the parent table

func DataSourceParentRawFieldValue ¶

func DataSourceParentRawFieldValue(structSelector string) DataSource

DataSourceParentRawFieldValue Gets a value from the original return result of the parent table

type DataSourceExecutor ¶

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

DataSourceExecutor Pulls the actuator of the data source

func (*DataSourceExecutor) ShutdownAndAwaitTermination ¶

func (x *DataSourceExecutor) ShutdownAndAwaitTermination(ctx context.Context) *Diagnostics

ShutdownAndAwaitTermination Close the task queue and hold the current coroutine until the task completes or times out

func (*DataSourceExecutor) Submit ¶

Submit Submit a data source pull task for execution

type DataSourcePullTask ¶

type DataSourcePullTask struct {

	// global uniq task id
	TaskId string

	Ctx context.Context

	ParentTask *DataSourcePullTask

	ParentTable *Table

	ParentRow *Row

	ParentRawResult any

	// Only if the task is successfully executed will the raw result be backfilled here
	// This is so that when a task result is expand, there is a way to access the before expand results if you need to
	NotExpandRawResult any

	Table *Table

	// What happens to the pulled data
	ResultHandler func(ctx context.Context, clientMeta *ClientMeta, client any, task *DataSourcePullTask, result any) (*Rows, []any, *Diagnostics)

	// Callback method when the task is completed
	TaskDoneCallback func(ctx context.Context, clientMeta *ClientMeta, task *DataSourcePullTask) *Diagnostics

	// You can pass some messages back at execution time
	DiagnosticsChannel chan *Diagnostics

	// Whether this task is a Root task
	IsRootTask bool
	// The client context required to perform the task
	Client any
	// Is the expansion completed?
	IsExpandDone bool
	// contains filtered or unexported fields
}

DataSourcePullTask Represents a data source pull task

func (*DataSourcePullTask) ClearItem ¶ added in v0.0.2

func (x *DataSourcePullTask) ClearItem()

func (*DataSourcePullTask) Clone ¶ added in v0.0.2

func (*DataSourcePullTask) GetIntItem ¶ added in v0.0.2

func (x *DataSourcePullTask) GetIntItem(itemName string, defaultValue int) int

func (*DataSourcePullTask) GetItem ¶ added in v0.0.2

func (x *DataSourcePullTask) GetItem(itemName string) any

func (*DataSourcePullTask) GetStringItem ¶ added in v0.0.2

func (x *DataSourcePullTask) GetStringItem(itemName, defaultValue string) string

func (*DataSourcePullTask) LookupIntItem ¶ added in v0.0.2

func (x *DataSourcePullTask) LookupIntItem(itemName string, defaultValue int) int

func (*DataSourcePullTask) LookupItem ¶ added in v0.0.2

func (x *DataSourcePullTask) LookupItem(itemName string) any

func (*DataSourcePullTask) LookupStringItem ¶ added in v0.0.2

func (x *DataSourcePullTask) LookupStringItem(itemName, defaultValue string) string

func (*DataSourcePullTask) SetItem ¶ added in v0.0.2

func (x *DataSourcePullTask) SetItem(itemName string, itemValue any)

type DataSourcePullTaskQueue ¶ added in v0.0.10

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

DataSourcePullTaskQueue A dedicated task queue allows you to expand the task queue at will

func NewDataSourcePullTaskQueue ¶ added in v0.0.10

func NewDataSourcePullTaskQueue() *DataSourcePullTaskQueue

func (*DataSourcePullTaskQueue) Add ¶ added in v0.0.10

func (*DataSourcePullTaskQueue) IsEmpty ¶ added in v0.0.10

func (x *DataSourcePullTaskQueue) IsEmpty() bool

func (*DataSourcePullTaskQueue) Take ¶ added in v0.0.10

type DefaultClientLogger ¶

type DefaultClientLogger struct {
	DesensitizationFunction DesensitizationFunction
	// contains filtered or unexported fields
}

func NewDefaultClientLogger ¶

func NewDefaultClientLogger(loggerConfig *DefaultClientLoggerConfig) (*DefaultClientLogger, error)

func (*DefaultClientLogger) Debug ¶

func (x *DefaultClientLogger) Debug(msg string, fields ...zap.Field)

func (*DefaultClientLogger) DebugF ¶

func (x *DefaultClientLogger) DebugF(msg string, args ...any)

func (*DefaultClientLogger) Error ¶

func (x *DefaultClientLogger) Error(msg string, fields ...zap.Field)

func (*DefaultClientLogger) ErrorF ¶

func (x *DefaultClientLogger) ErrorF(msg string, args ...any)

func (*DefaultClientLogger) Fatal ¶

func (x *DefaultClientLogger) Fatal(msg string, fields ...zap.Field)

func (*DefaultClientLogger) FatalF ¶

func (x *DefaultClientLogger) FatalF(msg string, args ...any)

func (*DefaultClientLogger) Info ¶

func (x *DefaultClientLogger) Info(msg string, fields ...zap.Field)

func (*DefaultClientLogger) InfoF ¶

func (x *DefaultClientLogger) InfoF(msg string, args ...any)

func (*DefaultClientLogger) Log ¶

func (x *DefaultClientLogger) Log(level zapcore.Level, msg string, fields ...zap.Field)

func (*DefaultClientLogger) LogDiagnostics ¶ added in v0.0.21

func (x *DefaultClientLogger) LogDiagnostics(prefix string, d *Diagnostics)

LogDiagnostics Logs need to be able to print diagnostic logs directly

func (*DefaultClientLogger) Name ¶

func (x *DefaultClientLogger) Name() string

func (*DefaultClientLogger) Warn ¶

func (x *DefaultClientLogger) Warn(msg string, fields ...zap.Field)

func (*DefaultClientLogger) WarnF ¶

func (x *DefaultClientLogger) WarnF(msg string, args ...any)

type DefaultClientLoggerConfig ¶

type DefaultClientLoggerConfig struct {
	DesensitizationFunction func(ctx context.Context, msg string, args ...any) (string, []any)

	FileLogEnabled      bool
	ConsoleLogEnabled   bool
	EncodeLogsAsJson    bool
	Level               string
	LevelIdentUppercase bool
	MaxDayAge           int
	ShowLine            bool
	ConsoleNoColor      bool
	MaxMegaBytesSize    int
	MaxBackups          int
	TimeFormat          string
	Prefix              string
	// contains filtered or unexported fields
}

func NewDefaultClientLoggerConfig ¶

func NewDefaultClientLoggerConfig(workspace, providerName string) *DefaultClientLoggerConfig

func (*DefaultClientLoggerConfig) EncodeLevel ¶

func (*DefaultClientLoggerConfig) GetEncoder ¶

func (x *DefaultClientLoggerConfig) GetEncoder() zapcore.Encoder

func (*DefaultClientLoggerConfig) GetEncoderConfig ¶

func (x *DefaultClientLoggerConfig) GetEncoderConfig() zapcore.EncoderConfig

func (*DefaultClientLoggerConfig) GetEncoderCore ¶

func (x *DefaultClientLoggerConfig) GetEncoderCore() []zapcore.Core

func (*DefaultClientLoggerConfig) GetLevelPriority ¶

func (x *DefaultClientLoggerConfig) GetLevelPriority(level zapcore.Level) zap.LevelEnablerFunc

func (*DefaultClientLoggerConfig) GetLogWriter ¶

func (x *DefaultClientLoggerConfig) GetLogWriter(level string) zapcore.WriteSyncer

func (*DefaultClientLoggerConfig) TranslationLevel ¶

func (x *DefaultClientLoggerConfig) TranslationLevel() zapcore.Level

type DesensitizationFunction ¶

type DesensitizationFunction func(ctx context.Context, msg string, fields ...zap.Field) (string, []zap.Field)

type Diagnostic ¶

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

func NewDiagnostic ¶

func NewDiagnostic(level DiagnosticLevel, content string) *Diagnostic

func NewErrorDiagnostic ¶

func NewErrorDiagnostic(content string) *Diagnostic

func NewFatalDiagnostic ¶

func NewFatalDiagnostic(content string) *Diagnostic

func NewInfoDiagnostic ¶

func NewInfoDiagnostic(content string) *Diagnostic

func NewWarnDiagnostic ¶

func NewWarnDiagnostic(content string) *Diagnostic

func (*Diagnostic) Content ¶

func (x *Diagnostic) Content() string

func (*Diagnostic) Level ¶

func (x *Diagnostic) Level() DiagnosticLevel

type DiagnosticLevel ¶

type DiagnosticLevel int
const (
	DiagnosisLevelTrace DiagnosticLevel = iota
	DiagnosisLevelDebug
	DiagnosisLevelInfo
	DiagnosisLevelWarn
	DiagnosisLevelError
	DiagnosisLevelFatal
)

func (DiagnosticLevel) String ¶

func (x DiagnosticLevel) String() string

type Diagnostics ¶

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

Diagnostics Represents a series of diagnostic information

func NewDiagnostics ¶

func NewDiagnostics() *Diagnostics

func NewDiagnosticsAddErrorMsg ¶

func NewDiagnosticsAddErrorMsg(format string, args ...any) *Diagnostics

func NewDiagnosticsErrorColumnValueExtractor ¶

func NewDiagnosticsErrorColumnValueExtractor(table *Table, column *Column, err error) *Diagnostics

func NewDiagnosticsErrorMsgColumnValueExtractor ¶

func NewDiagnosticsErrorMsgColumnValueExtractor(table *Table, column *Column, format string, args ...any) *Diagnostics

func NewDiagnosticsErrorMsgPullTable ¶

func NewDiagnosticsErrorMsgPullTable(table *Table, format string, args ...any) *Diagnostics

func NewDiagnosticsErrorPullTable ¶

func NewDiagnosticsErrorPullTable(table *Table, err error) *Diagnostics

func (*Diagnostics) Add ¶

func (x *Diagnostics) Add(d any) *Diagnostics

Add d type *Diagnostic or *Diagnostics or error

func (*Diagnostics) AddDiagnostic ¶

func (x *Diagnostics) AddDiagnostic(diagnostic *Diagnostic) *Diagnostics

func (*Diagnostics) AddDiagnostics ¶

func (x *Diagnostics) AddDiagnostics(diagnostics *Diagnostics) *Diagnostics

func (*Diagnostics) AddError ¶

func (x *Diagnostics) AddError(err error) *Diagnostics

func (*Diagnostics) AddErrorColumnValueExtractor ¶

func (x *Diagnostics) AddErrorColumnValueExtractor(table *Table, column *Column, err error) *Diagnostics

AddErrorColumnValueExtractor There was an error in extract column value

func (*Diagnostics) AddErrorMsg ¶

func (x *Diagnostics) AddErrorMsg(format string, args ...any) *Diagnostics

func (*Diagnostics) AddErrorMsgColumnValueExtractor ¶

func (x *Diagnostics) AddErrorMsgColumnValueExtractor(table *Table, column *Column, format string, args ...any) *Diagnostics

func (*Diagnostics) AddErrorMsgPullTable ¶

func (x *Diagnostics) AddErrorMsgPullTable(table *Table, format string, args ...any) *Diagnostics

func (*Diagnostics) AddErrorPullTable ¶

func (x *Diagnostics) AddErrorPullTable(table *Table, err error) *Diagnostics

AddErrorPullTable There was an error in pull table

func (*Diagnostics) AddFatal ¶

func (x *Diagnostics) AddFatal(format string, args ...any) *Diagnostics

func (*Diagnostics) AddInfo ¶

func (x *Diagnostics) AddInfo(format string, args ...any) *Diagnostics

func (*Diagnostics) AddWarn ¶

func (x *Diagnostics) AddWarn(format string, args ...any) *Diagnostics

func (*Diagnostics) GetDiagnosticSlice ¶

func (x *Diagnostics) GetDiagnosticSlice() []*Diagnostic

func (*Diagnostics) HasError ¶

func (x *Diagnostics) HasError() bool

func (*Diagnostics) IsEmpty ¶

func (x *Diagnostics) IsEmpty() bool

func (*Diagnostics) Size ¶

func (x *Diagnostics) Size() int

func (*Diagnostics) String ¶ added in v0.0.17

func (x *Diagnostics) String() string

func (*Diagnostics) ToString ¶

func (x *Diagnostics) ToString() string

type ErrorsHandlerMeta ¶ added in v0.0.2

type ErrorsHandlerMeta struct {

	// You can configure which types of errors are blocked from users
	IgnoredErrors []IgnoredError
	// contains filtered or unexported fields
}

func (*ErrorsHandlerMeta) IsIgnore ¶ added in v0.0.2

func (x *ErrorsHandlerMeta) IsIgnore(err IgnoredError) bool

type ErrorsHandlerMetaRuntime ¶ added in v0.0.2

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

func NewErrorsHandlerMetaRuntime ¶ added in v0.0.2

func NewErrorsHandlerMetaRuntime(myErrorsHandlerMeta *ErrorsHandlerMeta) *ErrorsHandlerMetaRuntime

func (*ErrorsHandlerMetaRuntime) IsNeedIgnore ¶ added in v0.0.2

func (x *ErrorsHandlerMetaRuntime) IsNeedIgnore(err IgnoredError) bool

type IgnoredError ¶ added in v0.0.2

type IgnoredError int
const (

	// IgnoredErrorAll Ignore the following types of errors
	IgnoredErrorAll IgnoredError = iota

	// IgnoredErrorOnPullTable When an error occurs while pulling the table, the error is ignored and the user is not reported, but the log is printed silently
	IgnoredErrorOnPullTable

	// IgnoredErrorOnTransformerRow Ignore errors when converting row
	IgnoredErrorOnTransformerRow

	// IgnoredErrorOnTransformerCell Ignore errors when converting cell
	IgnoredErrorOnTransformerCell

	// IgnoredErrorOnSaveResult If an error is reported when the retrieved data is saved to the table, the system ignores
	// the error and does not print it to the user. Instead, it silently records a log
	IgnoredErrorOnSaveResult
)

type Row ¶

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

Row Represents a row in a matrix or database

func NewRow ¶

func NewRow(columnNameSlice ...string) *Row

func (*Row) AddColumnName ¶

func (x *Row) AddColumnName(columnName string) error

AddColumnName Add a column

func (*Row) AddColumnNames ¶

func (x *Row) AddColumnNames(columnNames []string) error

AddColumnNames Add multiple columns at a time

func (*Row) ColumnCount ¶

func (x *Row) ColumnCount() int

ColumnCount How many columns count

func (*Row) Get ¶

func (x *Row) Get(columnName string) (any, error)

Get Gets the column value based on the column name

func (*Row) GetColumnNames ¶

func (x *Row) GetColumnNames() []string

GetColumnNames Gets all current column's name return as string slice

func (*Row) GetInt ¶

func (x *Row) GetInt(columnName string) (int, error)

func (*Row) GetIntOrDefault ¶

func (x *Row) GetIntOrDefault(columnName string, defaultValue int) int

func (*Row) GetOrDefault ¶ added in v0.0.4

func (x *Row) GetOrDefault(columnName string, defaultValue any) any

func (*Row) GetString ¶

func (x *Row) GetString(columnName string) (string, error)

func (*Row) GetStringOrDefault ¶

func (x *Row) GetStringOrDefault(columnName, defaultValue string) string

GetStringOrDefault The fetch column value is returned as String, or the default value in case of an error

func (*Row) GetValues ¶

func (x *Row) GetValues() []any

GetValues Returns all values of the current row in order

func (*Row) Set ¶

func (x *Row) Set(columnName string, value any) (any, error)

Set Set the column value based on the column name

func (*Row) SetColumnNames ¶

func (x *Row) SetColumnNames(columnNames []string) error

SetColumnNames Setting the current column is equivalent to resetting, which is an override setting

func (*Row) SetValues ¶

func (x *Row) SetValues(values []any) error

SetValues Sets the values for all columns of the row at once

func (*Row) SetValuesIgnoreError ¶

func (x *Row) SetValuesIgnoreError(values []any) *Row

SetValuesIgnoreError Set values for all columns of the row at once, ignoring errors

func (*Row) String ¶ added in v0.0.2

func (x *Row) String() string

func (*Row) ToRows ¶

func (x *Row) ToRows() *Rows

ToRows Converts the current row to Rows, if occur error then ignore it

func (*Row) ToRowsE ¶

func (x *Row) ToRowsE() (*Rows, error)

ToRowsE Converts the current row to Rows, if occur error then return

type Rows ¶

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

Rows Represents a number of rows of data in a table, a collection of rows

func NewRows ¶

func NewRows(columnNames ...string) *Rows

func (*Rows) AddColumnName ¶

func (x *Rows) AddColumnName(columnName string) error

AddColumnName Add a column to the table

func (*Rows) AddColumnNames ¶

func (x *Rows) AddColumnNames(columnName []string) error

AddColumnNames Add multiple columns at a time

func (*Rows) AppendRow ¶

func (x *Rows) AppendRow(row *Row) error

AppendRow Write a line

func (*Rows) AppendRowValues ¶

func (x *Rows) AppendRowValues(row []any) error

AppendRowValues Write a line

func (*Rows) ColumnCount ¶

func (x *Rows) ColumnCount() int

ColumnCount How many columns

func (*Rows) GetCellIntValueOrDefault ¶

func (x *Rows) GetCellIntValueOrDefault(rowIndex, columnIndex int, defaultValue int) int

func (*Rows) GetCellStringValueOrDefault ¶

func (x *Rows) GetCellStringValueOrDefault(rowIndex, columnIndex int, defaultValue string) string

func (*Rows) GetCellValue ¶

func (x *Rows) GetCellValue(rowIndex, columnIndex int) (any, error)

func (*Rows) GetCellValueOrDefault ¶

func (x *Rows) GetCellValueOrDefault(rowIndex, columnIndex int, defaultValue any) any

func (*Rows) GetColumnNames ¶

func (x *Rows) GetColumnNames() []string

GetColumnNames Gets all column names

func (*Rows) GetColumnValue ¶

func (x *Rows) GetColumnValue(rowIndex int, columnName string) (any, error)

GetColumnValue Get the value of a given column for a given row. Note that this method is inefficient and should be avoided if possible

func (*Rows) GetFirstRowColumnValue ¶

func (x *Rows) GetFirstRowColumnValue(columnName string) (any, error)

func (*Rows) GetFirstRowColumnValueAsBoolOrDefault ¶

func (x *Rows) GetFirstRowColumnValueAsBoolOrDefault(columnName string, defaultValue bool) bool

func (*Rows) GetFirstRowColumnValueAsIntOrDefault ¶

func (x *Rows) GetFirstRowColumnValueAsIntOrDefault(columnName string, defaultValue int) int

func (*Rows) GetFirstRowColumnValueAsStringOrDefault ¶

func (x *Rows) GetFirstRowColumnValueAsStringOrDefault(columnName string, defaultValue string) string

func (*Rows) GetMatrix ¶

func (x *Rows) GetMatrix() [][]any

GetMatrix Returns the inner matrix

func (*Rows) GetRow ¶

func (x *Rows) GetRow(rowIndex int) (*Row, error)

GetRow Gets the specified Row, converts it to Row and returns

func (*Rows) GetRowValues ¶

func (x *Rows) GetRowValues(rowIndex int) ([]any, error)

GetRowValues Gets the values of all columns of the specified row

func (*Rows) IsEmpty ¶

func (x *Rows) IsEmpty() bool

func (*Rows) RowCount ¶

func (x *Rows) RowCount() int

RowCount How many lines

func (*Rows) SetColumnNames ¶

func (x *Rows) SetColumnNames(columnNames []string) *Rows

SetColumnNames Set the column name. The matrix value is reset when the column name is set

func (*Rows) SetMatrix ¶

func (x *Rows) SetMatrix(matrix [][]any) error

SetMatrix Sets the value of the matrix

func (*Rows) SplitRowByRow ¶

func (x *Rows) SplitRowByRow() []*Row

SplitRowByRow Partition the matrix into matrices with only one row

func (*Rows) String ¶

func (x *Rows) String() string

func (*Rows) ToRow ¶

func (x *Rows) ToRow() (*Row, error)

ToRow Convert Rows to Row only if there are 0 or 1 Rows

func (*Rows) Write ¶

func (x *Rows) Write(cellValue any)

I'm going to write a cell in the table, and I'm only allowed to write cells sequentially

func (*Rows) WriteNewLine ¶

func (x *Rows) WriteNewLine() error

WriteNewLine Write a newline

type Table ¶

type Table struct {

	// Table's name
	TableName string

	// You can provide some description information, which will be included in the automatic document generation
	Description string

	// What are the columns in this table
	Columns []*Column

	// A table can have child tables whose data depends on the current table
	SubTables []*Table

	// Some configuration items of this table
	Options *TableOptions

	// The data source used to provide data for this table
	DataSource DataSource

	// If your table needs to extend the default call method, you can implement this function
	// The default is to use Task once per client
	// But you can call the client multiple times by making multiple copies of the client
	// When a value is returned, it is called once with each of the returned clients
	// The second parameter, task, if it is not returned, uses the original task. If it is returned, it must be the same length as the client and correspond one to one
	ExpandClientTask func(ctx context.Context, clientMeta *ClientMeta, client any, task *DataSourcePullTask) []*ClientTaskContext

	// An increasing number. If the table structure has changed, the version number needs to be changed
	Version uint64
	// contains filtered or unexported fields
}

Table A Provider may have many tables, which are the API's persistent representation

func (*Table) GetFullTableName ¶

func (x *Table) GetFullTableName() string

func (*Table) GetNamespace ¶

func (x *Table) GetNamespace() string

func (*Table) GetPrimaryKeys ¶

func (x *Table) GetPrimaryKeys() []string

func (*Table) Runtime ¶

func (x *Table) Runtime() *TableRuntime

type TableForeignKey ¶

type TableForeignKey struct {

	// Leaving it unset automatically generates a name
	Name string

	// The column name of the current table
	SelfColumns []string

	// The table to associate with
	ForeignTableName string

	// The column of the table to be associated with
	ForeignColumns []string

	Description string
}

TableForeignKey Foreign key table

func (*TableForeignKey) GetName ¶

func (x *TableForeignKey) GetName(tableName string) string

type TableIndex ¶

type TableIndex struct {

	// index's name
	Name string

	// Index the columns involved
	ColumnNames []string

	// Whether this index is unique
	IsUniq *bool

	// Please briefly explain what this index does
	Description string
}

TableIndex You can create indexes, composite indexes, and the like to speed up queries

func (*TableIndex) GetName ¶

func (x *TableIndex) GetName(tableName string) string

type TableOptions ¶

type TableOptions struct {

	// Primary key: Which columns are the primary keys of the table.
	// Note that this is in order. The primary keys are created in the given order
	PrimaryKeys []string

	// Foreign key: This table can be associated to other tables through foreign keys
	ForeignKeys []*TableForeignKey

	// Indexes: There are some indexes that can be defined in a table. Generally,
	// compound indexes are defined in this place. If an index involves only one column, then it is OK to define on the column
	Indexes []*TableIndex
}

TableOptions When you create a table, you can specify primary keys, foreign keys, indexes, and so on

func (*TableOptions) GenPrimaryKeysName ¶

func (x *TableOptions) GenPrimaryKeysName(tableName string) string

GenPrimaryKeysName Automatically generate the name of the primary key

type TableRuntime ¶

type TableRuntime struct {

	// like database name
	Namespace string

	// The order in which columns are resolved, Because there may be a dependency order between columns,
	// the resolution order is obtained by topological sorting of the DAG
	ColumnExtractorSorted []*Column
	// contains filtered or unexported fields
}

TableRuntime The runtime of the table, the relevant context during the runtime and so forth will be taken care of by this struct

func (*TableRuntime) ContainsColumnName ¶

func (x *TableRuntime) ContainsColumnName(columnName string) bool

ContainsColumnName Whether the table contains the given column

func (*TableRuntime) FindUniqGroup ¶ added in v0.0.20

func (x *TableRuntime) FindUniqGroup(columnName string) []string

FindUniqGroup The current column may not be unique by itself, but it is unique when combined with other columns. Get the unique group

func (*TableRuntime) Init ¶

func (x *TableRuntime) Init(ctx context.Context, clientMeta *ClientMeta, parentTable *Table, myTable *Table) *Diagnostics

Init Initializes the runtime of the table

func (*TableRuntime) IsIndexed ¶ added in v0.0.20

func (x *TableRuntime) IsIndexed(columnName string) bool

IsIndexed Whether this column is the column to be indexed

func (*TableRuntime) IsNotNull ¶ added in v0.0.20

func (x *TableRuntime) IsNotNull(columnName string) bool

IsNotNull Whether the value of this column is non-null

func (*TableRuntime) IsPrimaryKey ¶ added in v0.0.20

func (x *TableRuntime) IsPrimaryKey(columnName string) bool

IsPrimaryKey Whether this column is a primary key column It's a primary key itself, or there are multiple primary keys, and it's one of them

func (*TableRuntime) IsUniq ¶ added in v0.0.20

func (x *TableRuntime) IsUniq(columnName string) bool

IsUniq Whether the value of this column is unique

func (*TableRuntime) Validate ¶

func (x *TableRuntime) Validate(ctx context.Context, clientMeta *ClientMeta, parentTable *Table, table *Table) *Diagnostics

Validate The table is self-checked

type TransformerMeta ¶

type TransformerMeta struct {

	// if you api will return some valid string, you can config on this field
	//
	// For example, if the value of an int field is not available, the API will return a uniform invalid value, such as N/A.
	// Even though it is an int field, the API will return a string it's value is "N/A", so you can use this configuration
	// to be compatible with this situation. The underlying converter will check and ignore any invalid value configured.
	//
	// Note that the checker will only check for fields that are not String. If an invalid value is specified on a String
	// field, it will be stored because the checker cannot determine whether it is a valid value or an invalid value, so
	// it plays it safe
	DefaultColumnValueConvertorBlackList []string

	// If you do not want to use the default type converter, you can use your own custom type converter.
	// In order to realize your own ColumnValueConvertor, implementation schema.ColumnValueConvertor interface
	//
	// If you do not configure this field, a default type converter will be initialized, default
	// ColumnValueConvertor is column_value_convertor.DefaultColumnValueConvertor
	ColumnValueConvertor ColumnValueConvertor

	// If the Pull method of the DataSource returns Array or Slice, the DataSource is automatically expanded to multiple results
	DataSourcePullResultAutoExpand bool
}

TransformerMeta data transformation meta information

func (*TransformerMeta) IsUseDefaultColumnValueConvertor ¶

func (x *TransformerMeta) IsUseDefaultColumnValueConvertor() bool

Jump to

Keyboard shortcuts

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