Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Auth(adminUser, adminPassw string) (orient.DBAdmin, error)
- func (c *Client) Close() error
- func (c *Client) ConnectToServer(adminUser, adminPassw string) (mgr *Manager, err error)
- func (c *Client) Open(dbname string, dbtype orient.DatabaseType, user, pass string) (orient.DBSession, error)
- func (c *Client) OpenDatabase(dbname string, dbtype orient.DatabaseType, user, pass string) (db *Database, err error)
- type Database
- func (db *Database) AddClusterWithID(name string, id int16) (clusterID int16, err error)
- func (db *Database) Close() error
- func (db *Database) ClustersCount(withDeleted bool, clusterNames ...string) (val int64, err error)
- func (db *Database) Command(cmd orient.CustomSerializable) (result interface{}, err error)
- func (db *Database) CountRecords() (int64, error)
- func (db *Database) CreateRecord(rec orient.ORecord) error
- func (db *Database) DeleteRecordByRID(rid orient.RID, recVersion int) error
- func (db *Database) DropCluster(clusterName string) error
- func (db *Database) GetClusterDataRange(clusterName string) (begin, end int64, err error)
- func (db *Database) GetCurDB() *orient.ODatabase
- func (db *Database) GetRecordByRID(rid orient.RID, fetchPlan orient.FetchPlan, ignoreCache bool) (rec orient.ORecord, err error)
- func (db *Database) ReloadSchema() error
- func (db *Database) ResolveLinks(links []orient.OIdentifiable) error
- func (db *Database) Size() (int64, error)
- func (db *Database) UpdateRecord(rec orient.ORecord) error
- type ErrBrokenProtocol
- type ErrDataTypeMismatch
- type ErrUnsupportedVersion
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) CreateDatabase(dbname string, dbtype orient.DatabaseType, storageType orient.StorageType) error
- func (m *Manager) DatabaseExists(dbname string, storageType orient.StorageType) (val bool, err error)
- func (m *Manager) DropDatabase(dbname string, dbtype orient.StorageType) (err error)
- func (m *Manager) ListDatabases() (list map[string]string, err error)
- type OCluster
- type ODatabase
- type ODuplicatedRecordException
- type OStorageConfiguration
Constants ¶
const ( MaxProtocolVersion = 32 // max protocol supported by this client CurrentProtoVersion = 28 MinProtocolVersion = 28 // min protocol supported by this client )
internal client constants
const ( // binary protocol sentinel values when reading single records RecordNull = -2 RecordRID = -3 )
const ( // FOR MORE INFO: // https://github.com/orientechnologies/orientdb/wiki/Network-Binary-Protocol#wiki-Compatibility ProtoVersion7 = 7 ProtoVersion8 = 8 ProtoVersion9 = 9 ProtoVersion13 = 13 ProtoVersion17 = 17 ProtoVersion19 = 19 ProtoVersion21 = 21 ProtoVersion23 = 23 ProtoVersion24 = 24 ProtoVersion25 = 25 ProtoVersion26 = 26 ProtoVersion27 = 27 ProtoVersion28 = 28 ProtoVersion29 = 29 ProtoVersion30 = 30 ProtoVersion31 = 31 ProtoVersion32 = 32 )
command and server-related constants copied from Java OChannelBinaryProtocol
Variables ¶
var ErrClosedConnection = fmt.Errorf("closed connection")
var ErrStaleGlobalProperties = fmt.Errorf("stale global properties")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client encapsulates the active TCP connection to an OrientDB server to be used with the Network Binary Protocol. It also may be connected to up to one database at a time. Do not create a Client struct directly. You should use NewClient, followed immediately by ConnectToServer, to connect to the OrientDB server, or OpenDatabase, to connect to a database on the server.
func Dial ¶
Dial creates a new binary connection to OrientDB server. The Client returned is ready to make calls to the OrientDB but has not yet established a database session or a session with the OrientDB server. After this, the user needs to call either OpenDatabase or CreateServerSession.
func (*Client) ConnectToServer ¶
ConnectToServer logs into the OrientDB server with the appropriate admin privileges in order to execute server-level commands (as opposed to database-level commands). This must be called to establish a server session before any other server-level commands. The username and password required are for the server (admin) not any particular database.
func (*Client) OpenDatabase ¶
func (c *Client) OpenDatabase(dbname string, dbtype orient.DatabaseType, user, pass string) (db *Database, err error)
OpenDatabase sends the REQUEST_DB_OPEN command to the OrientDb server to open the db in read/write mode. The database name and type are required, plus username and password. Database type should be one of the obinary constants: DocumentDbType or GraphDbType.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) AddClusterWithID ¶
AddClusterWithID adds a cluster to the current database with a given cluster position. It is a database-level operation, so OpenDatabase must have already been called first in order to start a session with the database. The clusterID is returned if the command is successful.
func (*Database) Close ¶
CloseDatabase closes down a session with a specific database that has already been opened (via OpenDatabase). This should be called when exiting an app or before starting a connection to a different OrientDB database.
func (*Database) ClustersCount ¶
ClustersCount gets the number of records in all the clusters specified.
func (*Database) CountRecords ¶
FetchNumRecordsInDatabase retrieves the number of records of the current database. It is a database-level operation, so OpenDatabase must have already been called first in order to start a session with the database.
func (*Database) CreateRecord ¶
Use this to create a new record in the OrientDB database you are currently connected to. Does REQUEST_RECORD_CREATE OrientDB cmd (binary network protocol).
func (*Database) DeleteRecordByRID ¶
DeleteRecordByRID deletes a record specified by its RID and its version.
If nil is returned, delete succeeded. If error is returned, delete request was either never issued, or there was a problem on the server end or the record did not exist in the database.
func (*Database) DropCluster ¶
DropCluster drops a cluster to the current database. It is a database-level operation, so OpenDatabase must have already been called first in order to start a session with the database. If nil is returned, then the action succeeded.
func (*Database) GetClusterDataRange ¶
FetchClusterDataRange returns the range of record ids for a cluster
func (*Database) GetCurDB ¶
func (db *Database) GetCurDB() *orient.ODatabase
GetCurDB returns database metadata
func (*Database) GetRecordByRID ¶
func (db *Database) GetRecordByRID(rid orient.RID, fetchPlan orient.FetchPlan, ignoreCache bool) (rec orient.ORecord, err error)
GetRecordByRID takes an RID and reads that record from the database.
ignoreCache = true
func (*Database) ReloadSchema ¶
ReloadSchema should be called after a schema is altered, such as properties added, deleted or renamed.
func (*Database) ResolveLinks ¶
ResolveLinks iterates over all the OLinks passed in and does a FetchRecordByRID for each one that has a null Record. TODO: maybe include a fetchplan here? TODO: remove it from obinary
func (*Database) Size ¶
FetchDatabaseSize retrieves the size of the current database in bytes. It is a database-level operation, so OpenDatabase must have already been called first in order to start a session with the database.
func (*Database) UpdateRecord ¶
UpdateRecord should be used update an existing record in the OrientDB database. It does the REQUEST_RECORD_UPDATE OrientDB cmd (network binary protocol)
type ErrBrokenProtocol ¶
type ErrBrokenProtocol struct {
Reason error
}
func (ErrBrokenProtocol) Error ¶
func (e ErrBrokenProtocol) Error() string
type ErrDataTypeMismatch ¶
type ErrDataTypeMismatch struct { ExpectedDataType orient.OType ExpectedGoType string ActualValue interface{} }
InvalidDatabaseType is an Error that indicates that the db type value is not one that the OrientDB server will recognize. For OrientDB 2.x, the valid types are "document" or "graph". Constants for these values are provided in the obinary ogonori code base.
func (ErrDataTypeMismatch) Error ¶
func (e ErrDataTypeMismatch) Error() string
type ErrUnsupportedVersion ¶
type ErrUnsupportedVersion int
func (ErrUnsupportedVersion) Error ¶
func (e ErrUnsupportedVersion) Error() string
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) CreateDatabase ¶
func (m *Manager) CreateDatabase(dbname string, dbtype orient.DatabaseType, storageType orient.StorageType) error
CreateDatabase will create a `remote` database of the type and storageType specified. dbType must be type DocumentDBType or GraphDBType. storageType must type PersistentStorageType or VolatileStorageType.
func (*Manager) DatabaseExists ¶
func (m *Manager) DatabaseExists(dbname string, storageType orient.StorageType) (val bool, err error)
DatabaseExists is a server-level command, so must be preceded by calling ConnectToServer, otherwise an authorization error will be returned. The storageType param must be either PersistentStorageType or VolatileStorageType.
func (*Manager) DropDatabase ¶
DropDatabase drops the specified database. The caller must provide both the name and the type of the database. The type should either:
obinary.DocumentDBType obinary.GraphDBType
This is a "server" command, so you must have already called ConnectToServer before calling this function.
func (*Manager) ListDatabases ¶
RequestDBList works like the "list databases" command from the OrientDB client. The result is put into a map, where the key of the map is the name of the database and the value is the type concatenated with the path, like so:
key: cars val: plocal:/path/to/orientdb-community-2.0.1/databases/cars
type ODatabase ¶
type ODatabase struct { Name string Type orient.DatabaseType Clusters []OCluster ClustCfg []byte // TODO: why is this a byte array? Just placeholder? What is it in the Java client? SchemaVersion int Classes map[string]*orient.OClass StorageCfg OStorageConfiguration // TODO: redundant to ClustCfg ?? // contains filtered or unexported fields }
func NewDatabase ¶
func (*ODatabase) GetGlobalProperty ¶
func (*ODatabase) SetGlobalProperty ¶
type ODuplicatedRecordException ¶
type ODuplicatedRecordException struct {
orient.OServerException
}
func (ODuplicatedRecordException) Error ¶
func (e ODuplicatedRecordException) Error() string
type OStorageConfiguration ¶
type OStorageConfiguration struct {
// contains filtered or unexported fields
}
OStorageConfiguration holds (some of) the information in the "Config Record" #0:0. At this time, I'm throwing away a lot of the info in record #0:0 until proven that the ogonori client needs them.