datastore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MongoStore     = "mongo"
	RedisStore     = "redis"
	CassandraStore = "cassandra"
	SqlStore       = "sql"
	Kafka          = "kafka"
	EventBridge    = "eventbridge"
	ElasticSearch  = "elasticsearch"
	Ycql           = "ycql"
	EventHub       = "eventhub"
	DynamoDb       = "dynamoDB"
	AWSSNS         = "aws-sns"
	Avro           = "avro"
	GooglePubSub   = "google"
)

Variables

This section is empty.

Functions

func NewMySQLDialector

func NewMySQLDialector(cfg *DBConfig, connectionStr, driverName string) (gorm.Dialector, error)

NewMySQLDialector creates a new GORM Dialector for MySQL database based on the provided configurations.

Types

type Cassandra

type Cassandra struct {
	Cluster *gocql.ClusterConfig
	Session *gocql.Session
	// contains filtered or unexported fields
}

Cassandra stores information about the Cassandra cluster and open sessions

func GetNewCassandra

func GetNewCassandra(logger log.Logger, cassandraCfg *CassandraCfg) (Cassandra, error)

GetNewCassandra creates and opens a connection to the cassandra cluster

func (*Cassandra) HealthCheck

func (c *Cassandra) HealthCheck() types.Health

HealthCheck returns the health of Cassandra

type CassandraCfg

type CassandraCfg struct {
	Hosts               string
	Consistency         string
	Username            string
	Password            string
	Keyspace            string
	RetryPolicy         gocql.RetryPolicy
	CertificateFile     string
	KeyFile             string
	RootCertificateFile string
	DataCenter          string
	Port                int
	Timeout             int
	ConnectTimeout      int
	ConnRetryDuration   int
	TLSVersion          uint16
	HostVerification    bool
	InsecureSkipVerify  bool
}

CassandraCfg holds the configurations for Cassandra Connectivity

type Client

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

Client implements the methods to create update search and delete documents It also implements methods to retrieve, create, update and delete fields in schema

func NewSolrClient

func NewSolrClient(host, port string) Client

NewSolrClient returns a client to support basic solr functionality

func (Client) AddField

func (c Client) AddField(ctx context.Context, collection string, document *bytes.Buffer) (interface{}, error)

AddField adds Field in the schema for the specified collection

func (Client) Create

func (c Client) Create(ctx context.Context, collection string, document *bytes.Buffer,
	params map[string]interface{}) (interface{}, error)

Create makes documents in the specified collection. params can be used to send parameters like commit=true

func (Client) Delete

func (c Client) Delete(ctx context.Context, collection string, document *bytes.Buffer,
	params map[string]interface{}) (interface{}, error)

Create deletes documents in the specified collection. params can be used to send parameters like commit=true

func (Client) DeleteField

func (c Client) DeleteField(ctx context.Context, collection string, document *bytes.Buffer) (interface{}, error)

DeleteField deletes the field definitions in the schema for the specified collection

func (Client) ListFields

func (c Client) ListFields(ctx context.Context, collection string, params map[string]interface{}) (interface{}, error)

ListFields retrieves all the fields in the schema for the specified collection. params can be used to send query parameters like wt, fl, includeDynamic etc.

func (Client) Retrieve

func (c Client) Retrieve(ctx context.Context, collection string, params map[string]interface{}) (interface{}, error)

Retrieve retrieves the entire schema that includes all the fields,field types,dynamic rules and copy field rules. params can be used to specify the format of response

func (Client) Search

func (c Client) Search(ctx context.Context, collection string, params map[string]interface{}) (interface{}, error)

Search searches documents in the given collections based on the parameters specified. This can be used for making any queries to SOLR

func (Client) Update

func (c Client) Update(ctx context.Context, collection string, document *bytes.Buffer,
	params map[string]interface{}) (interface{}, error)

Update updates documents in the specified collection. params can be used to send parameters like commit=true

func (Client) UpdateField

