...

Package tibdg

import "tibco.com/tibdg"
Overview
Index

Overview ▾

Package tibdg provides the TIBCO ActiveSpaces API for the Go programming language.

Copyright Cloud Software Group, Inc.

Introduction to the TIBCO ActiveSpaces Go API

The following sections briefly describe how to use the Go API. Refer to the Concepts guide for more details on the concepts employed.

The code fragments are simplified for illustrative purposes. In particular, there is no error checking. See the operations.go sample program for a more complete example.

Setting up the Connection, Session and Table

The first thing any program will need to do is connect to the data grid and then create a Session object to provide a context for the subsequent operations and a Table object for the table on which to do the operations:

connection, err := tibdg.NewConnection("http://localhost:8080", "", nil)
session, err := connection.NewSession(nil)
table, err := session.OpenTable("t1", nil)

A Session should only be used in a single Go routine.

In the above code, the type of Session that is created is a non-transactional one, so any operations on the Table will be applied immediately rather than requiring the program to call Commit() on the Session.

Putting a Row into a table

To add data to the Table the program creates a Row containing the appropriate data and then calls table.Put(row) to put the data into the Table. In the code fragment below, two rows are put into the table:

row1, err := table.NewRow()
content := tibdg.RowContent{"key": 1, "value": "Hello"}
err = row1.Set(content)
err = table.Put(row1)
row1.Destroy()

row2, err := table.NewRow()
content["key"] = 2
content["value"] = "World"
err = row2.Set(content)
err = table.Put(row2)
row2.Destroy()

Once the Row has been Put into the Table, the Row can either be re-used or destroyed. A Row object should only be used with the Table object that created it.

Getting a Row from a table

To retrieve a Row from a Table the program creates a Row object and sets the primary key fields to match those of the Row to be fetched. This "key row" is then passed to table.Get(), which returns a new Row containing the data retrieved from the Table.

keyRow, err := table.NewRow()
content := tibdg.RowContent{"key": 1}
err = keyRow.Set(content)
getRow, err := table.Get(keyRow)
keyRow.Destroy()
if getRow != nil {
    getRow.Destroy()
}

If there is no Row with the given key, then table.Get() return will nil. The program must destory both Row objects.

Querying a table

To retrieve multiple rows from the table the program uses an Iterator created with a filter expression that is used to match the Rows to be returned:

iterator, err := table.NewIterator("key = 1 OR key = 2", nil)
for hasNext, err := iterator.HasNext(); hasNext; hasNext, err = iterator.HasNext() {
    nextRow, err := iterator.Next()
    nextRow.Destroy()
}
iterator.Close()

To iterate over all the Rows in the Table specify nil for the filter.

Destroying the Table and Session, then closing the Connection

When the program has completed all its operations on a given Table, it should close the Table. When all processing is complete, the program should destroy the Session and close the Connection.

table.Close()
session.Destroy()
connection.Close()

It is usually good practice to use defer to call these destructors to ensure they get called even if the program encounters some sort of error. For example:

connection, err := tibdg.NewConnection("http://localhost:8080", "", nil)
defer connection.Close()

Index ▾

Constants
func ErrStack(e error) string
func EventTypeListToString(eventTypeList []EventType) (string, error)
func SetLogChannel(out chan *LogEntry) error
func SetLogFiles(filePrefix string, maxFileSize int64, maxFiles int32, p Props) error
func SetLogLevel(level string) error
type BatchResult
    func (br *BatchResult) AllSucceeded() (success bool, err error)
    func (br *BatchResult) Destroy() error
    func (br *BatchResult) GetRow(rowNum int) (row *Row, err error)
    func (br *BatchResult) GetSize() (sz int, err error)
type ColumnMetadata
type ColumnType
    func ColumnTypeFromString(columnTypeString string) (columnType ColumnType, err error)
    func (columnType ColumnType) String() (ret string)
type Connection
    func NewConnection(url string, gridName string, props Props) (conn *Connection, err error)
    func (conn *Connection) Close() error
    func (conn *Connection) GetGridMetadata(props Props) (gmd *GridMetadata, err error)
    func (conn *Connection) NewSession(props Props) (sess *Session, err error)
type DeleteEvent
    func (deleteEvent *DeleteEvent) Destroy()
    func (deleteEvent DeleteEvent) EventType() EventType
    func (deleteEvent *DeleteEvent) Listener() *Listener
    func (deleteEvent *DeleteEvent) String() string
type ErrorCode
    func ErrCode(e error) ErrorCode
type ErrorEvent
    func (errorEvent *ErrorEvent) Destroy()
    func (errorEvent ErrorEvent) EventType() EventType
    func (errorEvent *ErrorEvent) Listener() *Listener
    func (errorEvent *ErrorEvent) String() string
type Event
type EventErrorCode
    func (eventErrorCode EventErrorCode) String() (ret string)
type EventType
    func (eventType EventType) String() (ret string)
type ExpiredEvent
    func (expiredEvent *ExpiredEvent) Destroy()
    func (expiredEvent ExpiredEvent) EventType() EventType
    func (expiredEvent *ExpiredEvent) Listener() *Listener
    func (expiredEvent *ExpiredEvent) String() string
type GridMetadata
type IndexMetadata
type Iterator
    func (iter *Iterator) Close() error
    func (iter *Iterator) HasNext() (hasNext bool, err error)
    func (iter *Iterator) Next() (nextRow *Row, err error)
type Listener
    func (listener *Listener) Destroy() error
type LogEntry
type Props
type PutEvent
    func (putEvent *PutEvent) Destroy()
    func (putEvent PutEvent) EventType() EventType
    func (putEvent *PutEvent) Listener() *Listener
    func (putEvent *PutEvent) String() string
