Documentation
¶
Overview ¶
Copyright 2025 SGNL.ai, Inc.
Copyright 2025 SGNL.ai, Inc.
Copyright 2025 SGNL.ai, Inc.
Copyright 2025 SGNL.ai, Inc.
Copyright 2025 SGNL.ai, Inc.
Copyright 2025 SGNL.ai, Inc.
Copyright 2025 SGNL.ai, Inc.
Index ¶
- func NewAdapter(client Client) framework.Adapter[Config]
- func ParseResponse(rows *sql.Rows, request *Request) ([]map[string]any, *framework.Error)
- type Adapter
- func (a *Adapter) GetPage(ctx context.Context, request *framework.Request[Config]) framework.Response
- func (a *Adapter) RequestPageFromDatasource(ctx context.Context, request *framework.Request[Config]) framework.Response
- func (a *Adapter) ValidateGetPageRequest(ctx context.Context, request *framework.Request[Config]) *framework.Error
- type Client
- type Config
- type Datasource
- type DefaultSQLClient
- type MockSQLClient
- type Request
- type Response
- type SQLClient
- type SQLColumnTypes
- type SQLRow
- type SQLRows
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAdapter ¶
NewAdapter instantiates a new Adapter.
Types ¶
type Adapter ¶
type Adapter struct {
MySQLClient Client
}
Adapter implements the framework.Adapter interface to query pages of objects from datasources.
func (*Adapter) GetPage ¶
func (a *Adapter) GetPage(ctx context.Context, request *framework.Request[Config]) framework.Response
GetPage is called by SGNL's ingestion service to query a page of objects from a datasource.
type Client ¶
type Config ¶
type Config struct {
*config.CommonConfig
// MySQL database to connect to.
Database string `json:"database,omitempty"`
}
Config is the configuration passed in each GetPage calls to the adapter. Adapter configuration example: nolint: godot
{
"requestTimeoutSeconds": 10,
"localTimeZoneOffset": 43200,
"database": "sgnl"
}
type Datasource ¶
type Datasource struct {
Client SQLClient
}
type DefaultSQLClient ¶
func NewDefaultSQLClient ¶
func NewDefaultSQLClient() *DefaultSQLClient
func (*DefaultSQLClient) Connect ¶
func (c *DefaultSQLClient) Connect(dataSourceName string) error
Connect opens a database connection to the provided datasource. The database is safe for concurrent use by multiple goroutines and maintains its own pool of idle connections. Thus, the Connect function should be called just once.
This must be called before calling Query, else that function call will fail.
type MockSQLClient ¶
func NewMockSQLClient ¶
func NewMockSQLClient() *MockSQLClient
func (*MockSQLClient) Connect ¶
func (c *MockSQLClient) Connect(datasourceName string) error
type Request ¶
type Request struct {
// BaseURL is the Base URL of the datasource to query.
BaseURL string
// Username is the user name used to authenticate with the MySQL instance.
Username string
// Password is the password used to authenticate with the MySQL instance.
Password string
// PageSize is the maximum number of objects to return from the entity.
PageSize int64
// EntityExternalID is the external ID of the entity.
// The external ID should match the table name on the MySQL database.
EntityExternalID string
// Cursor identifies the first object of the page to return, as returned by
// the last request for the entity.
// nil in the request for the first page.
Cursor *int64
// MySQL database to connect to.
Database string
// UniqueAttributeExternalID is used to specify the unique ID that should be used when ordering results from
// the specified table.
UniqueAttributeExternalID string
}
Request is a request to a MySQL database.
type Response ¶
type Response struct {
// StatusCode is an HTTP status code.
StatusCode int
// RetryAfterHeader is the Retry-After response HTTP header, if set.
RetryAfterHeader string
// Objects is the list of objects returned from the datasource.
// May be empty.
Objects []map[string]any
// NextCursor is the cursor that identifies the first object of the next page.
// nil if this is the last page in this full sync.
NextCursor *int64
}
Response is a response returned by the datasource.