func (c Client) UpdateField(ctx context.Context, collection string, document *bytes.Buffer) (interface{}, error)

UpdateField updates the field definitions in the schema for the specified collection

type DBConfig

type DBConfig struct {
	HostName string
	Username string
	Password string
	Database string
	Port     string
	Dialect  string // supported dialects are - mysql, mssql, sqlite, postgres
	// postgres and mysql related config only, accepts disable, allow, prefer, require,
	// verify-ca and verify-full; default is disable
	SSL               string
	ORM               string
	CertificateFile   string
	KeyFile           string
	ConnRetryDuration int
	MaxOpenConn       int
	MaxIdleConn       int
	MaxConnLife       int
	CACertificateFile string
}

DBConfig stores the config variables required to connect to a supported database

type DataStore

type DataStore struct {
	Logger        log.Logger
	MongoDB       MongoDB
	Redis         Redis
	ORM           interface{}
	Cassandra     Cassandra
	YCQL          YCQL
	PubSub        pubsub.PublisherSubscriber
	Solr          Client
	Elasticsearch Elasticsearch
	DynamoDB      DynamoDB
	// contains filtered or unexported fields
}

DataStore represents a database connection pool for various types of databases

func (*DataStore) CQLHealthCheck

func (ds *DataStore) CQLHealthCheck() types.Health

CQLHealthCheck performs a query operation on the cql instance. If the operation does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN.

func (*DataStore) DB

func (ds *DataStore) DB() *SQLClient

DB returns an initialized SQLClient instance

func (*DataStore) DynamoDBHealthCheck

func (ds *DataStore) DynamoDBHealthCheck() types.Health

DynamoDBHealthCheck executes a ListTable API operation. If the returned error is not nil, the healthCheck status will be set to DOWN, else the healthCheck status will be UP

func (*DataStore) ElasticsearchHealthCheck

func (ds *DataStore) ElasticsearchHealthCheck() types.Health

ElasticsearchHealthCheck pings the Elasticsearch instance. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN

func (*DataStore) GORM

func (ds *DataStore) GORM() *gorm.DB

GORM returns a GORM database instance, initializing it if necessary, based on the DataStore's internal state and ORM interface.

func (*DataStore) MongoHealthCheck

func (ds *DataStore) MongoHealthCheck() types.Health

MongoHealthCheck pings the MongoDB instance. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN.

func (*DataStore) PubSubHealthCheck

func (ds *DataStore) PubSubHealthCheck() types.Health

PubSubHealthCheck pings the pubsub instance. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN

func (*DataStore) RedisHealthCheck

func (ds *DataStore) RedisHealthCheck() types.Health

RedisHealthCheck pings the redis instance. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN

func (*DataStore) SQLHealthCheck

func (ds *DataStore) SQLHealthCheck() types.Health

SQLHealthCheck pings the sql instance. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN

func (*DataStore) SQLX

func (ds *DataStore) SQLX() *sqlx.DB

SQLX returns an initialized SQLX instance

func (*DataStore) SQLXHealthCheck

func (ds *DataStore) SQLXHealthCheck() types.Health

SQLXHealthCheck pings the sqlx instance. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN.

func (*DataStore) SetORM

func (ds *DataStore) SetORM(client interface{})

SetORM sets the ORM based on GORM or SQLX

func (*DataStore) YCQLHealthCheck

func (ds *DataStore) YCQLHealthCheck() types.Health

YCQLHealthCheck performs a query operation on the ycql instance. If the operation does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN.

type Document

type Document interface {
	Search(ctx context.Context, collection string, params map[string]interface{}) (interface{}, error)
	Create(ctx context.Context, collection string, document *bytes.Buffer, params map[string]interface{}) (interface{}, error)
	Update(ctx context.Context, collection string, document *bytes.Buffer, params map[string]interface{}) (interface{}, error)
	Delete(ctx context.Context, collection string, document *bytes.Buffer, params map[string]interface{}) (interface{}, error)
}