type ResultColumnMetadata
type ResultSet
    func (rs *ResultSet) Close() error
    func (rs *ResultSet) HasNext() (hasNext bool, err error)
    func (rs *ResultSet) Next() (nextRow *Row, err error)
type ResultSetMetadata
type Row
    func (r Row) Clear() error
    func (r *Row) Copy() (copy *Row, err error)
    func (r *Row) Destroy() error
    func (r *Row) Get(columns ...string) (c RowContent, err error)
    func (r *Row) GetColumnType(name string) (ColumnType, error)
    func (r *Row) GetExpiration() (time.Time, error)
    func (r *Row) IsColumnSet(name string) (b bool, err error)
    func (r *Row) Set(c RowContent) (ex error)
    func (r *Row) SetTTL(ttl int64) error
    func (r *Row) String() string
    func (r *Row) Update(c RowContent) (ex error)
type RowContent
type Session
    func (session *Session) Commit() error
    func (session *Session) DeleteRows(rows []*Row, props Props) (br *BatchResult, err error)
    func (session *Session) Destroy() error
    func (session *Session) ExecuteUpdate(sqlString string, props Props) (int64, error)
    func (session *Session) GetRows(rows []*Row, props Props) (br *BatchResult, err error)
    func (session *Session) NewStatement(sqlString string, props Props) (stmt *Statement, err error)
    func (session *Session) OpenTable(name string, props Props) (tab *Table, err error)
    func (session *Session) PutRows(rows []*Row, props Props) (br *BatchResult, err error)
    func (session *Session) Rollback() error
type Statement
    func (stmt *Statement) ClearParameters() error
    func (stmt *Statement) Close() error
    func (stmt *Statement) ExecuteQuery(props Props) (rs *ResultSet, err error)
    func (stmt *Statement) ExecuteUpdate(props Props) (count int64, err error)
    func (stmt *Statement) SetFloat(parameterIndex int, float float64) error
    func (stmt *Statement) SetLong(parameterIndex int, long int64) error
    func (stmt *Statement) SetNull(parameterIndex int) error
    func (stmt *Statement) SetOpaque(parameterIndex int, opaque []byte) error
    func (stmt *Statement) SetString(parameterIndex int, str string) error
    func (stmt *Statement) SetTime(parameterIndex int, time time.Time) error
type Table
    func (table *Table) Close() error
    func (table *Table) Delete(key *Row) error
    func (table *Table) Get(key *Row) (r *Row, err error)
    func (table *Table) NewIterator(filter string, props Props) (iter *Iterator, err error)
    func (table *Table) NewListener(filter string, props Props, channel chan Event) (lsnr *Listener, err error)
    func (table *Table) NewRow() (r *Row, err error)
    func (table *Table) Put(keyValue *Row) error
type TableMetadata

Package files

batchresult.go connection.go doc.go exception.go iterator.go listener.go metadata.go pin.go props.go resultset.go row.go session.go statement.go table.go tibdg.go version.go

Constants

Connection property names

const (
    ConnectionPropertyDoubleConnectWaitTime   string = C.TIBDG_CONNECTION_PROPERTY_DOUBLE_CONNECT_WAIT_TIME
    ConnectionPropertyDoubleTimeout           string = C.TIBDG_CONNECTION_PROPERTY_DOUBLE_TIMEOUT
    ConnectionPropertyLongBindStrategy        string = C.TIBDG_CONNECTION_PROPERTY_LONG_BINDSTRATEGY
    ConnectionPropertyLongConnectNumResponses string = C.TIBDG_CONNECTION_PROPERTY_LONG_CONNECT_NUMRESPONSES
    ConnectionPropertyLongConnectRetries      string = C.TIBDG_CONNECTION_PROPERTY_LONG_REALM_CONNECT_RETRIES
    ConnectionPropertyStringClientLabel       string = C.TIBDG_CONNECTION_PROPERTY_STRING_CLIENT_LABEL
    ConnectionPropertyStringConnectProxyNames string = C.TIBDG_CONNECTION_PROPERTY_STRING_CONNECT_PROXYNAMES
    ConnectionPropertyStringSecondaryRealm    string = C.TIBDG_CONNECTION_PROPERTY_STRING_SECONDARY_REALM
    ConnectionPropertyStringTrustFile         string = C.TIBDG_CONNECTION_PROPERTY_STRING_TRUST_FILE
    ConnectionPropertyStringTrustType         string = C.TIBDG_CONNECTION_PROPERTY_STRING_TRUST_TYPE
    ConnectionPropertyStringUsername          string = C.TIBDG_CONNECTION_PROPERTY_STRING_USERNAME
    ConnectionPropertyStringUserPassword      string = C.TIBDG_CONNECTION_PROPERTY_STRING_USERPASSWORD
)

Values for connection property ConnectionPropertyStringTrustType

const (
    ConnectionHTTPSConnectionTrustEveryone         string = C.TIBDG_CONNECTION_HTTPS_CONNECTION_TRUST_EVERYONE
    ConnectionHTTPSConnectionUseSpecifiedTrustFile string = C.TIBDG_CONNECTION_HTTPS_CONNECTION_USE_SPECIFIED_TRUST_FILE
)

Values for connection property ConnectionPropertyLongBindStrategy

const (
    ConnectionBindStrategyRandom int64 = C.TIBDG_CONNECTION_BINDSTRATEGY_RANDOM
    ConnectionBindStrategyNamed  int64 = C.TIBDG_CONNECTION_BINDSTRATEGY_NAMED
)

Iterator property names

