cassandra

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSession

func GetSession(cluster ClusterDriver) (*driver.Session, error)

GetSession creates new GoCql connection if required, and returns the existing or newly creating session. The returned Session is a Singleton.

Types

type ClusterDriver

type ClusterDriver interface {
	CreateSession() (*cql.Session, error)
}

ClusterDriver is the implementation for Cassandra-driver.

type ColumnComparator

type ColumnComparator struct {
	Name  string
	Value interface{}
	// contains filtered or unexported fields
}

ColumnComparator Creates comparator for select queries

func Comparator added in v1.2.0

func Comparator(col string, value interface{}) ColumnComparator

Comparator is a convenience function to create a new ColumnComparator

func (ColumnComparator) Eq

Eq creates an Equality (=) operator

func (ColumnComparator) Gt

Gt creates a Greater-Than (>) operator

func (ColumnComparator) GtOrEq

func (cc ColumnComparator) GtOrEq() ColumnComparator

GtOrEq creates a Greater-Than-Or-Equals-To (>=) operator

func (ColumnComparator) In

In creates a Value-In-Array operator. The provided value must be an array.

func (ColumnComparator) Lt

Lt creates a Less-Than (<) operator

func (ColumnComparator) LtOrEq

func (cc ColumnComparator) LtOrEq() ColumnComparator

LtOrEq creates a Less-Than-Or-Equals-To (<=) operator

type Keyspace

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

Keyspace acts as utility-entity corresponding to Cassandra Keyspace.

func NewKeyspace

func NewKeyspace(session driver.SessionI, kc KeyspaceConfig) (*Keyspace, error)

NewKeyspace creates a new Keyspace-entity instance, and also creates the Keyspace in database if it doesn't exist.

func (*Keyspace) Alter

func (k *Keyspace) Alter(session driver.SessionI, kc KeyspaceConfig) (*Keyspace, error)

Alter allows changing replicationStrategy and replicationFactor of Keyspace.

func (*Keyspace) Name

func (k *Keyspace) Name() string

Name returns the name of Keyspace.

func (*Keyspace) ReplicationStrategy

func (k *Keyspace) ReplicationStrategy() string

ReplicationStrategy returns the replicationStrategy of Keyspace.

func (*Keyspace) ReplicationStrategyArgs

func (k *Keyspace) ReplicationStrategyArgs() map[string]int

ReplicationStrategyArgs returns the ReplicationStrategyArgs of Keyspace.

type KeyspaceConfig

type KeyspaceConfig struct {
	Name                    string
	ReplicationStrategy     string
	ReplicationStrategyArgs map[string]int
}

KeyspaceConfig defines configuration for Keyspace.

type SelectParams

type SelectParams struct {
	ColumnValues []ColumnComparator
	// Add LIMIT parameter to the query
	Limit    uint
	PageSize uint
	// This should be the pointer to a struct slice representing the
	// returned data. The results are loaded into provided slice.
	ResultsBind interface{}
	// The columns to add in SELECT statement
	SelectColumns []string
}

SelectParams defines parameters for a SELECT query.

type Table

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

Table contains functions to help interact with table, which was created using the provided definition.

func NewTable

func NewTable(
	session driver.SessionI,
	tc *TableConfig,
	definition *map[string]TableColumn,
) (*Table, error)

NewTable creates a new table in database (if a table doesn't exist). This always returns table-structures as per provided definition, even if the table already existed in database (in which case the provided-definition is still not cross-checked/synced with the actual table from database).

func (*Table) AsyncInsert

func (t *Table) AsyncInsert(dataStruct interface{}) <-chan error

AsyncInsert asynchronously inserts the specified data into table.

func (*Table) Column

func (t *Table) Column(columnName string) (string, error)

Column returns the column-name (as used in database) from specified common-name of column. Use this for referencing columns in table. Returns error if no column matching the provided common-name is found.

func (*Table) Columns

func (t *Table) Columns() []string

Columns returns all table-columns.

func (*Table) ColumnsWithDataType

func (t *Table) ColumnsWithDataType() [][]string

ColumnsWithDataType returns a two-dimensional slice containing column-name and data-type pairs.

func (*Table) Definition

func (t *Table) Definition() *map[string]TableColumn

Definition is the table detailed-structure, used to create the table and form its schema.

func (*Table) FullName

func (t *Table) FullName() string

FullName returns the table-name in keyspace.table format.

func (*Table) Keyspace

func (t *Table) Keyspace() *Keyspace

Keyspace returns the table keyspace as specified when creating new table. This can only be set when #NewTable function is called.

func (*Table) Name

func (t *Table) Name() string

Name returns the table name as specified when creating new table.

func (*Table) Schema

func (t *Table) Schema() *map[string]string

Schema returns table-schema exactly as represented in database. This can be used to create the table in database.

func (*Table) Select

func (t *Table) Select(p SelectParams) (interface{}, error)

Select gets data from table. This returns a slice of struct containing the returned data. This slice is same as specified in SelectParams.ResultsBind

func (*Table) Session

func (t *Table) Session() driver.SessionI

Session returns the database-session used to create the table instance.

type TableColumn

type TableColumn struct {
	Name            string
	DataType        string
	PrimaryKeyIndex string
	PrimaryKeyOrder string
}

TableColumn represents column-definition for database.

type TableConfig

type TableConfig struct {
	Keyspace *Keyspace
	Name     string
}

TableConfig defines configuration for Table.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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