Document is an interface for managing document-related operations in Solr.

type DynamoDB

type DynamoDB struct {
	*dynamodb.DynamoDB
	// contains filtered or unexported fields
}

DynamoDB stores the DynamoDB Client along with logger ad configs to connect to DynamoDB Database.

func NewDynamoDB

func NewDynamoDB(logger log.Logger, c DynamoDBConfig) (DynamoDB, error)

NewDynamoDB connects to DynamoDB and returns the connection

func (*DynamoDB) DeleteItem

func (d *DynamoDB) DeleteItem(input *dynamodb.DeleteItemInput) (*dynamodb.DeleteItemOutput, error)

DeleteItem Deletes a single item in a table by primary key.It records start time, executes the operation, and logs query details. It returns the output of deleted item and error if any.

func (*DynamoDB) DeleteItemRequest

func (d *DynamoDB) DeleteItemRequest(input *dynamodb.DeleteItemInput) (*Request, *dynamodb.DeleteItemOutput)

DeleteItemRequest generates a request representing the client's request for the DeleteItem operation. It returns the request and Delete Item output which will be populated once the request is completed successfully.

func (*DynamoDB) DeleteItemWithContext

func (d *DynamoDB) DeleteItemWithContext(ctx context.Context, input *dynamodb.DeleteItemInput) (*dynamodb.DeleteItemOutput, error)

DeleteItemWithContext Deletes a single item in a table by primary key with the addition of the ability to pass a context and additional request options.It records start time, executes the operation, and logs query details.

func (*DynamoDB) GetItem

func (d *DynamoDB) GetItem(input *dynamodb.GetItemInput) (*dynamodb.GetItemOutput, error)

GetItem returns a set of attributes for the item with the given primary key and monitors query duration It returns the DynamoDB item and error if any.

func (*DynamoDB) GetItemRequest

func (d *DynamoDB) GetItemRequest(input *dynamodb.GetItemInput) (*Request, *dynamodb.GetItemOutput)

GetItemRequest generates a request representing the client's request for the GetItem operation in DynamoDB. It also generates a query logger to monitor the query. Returns the request and DynamoDB output which will be populated once the request is completed successfully for GetItem.

func (*DynamoDB) GetItemWithContext

func (d *DynamoDB) GetItemWithContext(ctx context.Context, input *dynamodb.GetItemInput) (*dynamodb.GetItemOutput, error)

GetItemWithContext returns a set of attributes for the item with the given primary key and monitors query duration with the addition of the ability to pass a context and additional request options. It returns the DynamoDB item and error if any.

func (*DynamoDB) HealthCheck

func (d *DynamoDB) HealthCheck() types.Health

HealthCheck checks health of the Dya

func (*DynamoDB) PutItem

func (d *DynamoDB) PutItem(input *dynamodb.PutItemInput) (*dynamodb.PutItemOutput, error)

PutItem adds an item to DynamoDB and monitors the query duration. It records start time, executes the operation, and logs query details.

func (*DynamoDB) PutItemRequest

func (d *DynamoDB) PutItemRequest(input *dynamodb.PutItemInput) (*Request, *dynamodb.PutItemOutput)

PutItemRequest generates a request representing the client's request for the PutItem operation in DynamoDB. It also generates a query logger to monitor the query. Returns the request and DynamoDB output which will be populated once the request is completed successfully for PutItem.

func (*DynamoDB) PutItemWithContext

func (d *DynamoDB) PutItemWithContext(ctx context.Context, input *dynamodb.PutItemInput) (*dynamodb.PutItemOutput, error)

PutItemWithContext adds an item to DynamoDB and monitors the query duration. It records start time, executes the operation, and logs query details with the addition of the ability to pass a context and additional request options.

func (*DynamoDB) UpdateItem

func (d *DynamoDB) UpdateItem(input *dynamodb.UpdateItemInput) (*dynamodb.UpdateItemOutput, error)