const (
    IteratorPropertyLongPrefetch       string = C.TIBDG_ITERATOR_PROPERTY_LONG_PREFETCH
    IteratorPropertyStringConsistency  string = C.TIBDG_ITERATOR_PROPERTY_STRING_CONSISTENCY
    IteratorPropertyDoubleFetchTimeout string = C.TIBDG_ITERATOR_PROPERTY_DOUBLE_FETCH_TIMEOUT
)

Values for IteratorPropertyStringConsistency

const (
    IteratorConsistencyGlobalSnapshot string = C.TIBDG_ITERATOR_CONSISTENCY_GLOBAL_SNAPSHOT
    IteratorConsistencySnapshot       string = C.TIBDG_ITERATOR_CONSISTENCY_SNAPSHOT
)

Session properties

const (
    SessionPropertyBooleanTransacted    string = C.TIBDG_SESSION_PROPERTY_BOOLEAN_TRANSACTED
    SessionPropertyStringCheckpointName string = C.TIBDG_SESSION_PROPERTY_STRING_CHECKPOINT_NAME
)

Statement properties

const (
    StatementPropertyLongPrefetch       string = C.TIBDG_STATEMENT_PROPERTY_LONG_PREFETCH
    StatementPropertyStringConsistency  string = C.TIBDG_STATEMENT_PROPERTY_STRING_CONSISTENCY
    StatementPropertyDoubleFetchTimeout string = C.TIBDG_STATEMENT_PROPERTY_DOUBLE_FETCH_TIMEOUT
)

Values for StatementPropertyStringConsistency property

const (
    StatementConsistencyGlobalSnapshot string = C.TIBDG_STATEMENT_CONSISTENCY_GLOBAL_SNAPSHOT
    StatementConsistencySnapshot       string = C.TIBDG_STATEMENT_CONSISTENCY_SNAPSHOT
)

Specify log level for the SetLogLevel function

const (
    LogLevelOff     string = C.TIB_LOG_LEVEL_OFF
    LogLevelSevere  string = C.TIB_LOG_LEVEL_SEVERE
    LogLevelWarn    string = C.TIB_LOG_LEVEL_WARN
    LogLevelInfo    string = C.TIB_LOG_LEVEL_INFO
    LogLevelVerbose string = C.TIB_LOG_LEVEL_VERBOSE
    LogLevelDebug   string = C.TIB_LOG_LEVEL_DEBUG
)
const (
    ASVersionMajorNum  = 4
    ASVersionMinorNum  = 3
    ASVersionUpdateNum = 0
    ASVersionBuildNum  = 2

    ASVersionMajorString       = "4"
    ASVersionMinorString       = "3"
    ASVersionUpdateString      = "0"
    ASVersionBuildString       = "2"
    ASVersionReleaseTypeString = ""

    ASVersionStringCompare = "4.3.0 "

    ASVersionStringShort = "4.3.0  V2"
    ASVersionStringLong  = "TIBCO Active Spaces Version " + ASVersionStringShort

    ASVersionCopyright = "\nCopyright  Cloud Software Group, Inc.\nAll Rights Reserved. Confidential & Proprietary.\n"

    ASVersionBanner = ASVersionStringLong + ASVersionCopyright
)

GridMetadata properties

const (
    GridMetadataPropertyStringCheckpointName string = C.TIBDG_GRIDMETADATA_PROPERTY_STRING_CHECKPOINT_NAME
)

Listener properties

const (
    ListenerPropertyStringEventTypeList string = C.TIBDG_LISTENER_PROPERTY_STRING_EVENT_TYPE_LIST
)

func ErrStack

func ErrStack(e error) string

ErrStack returns a stack trace for an TIBDG error.

If the error passed in to this function was generated by the tibdg library, this will return a detailed description of the error, including the C stack trace associated with it, if available. If the error is not a tibdg error, this returns the results of calling e.Error().

func EventTypeListToString

func EventTypeListToString(eventTypeList []EventType) (string, error)

EventTypeListToString converts a list of EventTypes to a string

func SetLogChannel

func SetLogChannel(out chan *LogEntry) error

SetLogChannel changes logging from stdout to the provided channel.

func SetLogFiles

func SetLogFiles(filePrefix string, maxFileSize int64, maxFiles int32, p Props) error

SetLogFiles changes logging from stdout to append log messages to files based on the filePrefix.

func SetLogLevel

func SetLogLevel(level string) error

SetLogLevel will generate log messages for this log level. By default, logging goes to stdout, but SetLogChannel and SetLogFiles can be used to change that.

type BatchResult

BatchResult objects encapsulate the results of a single batch of operations.

They are returned by Session.GetRows(), Session.PutRows() and Session.DeleteRows().

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

func (*BatchResult) AllSucceeded

func (br *BatchResult) AllSucceeded() (success bool, err error)

AllSucceeded reports whether or not all the operations in the batch succeeded.

func (*BatchResult) Destroy

func (br *BatchResult) Destroy() error

Destroy explicitly destroys a BatchResult object and reclaims its resources.

func (*BatchResult) GetRow

func (br *BatchResult) GetRow(rowNum int) (row *Row, err error)

GetRow returns a specific row from the BatchResult.

This is only valid for GET batches. You must call AllSucceeded prior to this to ensure the batch succeeded.

func (*BatchResult) GetSize

func (br *BatchResult) GetSize() (sz int, err error)

GetSize returns the number of rows in the BatchResult.

type ColumnMetadata

ColumnMetadata objects contain information about a specific column

type ColumnMetadata struct {
    Name          string         // the name of the column
    Type          ColumnType     // the type of the column
    TableMetadata *TableMetadata // a pointer to the table metadata for the table the column belongs to
}

