Documentation ¶
Overview ¶
Package db defines generic database functionality.
Index ¶
Constants ¶
View Source
const DefaultDatabase = ""
Marker for using the default database instance.
View Source
const DefaultTxConfigTimeout = math.MinInt
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessMode ¶
type AccessMode int
Definitions of these should correspond to public API
const ( WriteMode AccessMode = 0 ReadMode AccessMode = 1 )
type Connection ¶
type Connection interface { Connect( ctx context.Context, minor int, auth *ReAuthToken, userAgent string, routingContext map[string]string, notificationConfig NotificationConfig, ) error TxBegin(ctx context.Context, txConfig TxConfig) (TxHandle, error) TxRollback(ctx context.Context, tx TxHandle) error TxCommit(ctx context.Context, tx TxHandle) error Run(ctx context.Context, cmd Command, txConfig TxConfig) (StreamHandle, error) RunTx(ctx context.Context, tx TxHandle, cmd Command) (StreamHandle, error) // Keys for the specified stream. Keys(streamHandle StreamHandle) ([]string, error) // Next moves to next item in the stream. // If error is nil, either Record or Summary has a value, if Record is nil there are no more records. // If error is non nil, neither Record or Summary has a value. Next(ctx context.Context, streamHandle StreamHandle) (*db.Record, *db.Summary, error) // Consume discards all records on the stream and returns the summary otherwise it will return the error. Consume(ctx context.Context, streamHandle StreamHandle) (*db.Summary, error) // Buffer buffers all records on the stream, records, summary and error will be received through call to Next // The Connection implementation should preserve/buffer streams automatically if needed when new // streams are created and the server doesn't support multiple streams. Use Buffer to force // buffering before calling Reset to get all records and the bookmark. Buffer(ctx context.Context, streamHandle StreamHandle) error // Bookmark returns the bookmark and optionally its database from last committed transaction or last finished auto-commit transaction. // The returned database is relevant for queries executed with the USE clause, since the returned database may be different from the session's database. // Note that if there is an ongoing auto-commit transaction (stream active) the bookmark // from that is not included, use Buffer or Consume to end the stream with a bookmark. // Empty string if no bookmark. Bookmark() string // ServerName returns the name of the remote server ServerName() string // ServerVersion returns the server version on pattern Neo4j/1.2.3 ServerVersion() string // IsAlive returns true if the connection is fully functional. // Implementation of this should be passive, no pinging or similar since it might be // called rather frequently. IsAlive() bool // HasFailed returns true if the connection has received a recoverable error (“FAILURE“). HasFailed() bool // Birthdate returns the point in time when this connection was established. Birthdate() time.Time // IdleDate returns the point in time since which the connection is idle IdleDate() time.Time // Reset resets connection to same state as directly after a connection. // Active streams will be discarded and the bookmark will be lost. Reset(ctx context.Context) // ForceReset behaves like Reset except it also resets connections in the // ready state (while Reset does not) ForceReset(ctx context.Context) // Close closes the database connection as well as any underlying connection. // The instance should not be used after being closed. Close(ctx context.Context) // GetRoutingTable gets the routing table for specified database name or the default database if // database equals DefaultDatabase. If the underlying connection does not support // multiple databases, DefaultDatabase should be used as database. // If user impersonation is used (impersonatedUser != "") and default database is used // the database name in the returned routing table will contain the actual name of the // configured default database for the impersonated user. If no impersonation is used // database name in routing table will be set to the name of the requested database. GetRoutingTable(ctx context.Context, context map[string]string, bookmarks []string, database, impersonatedUser string) (*RoutingTable, error) // SetBoltLogger sets Bolt message logger on already initialized connections SetBoltLogger(boltLogger log.BoltLogger) // ReAuth enqueues a `LOGOFF` and `LOGON` message if the passed credentials differ // or `ReAuthToken.ForceReAuth` is `true`. // If `ReAuthToken.ForceReAuth` is `true` the messages will be sent and their responses received. // If `ReAuthToken.FromSession` is `false`, the credentials changed, and the protocol version does not support // re-auth (bolt 5.1 and earlier) the connection will be closed. // If it's `true` (under otherwise same conditions) a `FeatureNotSupportedError` will be returned. ReAuth(context.Context, *ReAuthToken) error // Version returns the protocol version of the connection Version() db.ProtocolVersion // ResetAuth clears any authentication token held by this connection ResetAuth() // GetCurrentAuth returns the current authentication manager and token that this connection is authenticated with GetCurrentAuth() (auth.TokenManager, iauth.Token) }
Connection defines an abstract database server connection.
type DatabaseSelector ¶
type DatabaseSelector interface { // SelectDatabase should be called immediately after Reset. Not allowed to call multiple times with different // databases without a reset in-between. SelectDatabase(database string) }
DatabaseSelector allows to select a database if the database server connection supports selecting which database instance on the server to connect to. Prior to Neo4j 4 there was only one database per server.
type NotificationConfig ¶
type NotificationConfig struct { MinSev notifications.NotificationMinimumSeverityLevel DisCats notifications.NotificationDisabledCategories }
func (*NotificationConfig) ToMeta ¶
func (n *NotificationConfig) ToMeta(meta map[string]any)
type ReAuthToken ¶
type ReAuthToken struct { Manager auth.TokenManager FromSession bool ForceReAuth bool }
type RoutingTable ¶
type StreamHandle ¶
type StreamHandle any
type TxConfig ¶
type TxConfig struct { Mode AccessMode Bookmarks []string Timeout time.Duration ImpersonatedUser string Meta map[string]any NotificationConfig NotificationConfig }
Click to show internal directories.
Click to hide internal directories.