UpdateItem Edits an existing item's attributes, or adds a new item to the table if it does not already exist. It records start time, executes the operation, and logs query details. It returns Update Item output and error if any.

func (*DynamoDB) UpdateItemRequest

func (d *DynamoDB) UpdateItemRequest(input *dynamodb.UpdateItemInput) (*Request, *dynamodb.UpdateItemOutput)

UpdateItemRequest generates a request representing the client's request for the UpdateItem operation. It also generates a query logger to monitor the query. Returns update request and Update Item output value will be populated with the request's response once the request completes successfully.

func (*DynamoDB) UpdateItemWithContext

func (d *DynamoDB) UpdateItemWithContext(ctx context.Context, input *dynamodb.UpdateItemInput) (*dynamodb.UpdateItemOutput, error)

UpdateItemWithContext Edits an existing item's attributes, or adds a new item to the table if it does not already exist with the addition of the ability to pass a context and additional request options. It also generates a query logger to monitor the query. Returns update request and Update Item output value will be populated with the request's response once the request completes successfully.

type DynamoDBConfig

type DynamoDBConfig struct {
	Region            string
	Endpoint          string
	AccessKeyID       string
	SecretAccessKey   string
	ConnRetryDuration int
}

DynamoDBConfig configuration for DynamoDB connection

type ElasticSearchCfg

type ElasticSearchCfg struct {
	Host                    string
	Ports                   []int
	Username                string
	Password                string
	CloudID                 string
	ConnectionRetryDuration int
}

ElasticSearchCfg stores the configuration parameters required to connect to Elasticsearch.

type Elasticsearch

type Elasticsearch struct {
	*elasticsearch.Client
	// contains filtered or unexported fields
}

Elasticsearch stores the elasticSearch client along with logger and configs to connect to ElasticSearch DB.

func NewElasticsearchClient

func NewElasticsearchClient(logger log.Logger, c *ElasticSearchCfg) (Elasticsearch, error)

NewElasticsearchClient factory function for Elasticsearch

func (*Elasticsearch) Bind

func (e *Elasticsearch) Bind(res *esapi.Response, target interface{}) error

Bind binds the response returned by the elasticsearch client to target(should not be array)

func (*Elasticsearch) BindArray

func (e *Elasticsearch) BindArray(res *esapi.Response, target interface{}) error

BindArray binds the response returned by the elasticsearch client to target(should be array)

func (*Elasticsearch) Body

func (e *Elasticsearch) Body(res *esapi.Response) (map[string]interface{}, error)

Body retrieves body from the response which returned by elasticsearch client

func (*Elasticsearch) HealthCheck

func (e *Elasticsearch) HealthCheck() types.Health

HealthCheck return the Health of the elastic search client

func (*Elasticsearch) Hits

func (e *Elasticsearch) Hits(res *esapi.Response) ([]interface{}, error)

Hits retrieves the data from the response which returned by elasticsearch client

func (*Elasticsearch) Ping

func (e *Elasticsearch) Ping() (*esapi.Response, error)

Ping makes a call to check connection with elastic search

type GORMClient

type GORMClient struct {
	*gorm.DB
	// contains filtered or unexported fields
}

GORMClient stores a GORM database client along with logger and configs to connect to GORM DB.

func NewORM

func NewORM(cfg *DBConfig) (GORMClient, error)

NewORM returns a new ORM object if the config is correct, otherwise it returns the error thrown

func NewORMFromEnv

func NewORMFromEnv() (GORMClient, error)

NewORMFromEnv fetches the config from environment variables and returns a new ORM object if the config was correct, otherwise returns the thrown error Deprecated: Instead use datastore.NewORM

func (GORMClient) HealthCheck

func (c GORMClient) HealthCheck() types.Health

HealthCheck pings the sql instance in gorm. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN

type MongoConfig

type MongoConfig struct {
	HostName          string
	Port              string
	Username          string
	Password          string
	Database          string
	SSL               bool
	RetryWrites       bool
	ConnRetryDuration int
}