type ColumnType

ColumnType represents the type of a column in a table

type ColumnType int

These are all the possible values for ColumnType.

const (
    ColumnTypeInvalid  ColumnType = C.TIBDG_COLUMN_TYPE_INVALID
    ColumnTypeLong     ColumnType = C.TIBDG_COLUMN_TYPE_LONG
    ColumnTypeString   ColumnType = C.TIBDG_COLUMN_TYPE_STRING
    ColumnTypeOpaque   ColumnType = C.TIBDG_COLUMN_TYPE_OPAQUE
    ColumnTypeDatetime ColumnType = C.TIBDG_COLUMN_TYPE_DATETIME
    ColumnTypeDouble   ColumnType = C.TIBDG_COLUMN_TYPE_DOUBLE
    ColumnTypeUnknown  ColumnType = C.TIBDG_COLUMN_TYPE_UNKNOWN
)

func ColumnTypeFromString

func ColumnTypeFromString(columnTypeString string) (columnType ColumnType, err error)

ColumnTypeFromString parses the string and returns the corresponding ColumnType.

func (ColumnType) String

func (columnType ColumnType) String() (ret string)

String returns the column type as a string

type Connection

Connection objects provide access to a data grid.

The Connection object creates or opens all resources associated with a given data grid. A program that creates a connection can explicitly call Connection.Close() to reclaim its resources.

type Connection struct {
    RealmURL   string // the URL of the realm
    Properties Props  // a copy of the properties supplied when creating the Connection
    // contains filtered or unexported fields
}

func NewConnection

func NewConnection(url string, gridName string, props Props) (conn *Connection, err error)

NewConnection creates a new Connection to the data grid.

func (*Connection) Close

func (conn *Connection) Close() error

Close closes the Connection to the data grid and frees the underlying resources.

func (*Connection) GetGridMetadata

func (conn *Connection) GetGridMetadata(props Props) (gmd *GridMetadata, err error)

GetGridMetadata returns a GridMetadata object that can be used to get information about the data grid.

Note that the GridMetadata object returned contains a snapshot of the data grid at that the time the object is being created. If tables are subsequently created, modified or destroyed, those changes will not be reflected in any GridMetadata that was created previously.

To access the metadata for the data grid at a specific checkpoint, pass in a Props object with the the property GridMetadataPropertyStringCheckpointName set to the name of the checkpoint.

func (*Connection) NewSession

func (conn *Connection) NewSession(props Props) (sess *Session, err error)

NewSession creates a new Session object for performing operations on the data grid.

type DeleteEvent

DeleteEvent objects are Events that indicate that a row was Deleted from the table.

type DeleteEvent struct {
    Previous *Row // the value of the Row prior to deletion
    // contains filtered or unexported fields
}

func (*DeleteEvent) Destroy

func (deleteEvent *DeleteEvent) Destroy()

Destroy destroys the Event, reclaiming all its resources.

func (DeleteEvent) EventType

func (deleteEvent DeleteEvent) EventType() EventType

EventType returns the type of the Event.

func (*DeleteEvent) Listener

func (deleteEvent *DeleteEvent) Listener() *Listener

Listener returns a pointer to the Listener that generated the PutEvent.

func (*DeleteEvent) String

func (deleteEvent *DeleteEvent) String() string

String returns a string representation of the Event

type ErrorCode

ErrorCode is a numeric error code that will always be one of the error constants defined below

type ErrorCode int

Error constants returned by ErrCode()

