obinary

package
v2.0.0-...-625dcbc Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxProtocolVersion  = 32 // max protocol supported by this client
	CurrentProtoVersion = 28
	MinProtocolVersion  = 28 // min protocol supported by this client

)

internal client constants

View Source
const (
	// binary protocol sentinel values when reading single records
	RecordNull = -2
	RecordRID  = -3
)
View Source
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

View Source
var ErrClosedConnection = fmt.Errorf("closed connection")
View Source
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

func Dial(addr string) (*Client, error)

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) Auth

func (c *Client) Auth(adminUser, adminPassw string) (orient.DBAdmin, error)

func (*Client) Close

func (c *Client) Close() error

Close closes database connection

func (*Client) ConnectToServer

func (c *Client) ConnectToServer(adminUser, adminPassw string) (mgr *Manager, err error)

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) Open

func (c *Client) Open(dbname string, dbtype orient.DatabaseType, user, pass string) (orient.DBSession, error)

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

func (db *Database) AddClusterWithID(name string, id int16) (clusterID int16, err error)

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

func (db *Database) Close() error

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

func (db *Database) ClustersCount(withDeleted bool, clusterNames ...string) (val int64, err error)

ClustersCount gets the number of records in all the clusters specified.

func (*Database) Command

func (db *Database) Command(cmd orient.CustomSerializable) (result interface{}, err error)

func (*Database) CountRecords

func (db *Database) CountRecords() (int64, error)

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

func (db *Database) CreateRecord(rec orient.ORecord) error

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

func (db *Database) DeleteRecordByRID(rid orient.RID, recVersion int) error

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

func (db *Database) DropCluster(clusterName string) error

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

func (db *Database) GetClusterDataRange(clusterName string) (begin, end int64, err error)

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

func (db *Database) ReloadSchema() error

ReloadSchema should be called after a schema is altered, such as properties added, deleted or renamed.

func (db *Database) ResolveLinks(links []orient.OIdentifiable) error

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

func (db *Database) Size() (int64, error)

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

func (db *Database) UpdateRecord(rec orient.ORecord) error

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) Close

func (m *Manager) Close() error

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

func (m *Manager) DropDatabase(dbname string, dbtype orient.StorageType) (err error)

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

func (m *Manager) ListDatabases() (list map[string]string, err error)

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 OCluster

type OCluster struct {
	Name string
	Id   int16
}

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 NewDatabase(name string, dbtype orient.DatabaseType) *ODatabase

func (*ODatabase) GetGlobalProperty

func (db *ODatabase) GetGlobalProperty(id int) (p orient.OGlobalProperty, ok bool)

func (*ODatabase) SetGlobalProperty

func (db *ODatabase) SetGlobalProperty(id int, p orient.OGlobalProperty)

type ODuplicatedRecordException

type ODuplicatedRecordException struct {
	orient.OServerException
}

func (ODuplicatedRecordException) Error

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.

Directories

Path Synopsis
rw is the read-write package for reading and writing types from the OrientDB binary network protocol.
rw is the read-write package for reading and writing types from the OrientDB binary network protocol.

Jump to

Keyboard shortcuts

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