MongoConfig holds the configurations for MongoDB Connectivity

type MongoDB

type MongoDB interface {
	Collection(name string, opts ...*options.CollectionOptions) *mongo.Collection
	Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
	RunCommand(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) *mongo.SingleResult
	RunCommandCursor(ctx context.Context, runCommand interface{}, opts ...*options.RunCmdOptions) (*mongo.Cursor, error)
	HealthCheck() types.Health
	IsSet() bool
}

MongoDB is an interface for accessing the base functionality

func GetMongoDBFromEnv

func GetMongoDBFromEnv(logger log.Logger) (MongoDB, error)

GetMongoDBFromEnv returns client to connect to MongoDB using configuration from environment variables Deprecated: Instead use datastore.GetNewMongoDB

func GetNewMongoDB

func GetNewMongoDB(logger log.Logger, config *MongoConfig) (MongoDB, error)

GetNewMongoDB connects to MongoDB and returns the connection with the specified database in the configuration

type QueryLogger

type QueryLogger struct {
	Hosts     string     `json:"host,omitempty"`
	Query     []string   `json:"query"`
	Duration  int64      `json:"duration"`
	StartTime time.Time  `json:"-"`
	Logger    log.Logger `json:"-"`
	DataStore string     `json:"datastore"`
}

QueryLogger represents a structure to log database queries.

func (*QueryLogger) AfterProcess

func (l *QueryLogger) AfterProcess(_ context.Context, cmd goRedis.Cmder) error

AfterProcess sets the metrics such as endTime, duration after the completion of the process

func (*QueryLogger) AfterProcessPipeline

func (l *QueryLogger) AfterProcessPipeline(_ context.Context, cmds []goRedis.Cmder) error

AfterProcessPipeline sets the metrics such as endTime, duration after the completion of the process

func (*QueryLogger) BeforeProcess

func (l *QueryLogger) BeforeProcess(ctx context.Context, _ goRedis.Cmder) (context.Context, error)

BeforeProcess sets the start time in the context and returns it.

func (*QueryLogger) BeforeProcessPipeline

func (l *QueryLogger) BeforeProcessPipeline(ctx context.Context, _ []goRedis.Cmder) (context.Context, error)

BeforeProcessPipeline sets the start time for slice of redis.Cmder in the context and returns it.

func (QueryLogger) ObserveBatch

func (l QueryLogger) ObserveBatch(_ context.Context, b gocql.ObservedBatch)

ObserveBatch monitors the connection in a particular fixed batch

func (QueryLogger) ObserveQuery

func (l QueryLogger) ObserveQuery(_ context.Context, o gocql.ObservedQuery)

ObserveQuery monitors the query that is sent.

func (*QueryLogger) String

func (l *QueryLogger) String() string

type Redis

type Redis interface {
	goRedis.UniversalClient
	HealthCheck() types.Health
	IsSet() bool
}

Redis is an abstraction that embeds the UniversalClient from go-redis/redis

func NewRedis

func NewRedis(logger log.Logger, config RedisConfig) (Redis, error)

NewRedis connects to Redis if the given config is correct, otherwise returns the error

func NewRedisCluster

func NewRedisCluster(clusterOptions *goRedis.ClusterOptions) (Redis, error)

NewRedisCluster returns a new Redis cluster client object if the given config is correct, otherwise returns the error

func NewRedisFromEnv

func NewRedisFromEnv(options *goRedis.Options) (Redis, error)

NewRedisFromEnv reads the config from environment variables and connects to redis if the config is correct, otherwise, returns the thrown error Deprecated: Instead use datastore.NewRedis

type RedisConfig

type RedisConfig struct {
	HostName                string
	Password                string
	Port                    string
	DB                      int
	SSL                     bool
	ConnectionRetryDuration int
	Options                 *goRedis.Options
}

RedisConfig stores the config variables required to connect to Redis, if Options is nil, then the Redis client will import the default configuration as defined in go-redis/redis. User defined config can be provided by populating the Options field.