const (
    ErrUnknown                ErrorCode = -2
    ErrNullException          ErrorCode = C.TIB_NULL_EXCEPTION
    ErrOk                     ErrorCode = C.TIB_OK
    ErrInvalidArg             ErrorCode = C.TIB_INVALID_ARG
    ErrNoMemory               ErrorCode = C.TIB_NO_MEMORY
    ErrTimeout                ErrorCode = C.TIB_TIMEOUT
    ErrNotInitialized         ErrorCode = C.TIB_NOT_INITIALIZED
    ErrOsError                ErrorCode = C.TIB_OS_ERROR
    ErrIntr                   ErrorCode = C.TIB_INTR
    ErrNotPermitted           ErrorCode = C.TIB_NOT_PERMITTED
    ErrNotFound               ErrorCode = C.TIB_NOT_FOUND
    ErrIllegalState           ErrorCode = C.TIB_ILLEGAL_STATE
    ErrNotSupported           ErrorCode = C.TIB_NOT_SUPPORTED
    ErrEndOfBuffer            ErrorCode = C.TIB_END_OF_BUFFER
    ErrVersionMismatch        ErrorCode = C.TIB_VERSION_MISMATCH
    ErrAlreadyExists          ErrorCode = C.TIB_ALREADY_EXISTS
    ErrFileIoError            ErrorCode = C.TIB_FILE_IO_ERROR
    ErrInvalidValue           ErrorCode = C.TIB_INVALID_VALUE
    ErrInvalidType            ErrorCode = C.TIB_INVALID_TYPE
    ErrInvalidConfig          ErrorCode = C.TIB_INVALID_CONFIG
    ErrInvalidFormat          ErrorCode = C.TIB_INVALID_FORMAT
    ErrClientShutdown         ErrorCode = C.TIB_CLIENT_SHUTDOWN
    ErrResourceUnavailable    ErrorCode = C.TIB_RESOURCE_UNAVAILABLE
    ErrLimitReached           ErrorCode = C.TIB_LIMIT_REACHED
    ErrFormatUnavailable      ErrorCode = C.TIB_FORMAT_UNAVAILABLE
    ErrException              ErrorCode = C.TIB_EXCEPTION
    ErrUnknownSysprop         ErrorCode = C.TIB_UNKNOWN_SYSPROP
    ErrRsUnknownError         ErrorCode = C.TIB_RS_UNKNOWN_ERROR
    ErrRsInvalidSessionUser   ErrorCode = C.TIB_RS_INVALID_SESSION_USER
    ErrRsUnknownOperationCode ErrorCode = C.TIB_RS_UNKNOWN_OPERATION_CODE
    ErrRsInternalServerError  ErrorCode = C.TIB_RS_INTERNAL_SERVER_ERROR
    ErrRsProtocolMismatch     ErrorCode = C.TIB_RS_PROTOCOL_MISMATCH
    ErrRsMissingProtocol      ErrorCode = C.TIB_RS_MISSING_PROTOCOL
    ErrRsMissingClientID      ErrorCode = C.TIB_RS_MISSING_CLIENT_ID
    ErrRsKeyNotFound          ErrorCode = C.TIB_RS_KEY_NOT_FOUND
    ErrRsServerIsntPaused     ErrorCode = C.TIB_RS_SERVER_ISNT_PAUSED
    ErrRsServerIsReadonly     ErrorCode = C.TIB_RS_SERVER_IS_READONLY
    ErrRsServerIsShuttingDown ErrorCode = C.TIB_RS_SERVER_IS_SHUTTING_DOWN
    ErrRsServerIsStartingUp   ErrorCode = C.TIB_RS_SERVER_IS_STARTING_UP
    ErrRsDbGenerationMismatch ErrorCode = C.TIB_RS_DB_GENERATION_MISMATCH
    ErrRsInvalidState         ErrorCode = C.TIB_RS_INVALID_STATE
    ErrRsInvalidMode          ErrorCode = C.TIB_RS_INVALID_MODE
    ErrRsAdminOperationFailed ErrorCode = C.TIB_RS_ADMIN_OPERATION_FAILED
    ErrRsUpdateInProgress     ErrorCode = C.TIB_RS_UPDATE_IN_PROGRESS
    ErrRsIncompatibleClient   ErrorCode = C.TIB_RS_INCOMPATIBLE_CLIENT
    ErrInvalidResource        ErrorCode = C.TIBDG_INVALID_RESOURCE
    ErrGridInMaintenance      ErrorCode = C.TIBDG_GRID_IN_MAINTENANCE
    ErrSQLSyntaxError         ErrorCode = C.TIBDG_SQL_SYNTAX_ERROR
    ErrSQLNotSupported        ErrorCode = C.TIBDG_SQL_NOT_SUPPORTED
    ErrSQLInvalidValue        ErrorCode = C.TIBDG_SQL_INVALID_VALUE
    ErrSQLParserError         ErrorCode = C.TIBDG_SQL_PARSER_ERROR
    ErrSQLStmtError           ErrorCode = C.TIBDG_SQL_STMT_ERROR
    ErrSQLSystemError         ErrorCode = C.TIBDG_SQL_SYSTEM_ERROR
    ErrSQLQueryError          ErrorCode = C.TIBDG_SQL_QUERY_ERROR
    ErrSQLDdlCmdError         ErrorCode = C.TIBDG_SQL_DDL_CMD_ERROR
    ErrSQLQueryCmdError       ErrorCode = C.TIBDG_SQL_QUERY_CMD_ERROR
    ErrSQLDmlCmdError         ErrorCode = C.TIBDG_SQL_DML_CMD_ERROR
    ErrSQLCmdError            ErrorCode = C.TIBDG_SQL_CMD_ERROR
    ErrSQLNotPermitted        ErrorCode = C.TIBDG_SQL_NOT_PERMITTED
)

func ErrCode

func ErrCode(e error) ErrorCode

ErrCode returns the numeric error code from a tibdg error.

If the error passed to this function was generated by tibdg, this will return the ErrorCode associated with it. If an error is passed in that did NOT originate from the tibdg library, ErrUnknown is returned.

type ErrorEvent

ErrorEvent objects are Events that indicate the Listener encountered an error.

type ErrorEvent struct {
    ErrorCode        EventErrorCode // the type of error
    ErrorDescription string         // a description of the error
    // contains filtered or unexported fields
}

func (*ErrorEvent) Destroy

func (errorEvent *ErrorEvent) Destroy()

Destroy destroys the Event, reclaiming all its resources.

func (ErrorEvent) EventType

func (errorEvent ErrorEvent) EventType() EventType

EventType returns the type of the Event.

func (*ErrorEvent) Listener

func (errorEvent *ErrorEvent) Listener() *Listener

Listener returns a pointer to the Listener that generated the ErrorEvent.

func (*ErrorEvent) String

func (errorEvent *ErrorEvent) String() string

String returns a string representation of the Event

type Event

Event is an interface that is implemented by all types of Event.

type Event interface {
    EventType() EventType // EventType returns the type of the Event
    Destroy()             // Destroy destroys the underlying event
    Listener() *Listener  // Listener provides a pointer to the Listener that generated the Event
    String() string       // Return a string representation of the Event
}

type EventErrorCode

EventErrorCode is the type of error that the ErrorEvent is reporting.

type EventErrorCode int

These are all the possible values for EventErrorCode.

const (
    EventErrorCodeInvalid              EventErrorCode = C.TIBDG_EVENT_ERROR_CODE_INVALID
    EventErrorCodeTableDeleted         EventErrorCode = C.TIBDG_EVENT_ERROR_CODE_TABLE_DELETED
    EventErrorCodeCopysetLeaderFailure EventErrorCode = C.TIBDG_EVENT_ERROR_CODE_COPYSET_LEADER_FAILURE
    EventErrorCodeGridRedistributing   EventErrorCode = C.TIBDG_EVENT_ERROR_CODE_GRID_REDISTRIBUTING
    EventErrorCodeProxyFailure         EventErrorCode = C.TIBDG_EVENT_ERROR_CODE_PROXY_FAILURE
)

func (EventErrorCode) String

func (eventErrorCode EventErrorCode) String() (ret string)

String returns a string representation of the EventErrorCode.

type EventType

EventType is used to indicate the type of the Event.

type EventType int

These are all the possible values for EventType.

const (
    EventTypeInvalid EventType = C.TIBDG_EVENT_TYPE_INVALID
    EventTypePut     EventType = C.TIBDG_EVENT_TYPE_PUT
    EventTypeDelete  EventType = C.TIBDG_EVENT_TYPE_DELETE
    EventTypeError   EventType = C.TIBDG_EVENT_TYPE_ERROR
    EventTypeExpired EventType = C.TIBDG_EVENT_TYPE_EXPIRED
)

func (EventType) String

func (eventType EventType) String() (ret string)

String returns a string representation of the Event.

type ExpiredEvent

ExpiredEvent objects are that indicate that a row in the table was removed because it expired.

type ExpiredEvent struct {
    Previous *Row // the value of the Row prior to expiration
    // contains filtered or unexported fields
}

func (*ExpiredEvent) Destroy

func (expiredEvent *ExpiredEvent) Destroy()

Destroy destroys the event, reclaiming all its resources.

func (ExpiredEvent) EventType

func (expiredEvent ExpiredEvent) EventType() EventType

EventType returns the type of the Event.

func (*ExpiredEvent) Listener

func (expiredEvent *ExpiredEvent) Listener() *Listener

Listener returns a pointer to the Listener that generated the ExpiredEvent.

func (*ExpiredEvent) String

func (expiredEvent *ExpiredEvent) String() string

String returns a string representation of the Event

type GridMetadata

GridMetadata objects contain metadata information about the data grid and the tables in the data grid.

type GridMetadata struct {
    Name       string                   // the name of the grid
    Version    string                   // the version of the software the grid is using
    Tables     map[string]TableMetadata // a map of the table metadata for the tables in the grid, keyed by table name
    Connection *Connection              // the connection that created the grid metadata
}

type IndexMetadata

IndexMetadata objects contain information about a specific index

type IndexMetadata struct {
    Name          string           // the name of the index
    Columns       []ColumnMetadata // the columns that comprise the index
    TableMetadata *TableMetadata   // a pointer to the table metadata for the table the column belongs to
}

type Iterator

Iterator objects traverse the rows of a Table, or a subset of them if a filter was used when creating the Iterator.

type Iterator struct {
    Table *Table // the Table that will be iterated over
    // contains filtered or unexported fields
}

func (*Iterator) Close

func (iter *Iterator) Close() error

Close explicitly releases the resources associated with the Iterator.

func (*Iterator) HasNext

func (iter *Iterator) HasNext() (hasNext bool, err error)

HasNext informs the caller if the Iterator has more rows or not.

func (*Iterator) Next

func (iter *Iterator) Next() (nextRow *Row, err error)

Next advances the iterator to the next row and returns it.

This call advances the iterator beyond the current row. If the next row exists, this call returns it. If the current row is the last or if an exception has been thrown, this call returns NULL.

This call may block in order to fetch the next batch of rows.

type Listener

A Listener is created on a Table and sends Events to its Channel when changes take place in the underlying table.

type Listener struct {
    Filter  string     // the Filter parameter used when the Listener was created
    Table   *Table     // the Table on which to listen
    Channel chan Event // the channel on which the Events will be sent
    // contains filtered or unexported fields
}

func (*Listener) Destroy

func (listener *Listener) Destroy() error

Destroy explicitly destroys a Listener object and reclaims its resources.

type LogEntry

LogEntry values can be received when using SetLogChannel

type LogEntry struct {
    Timestamp time.Time
    Statement string
}

type Props

Props type is used for tibdg functions that take a properties argument.

Various properties are defined as constants throughout the interface.

type Props map[string]interface{}

type PutEvent

PutEvent objects are Events that indicate that a row was Put into the table.

type PutEvent struct {
    Previous *Row // the value of the Row prior to the Put
    Current  *Row // the value of the Row that was Put into the table
    // contains filtered or unexported fields
}

func (*PutEvent) Destroy

func (putEvent *PutEvent) Destroy()

Destroy destroys the Event, reclaiming all its resources.

func (PutEvent) EventType

func (putEvent PutEvent) EventType() EventType

EventType returns the type of the Event.

func (*PutEvent) Listener

func (putEvent *PutEvent) Listener() *Listener

Listener returns a pointer to the Listener that generated the PutEvent.

func (*PutEvent) String

func (putEvent *PutEvent) String() string

String returns a string representation of the Event

type ResultColumnMetadata

ResultColumnMetadata objects provide information about columns in a Statement's results.

type ResultColumnMetadata struct {
    Name      string     // the name of the column in the underlying table (if this column exists in the table)
    Label     string     // the name of the column in the resultset
    Type      ColumnType // the type of the column
    TableName string     // the name of the table the column comes from
    Nullable  bool       // indicates whether or not this column can contain null values
}

type ResultSet

ResultSet objects are created when a Statement is executed.

They contain the results of executing the Statement in the form of Rows.

type ResultSet struct {
    Statement *Statement // the Statement that generated the ResultSet
    // contains filtered or unexported fields
}

func (*ResultSet) Close

func (rs *ResultSet) Close() error

Close explicitly closes a ResultSet object and reclaims its resources.