type Request

type Request struct {
	*request.Request
	// contains filtered or unexported fields
}

Request stores an HTTP service request along with a DB QueryLogger to monitor the duration and execution plan of database queries.

func (*Request) Send

func (r *Request) Send() error

Send will send the request to dynamodb, returning error if errors are encountered.

type Response

type Response struct {
	Code int
	Data interface{}
}

Response stores the response from SOLR

type SQLClient

type SQLClient struct {
	*sql.DB
	// contains filtered or unexported fields
}

SQLClient stores a SQL database client along with logger and configs to connect to SQL DB.

func (*SQLClient) Begin

func (c *SQLClient) Begin() (*SQLTx, error)

Begin starts a transaction. The default isolation level is dependent on the driver.

func (*SQLClient) BeginTx

func (c *SQLClient) BeginTx(ctx context.Context, opts *sql.TxOptions) (*SQLTx, error)

BeginTx starts a transaction.

func (*SQLClient) Exec

func (c *SQLClient) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*SQLClient) ExecContext

func (c *SQLClient) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*SQLClient) Query

func (c *SQLClient) Query(query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

func (*SQLClient) QueryContext

func (c *SQLClient) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

func (*SQLClient) QueryRow

func (c *SQLClient) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow executes a query that is expected to return at most one row. QueryRow always returns a non-nil value. Errors are deferred until Row's Scan method is called.

func (*SQLClient) QueryRowContext

func (c *SQLClient) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRowContext executes a query that is expected to return at most one row. QueryRowContext always returns a non-nil value. Errors are deferred until Row's Scan method is called.

type SQLTx

type SQLTx struct {
	*sql.Tx
	// contains filtered or unexported fields
}

SQLTx represents a SQL Transaction.

func (*SQLTx) Commit

func (c *SQLTx) Commit() error

Commit commits the transaction.

func (*SQLTx) Exec

func (c *SQLTx) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a query that doesn't return rows.

func (*SQLTx) ExecContext

func (c *SQLTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

ExecContext executes a query that doesn't return rows.

func (*SQLTx) Query

func (c *SQLTx) Query(query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows, typically a SELECT.

func (*SQLTx) QueryContext

func (c *SQLTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT.

func (*SQLTx) QueryRow

func (c *SQLTx) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow executes a query that is expected to return at most one row. QueryRow always returns a non-nil value. Errors are deferred until Row's Scan method is called.

func (*SQLTx) QueryRowContext

func (c *SQLTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRowContext executes a query that is expected to return at most one row. QueryRowContext always returns a non-nil value. Errors are deferred until Row's Scan method is called.

type SQLXClient

type SQLXClient struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

SQLXClient stores a SQLX database client along with logger to connect to SQL DB.

func NewSQLX

func NewSQLX(cfg *DBConfig) (SQLXClient, error)

NewSQLX returns a new sqlx.DB object if the given config is correct, otherwise throws an error

func (SQLXClient) HealthCheck

func (c SQLXClient) HealthCheck() types.Health

HealthCheck pings the sqlx instance in gorm. If the ping does not return an error, the healthCheck status will be set to UP, else the healthCheck status will be DOWN

type Schema

type Schema interface {
	Retrieve(ctx context.Context, collection string, params map[string]interface{}) (interface{}, error)
	ListFields(ctx context.Context, collection string, params map[string]interface{}) (interface{}, error)
	AddField(ctx context.Context, collection string, document *bytes.Buffer) (interface{}, error)
	UpdateField(ctx context.Context, collection string, document *bytes.Buffer) (interface{}, error)
	DeleteField(ctx context.Context, collection string, document *bytes.Buffer) (interface{}, error)
}

Schema is an interface for managing schema-related operations in Solr.

type Seeder

type Seeder struct {
	*DataStore

	ResetCounter bool
	// contains filtered or unexported fields
}

Seeder represents a seeder for seeding data into database.

func NewSeeder

func NewSeeder(db *DataStore, directoryPath string) *Seeder

NewSeeder creates a new Seeder instance. It accepts a database DataStore and the directory path for data seeding.

func (*Seeder) AssertRowCount

func (d *Seeder) AssertRowCount(t tester, tableName string, count int)

AssertRowCount checks if the records expected are equal to the records retrieved

func (*Seeder) AssertVersion

func (d *Seeder) AssertVersion(t tester, version string)

AssertVersion checks if the version is valid or not

func (*Seeder) ClearTable

func (d *Seeder) ClearTable(t tester, tableName string)

ClearTable clears a particular table

func (*Seeder) RefreshCassandra

func (d *Seeder) RefreshCassandra(t tester, tableNames ...string)

RefreshCassandra refreshes the Cassandra index and inserts data from the .csv file

func (*Seeder) RefreshDynamoDB

func (d *Seeder) RefreshDynamoDB(t tester, tableNames ...string)

RefreshDynamoDB refreshes the DynamoDB state.

func (*Seeder) RefreshElasticSearch

func (d *Seeder) RefreshElasticSearch(t tester, indexes ...string)

RefreshElasticSearch refreshes the elastic search index and inserts data from the .csv file

func (*Seeder) RefreshMongoCollections

func (d *Seeder) RefreshMongoCollections(t tester, collectionNames ...string)

RefreshMongoCollections refreshes the Mongo index and inserts data from the .csv file

func (*Seeder) RefreshRedis

func (d *Seeder) RefreshRedis(t tester, tableNames ...string)

RefreshRedis refreshes the redis index and inserts data from the .csv file

func (*Seeder) RefreshTables

func (d *Seeder) RefreshTables(t tester, tableNames ...string)

RefreshTables The function will first clear the tables and then populate it with the test data for each table. The tables will have to be passed in the reverse order in which the dependency flows,i.e, the child first and then the parent

func (*Seeder) RefreshYCQL

func (d *Seeder) RefreshYCQL(t tester, tableNames ...string)

RefreshYCQL refreshes the YCQL index and inserts data from the .csv file

type YCQL

type YCQL struct {
	Cluster *gocql.ClusterConfig
	Session *gocql.Session
	// contains filtered or unexported fields
}

YCQL stores information about the YugabyteDB(CQL) cluster and open sessions

func GetNewYCQL

func GetNewYCQL(logger log.Logger, config *CassandraCfg) (YCQL, error)

GetNewYCQL creates and opens a connection to the NewYCQL cluster func GetNewYCQL(logger log.Logger, config *CassandraCfg) (YCQL, error) {

func (*YCQL) HealthCheck

func (y *YCQL) HealthCheck() types.Health

HealthCheck returns the health of the YCQL

Directories

Path Synopsis
Package pubsub implements the necessary methods and types to work with publish-subscribe messaging patterns.
Package pubsub implements the necessary methods and types to work with publish-subscribe messaging patterns.
avro
Package avro provides implementation methods for working with avro to serialize and deserialize messages.
Package avro provides implementation methods for working with avro to serialize and deserialize messages.
eventbridge
Package eventbridge provides methods to interact with AWS Eventbridge service allowing user to publish events to Eventbridge
Package eventbridge provides methods to interact with AWS Eventbridge service allowing user to publish events to Eventbridge
eventhub
Package eventhub provides methods to interact, publish and consume events from Azure Eventhub
Package eventhub provides methods to interact, publish and consume events from Azure Eventhub
google
Package google provides methods to work with Google Cloud Pub/Sub enabling the publishing and consumption of messages.
Package google provides methods to work with Google Cloud Pub/Sub enabling the publishing and consumption of messages.
kafka
Package kafka provides methods to interact with Apache Kafka offering functionality for both producing and consuming messages from kafka-topics.
Package kafka provides methods to interact with Apache Kafka offering functionality for both producing and consuming messages from kafka-topics.

Jump to

Keyboard shortcuts

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