func (*ResultSet) HasNext

func (rs *ResultSet) HasNext() (hasNext bool, err error)

HasNext informs the caller if the ResultSet has more Rows or not.

func (*ResultSet) Next

func (rs *ResultSet) Next() (nextRow *Row, err error)

Next advances the ResultSet to the next Row and returns it.

This call advances the ResultSet beyond the current Row. If the next Row exists, this call returns it. If the current Row is the last or if an exception has been thrown, this call returns NULL. Note that the data in the Row that is returned can be accessed but the Row cannot be used for table operations such as Put, Get, etc.

This call may block in order to fetch the next batch of rows.

type ResultSetMetadata

ResultSetMetadata objects describe the columns in the Statement's ResultSet.

type ResultSetMetadata struct {
    Columns   []ResultColumnMetadata // the columns in the ResultSet
    Statement *Statement             // the Statement that generated the ResultSet
}

type Row

Row represents a row of data from a table.

type Row struct {
    Table *Table // the Table containing the Row, may be nil if the Row belongs to a ResultSet.
    // contains filtered or unexported fields
}

func (Row) Clear

func (r Row) Clear() error

Clear the content of a row to preserve space.

func (*Row) Copy

func (r *Row) Copy() (copy *Row, err error)

Copy returns a copy of the Row and all its data.

func (*Row) Destroy

func (r *Row) Destroy() error

Destroy explicitly destroys a Row object and reclaims its resources.

func (*Row) Get

func (r *Row) Get(columns ...string) (c RowContent, err error)

Get all or at most specific values stored in the row Only columns present in the row will end up in the returned RowContent This is true even if the field was explicitly listed for retrieval.

func (*Row) GetColumnType

func (r *Row) GetColumnType(name string) (ColumnType, error)

GetColumnType returns the type of the named column.

func (*Row) GetExpiration

func (r *Row) GetExpiration() (time.Time, error)

GetExpiration returns the expiration time for the row.

It is an error to call this on a Row if the Row's table does not have expiration enabled or if the Row was not retrieved from a Table or Iterator.

func (*Row) IsColumnSet

func (r *Row) IsColumnSet(name string) (b bool, err error)

IsColumnSet indicates whether or not the named column is set in the Row.

func (*Row) Set

func (r *Row) Set(c RowContent) (ex error)

Set all specified key/value pairs to corresponding fields. The type is determined by the value type. See RowContent for conversion. This function will panic if an unknown type is used. When called multiple times the row will only contain the content of the last Set calling Set(nil) is identical to Clear()

func (*Row) SetTTL

func (r *Row) SetTTL(ttl int64) error

SetTTL sets the time-to-live for this Row, overriding the table's default value.

An application can set this on a Row before storing it in the table to override the table's default TTL value.

It is an error to set this on a Row if the Row's table does not have expiration enabled.

func (*Row) String

func (r *Row) String() string

String returns a string representation of the Row.

func (*Row) Update

func (r *Row) Update(c RowContent) (ex error)

Update updates the Row with only the columns in the RowContent parameter. All other rows are left unchanged. The type is determined by the value type. See RowContent for conversion. This function will panic if an unknown type is used. If an error occurs during the operation of this function, the state of the Row afterwards will be undefined.

type RowContent

RowContent is used to set values in the Set function and receive them through the Get function. supported types for the value are: Integer types become int64 values in the tibdg.Row

int, int64, int32, int16, int8
uint, uint64, uint32, uint16, uint8, uintptr

byte slices become opaque values in the tibdg.Row

[]byte, []uint8

The following types have corresponding slice versions as well.

Float types become float64 values in the tibdg.Row

float64, float32.

String types become string values in the tibdg.Row:

string, *string

Time types become time.Time in the tibdg.Row:

time.Time

The types converted to are the types received.

type RowContent map[string]interface{}

type Session

Session objects provide the context for a thread of operations involving data grid resources.

type Session struct {
    Conn *Connection // the Connection that created the Session
    // contains filtered or unexported fields
}

func (*Session) Commit

func (session *Session) Commit() error

Commit commits the current transaction on this Session and begins a new transaction.

Committing a transaction causes the data grid to make permanent all table operations performed since the start of the current transaction.

func (*Session) DeleteRows

func (session *Session) DeleteRows(rows []*Row, props Props) (br *BatchResult, err error)

DeleteRows Deletes a number of Rows from the data grid matching the key Rows in the slice provided by the caller.

The BatchResult returned can be used to find out if all the Delete operations succeeded or not.

Note: the rows may be on different tables. Not valid for transacted sessions

func (*Session) Destroy

func (session *Session) Destroy() error

Destroy explicitly destroys a Session object and reclaims its resources.

func (*Session) ExecuteUpdate

func (session *Session) ExecuteUpdate(sqlString string, props Props) (int64, error)

ExecuteUpdate executes a SQL Update.

A SQL update can be Create Table, Create Index, Drop Table, or Drop Index.

func (*Session) GetRows

func (session *Session) GetRows(rows []*Row, props Props) (br *BatchResult, err error)

GetRows Gets a number of Rows from the data grid matching the key Rows in the slice provided by the caller.

The BatchResult returned can be used to find out if all the Get operations succeeded or not. If they did then the Rows that matched the input Rows can be accesses from the BatchResult.

Note: the rows may be on different tables. Not valid for transacted sessions

func (*Session) NewStatement

func (session *Session) NewStatement(sqlString string, props Props) (stmt *Statement, err error)

NewStatement function as declared in tibdg/sess.h:134

The Statement's ExecuteQuery call will block while it fetches the first batch of Rows. If fetching each batch of Rows is always expected to take a long time then the StatementPropertyDoubleFetchTimeout property should be set when the Statement is created to prevent the fetch requests from timing out. The value provided when the Statement is created can also be overridden each time the Statement is executed. If a value of zero is supplied for this property then there will be no limit to how long the application will wait.

func (*Session) OpenTable

func (session *Session) OpenTable(name string, props Props) (tab *Table, err error)

OpenTable opens a Table in the data grid.

func (*Session) PutRows

func (session *Session) PutRows(rows []*Row, props Props) (br *BatchResult, err error)

PutRows Puts a slice of Rows into the data grid.

The BatchResult returned can be used to find out if all the Put operations succeeded or not.

Note: the rows may be on different tables. Not valid for transacted sessions

func (*Session) Rollback

func (session *Session) Rollback() error

Rollback rolls back a transaction on this Session.

Rolling back a transaction causes the data grid to discard all table operations performed since the start of the transaction.

type Statement

Statement objects are used to execute SQL and return ResultSets.

type Statement struct {
    ParameterCount int64              // the number of parameters in the statement
    Metadata       *ResultSetMetadata // describes the columns in the ResultSet.
    Session        *Session           // a pointer to the Session that was used to create the Statement
    // contains filtered or unexported fields
}

func (*Statement) ClearParameters

func (stmt *Statement) ClearParameters() error

ClearParameters clears all the parameters in a parameterized Statement.

func (*Statement) Close

func (stmt *Statement) Close() error

Close closes the Statement and reclaims its resources.

func (*Statement) ExecuteQuery

func (stmt *Statement) ExecuteQuery(props Props) (rs *ResultSet, err error)

ExecuteQuery executes the Statement and returns a ResultSet.

This call will block while it fetches the first batch of Rows. If fetching each batch of Rows is expected to take a long time then the StatementPropertyDoubleFetchTimeout property should be set to prevent the fetch requests from timing out. If this property is set when the Statement is created, it will apply be applied to all executions of the Statement. If you wish to override that value for a particular execution, it can be set when calling this ExecuteQuery function. If a value of zero is supplied for this property then there will be no limit to how long the application will wait.

func (*Statement) ExecuteUpdate

func (stmt *Statement) ExecuteUpdate(props Props) (count int64, err error)

ExecuteUpdate executes an update statement and returns the number of rows that were updated.

func (*Statement) SetFloat

func (stmt *Statement) SetFloat(parameterIndex int, float float64) error

SetFloat sets the value of the particular parameter in the Statement to a given value.

func (*Statement) SetLong

func (stmt *Statement) SetLong(parameterIndex int, long int64) error

SetLong sets the value of the particular parameter in the Statement to a given value.

func (*Statement) SetNull

func (stmt *Statement) SetNull(parameterIndex int) error

SetNull sets the value of the particular parameter in the Statement to NULL.

func (*Statement) SetOpaque

func (stmt *Statement) SetOpaque(parameterIndex int, opaque []byte) error

SetOpaque sets the value of the particular parameter in the Statement to a given value.

func (*Statement) SetString

func (stmt *Statement) SetString(parameterIndex int, str string) error

SetString sets the value of the particular parameter in the Statement to a given value.

func (*Statement) SetTime

func (stmt *Statement) SetTime(parameterIndex int, time time.Time) error

SetTime sets the value of the particular parameter in the Statement to a given value.

type Table

Table objects represent tables of rows.

The individual rows of a Table can be modified by Put or Delete operations or retrieved by Get operations. Iterators and Statements retrieve multiple rows from the table and Listeners allow a program to receive notifications when the table is modified.

type Table struct {
    Name    string   // the name of the Table
    Session *Session // the Session used to create the Table object
    // contains filtered or unexported fields
}

func (*Table) Close

func (table *Table) Close() error

Close explicitly destroys a Table object and reclaims its resources.

func (*Table) Delete

func (table *Table) Delete(key *Row) error

Delete removes a Row from the table if there is one that matches the key.

If there is no Row that matches the key, no error will be reported.

func (*Table) Get

func (table *Table) Get(key *Row) (r *Row, err error)

Get retrieves a Row from the table if there is one that matches the key, otherwise nil is returned.

func (*Table) NewIterator

func (table *Table) NewIterator(filter string, props Props) (iter *Iterator, err error)

NewIterator function as declared in tibdg/table.h:118

If filter is nil, all the rows will be returned. To iterate over a subset of Rows, provide a filter string using the syntax of an SQL WHERE clause, e.g. "key < 100".

func (*Table) NewListener

func (table *Table) NewListener(filter string, props Props, channel chan Event) (lsnr *Listener, err error)

NewListener creates a Listener that will send Events relating to the Table to the provided Channel.

If filter is the empty string, the Listener will receive all Events on the Table. Provide a non-empty string (using the syntax of a SQL WHERE clause) if you only want to receive Events for rows that match a given filter.

func (*Table) NewRow

func (table *Table) NewRow() (r *Row, err error)

NewRow creates a new Row object for a given Table.

func (*Table) Put

func (table *Table) Put(keyValue *Row) error

Put stores the Row in the Table.

type TableMetadata

TableMetadata objects contain information about a specific table in the data grid. This information includes column names, column types, index names, etc.

type TableMetadata struct {
    Name         string           // the name of the table
    DefaultTTL   int64            // the default Time To Live for rows in the table, zero means they will never expire
    Columns      []ColumnMetadata // the columns that comprise the table
    Indexes      []IndexMetadata  // the indexes on the table
    PrimaryIndex *IndexMetadata   // a pointer to the primary index
    GridMetadata *GridMetadata    // a pointer to the grid metadata for the grid the table belongs to
}