neo4j

package
v4.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 16 Imported by: 169

Documentation

Overview

Package neo4j provides required functionality to connect and execute statements against a Neo4j Database.

Index

Constants

View Source
const (
	// ERROR is the level that error messages are written
	ERROR LogLevel = 1
	// WARNING is the level that warning messages are written
	WARNING = 2
	// INFO is the level that info messages are written
	INFO = 3
	// DEBUG is the level that debug messages are written
	DEBUG = 4
)
View Source
const FetchAll = -1

Turns off fetching records in batches.

View Source
const FetchDefault = 0

Lets the driver decide fetch size

View Source
const UserAgent = "Go Driver/4.3"

Variables

This section is empty.

Functions

func ConsoleBoltLogger added in v4.3.0

func ConsoleBoltLogger() *log.ConsoleBoltLogger

func ConsoleLogger

func ConsoleLogger(level LogLevel) *log.Console

func IsConnectivityError added in v4.2.0

func IsConnectivityError(err error) bool

IsConnectivityError returns true if the provided error is an instance of ConnectivityError.

func IsNeo4jError added in v4.2.0

func IsNeo4jError(err error) bool

IsNeo4jError returns true if the provided error is an instance of Neo4jError.

func IsTransactionExecutionLimit added in v4.2.0

func IsTransactionExecutionLimit(err error) bool

IsTransactionExecutionLimit returns true if the provided error is an instance of TransactionExecutionLimit.

func IsUsageError added in v4.2.0

func IsUsageError(err error) bool

IsUsageError returns true if the provided error is an instance of UsageError.

func WithTxMetadata

func WithTxMetadata(metadata map[string]interface{}) func(*TransactionConfig)

WithTxMetadata returns a transaction configuration function that attaches metadata to a transaction.

To attach a metadata to an explicit transaction:

session.BeginTransaction(WithTxMetadata(map[string)interface{}{"work-id": 1}))

To attach a metadata to an auto-commit transaction:

session.Run("RETURN 1", nil, WithTxMetadata(map[string)interface{}{"work-id": 1}))

To attach a metadata to a read transaction function:

session.ReadTransaction(DoWork, WithTxMetadata(map[string)interface{}{"work-id": 1}))

To attach a metadata to a write transaction function:

session.WriteTransaction(DoWork, WithTxMetadata(map[string)interface{}{"work-id": 1}))

func WithTxTimeout

func WithTxTimeout(timeout time.Duration) func(*TransactionConfig)

WithTxTimeout returns a transaction configuration function that applies a timeout to a transaction.

To apply a transaction timeout to an explicit transaction:

session.BeginTransaction(WithTxTimeout(5*time.Second))

To apply a transaction timeout to an auto-commit transaction:

session.Run("RETURN 1", nil, WithTxTimeout(5*time.Second))

To apply a transaction timeout to a read transaction function:

session.ReadTransaction(DoWork, WithTxTimeout(5*time.Second))

To apply a transaction timeout to a write transaction function:

session.WriteTransaction(DoWork, WithTxTimeout(5*time.Second))

Types

type AccessMode

type AccessMode int

AccessMode defines modes that routing driver decides to which cluster member a connection should be opened.

const (
	// AccessModeWrite tells the driver to use a connection to 'Leader'
	AccessModeWrite AccessMode = 0
	// AccessModeRead tells the driver to use a connection to one of the 'Follower' or 'Read Replica'.
	AccessModeRead AccessMode = 1
)

type AuthToken

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

AuthToken contains credentials to be sent over to the neo4j server.

func BasicAuth

func BasicAuth(username string, password string, realm string) AuthToken

BasicAuth generates a basic authentication token with provided username, password and realm

func CustomAuth

func CustomAuth(scheme string, username string, password string, realm string, parameters map[string]interface{}) AuthToken

CustomAuth generates a custom authentication token with provided parameters

func KerberosAuth

func KerberosAuth(ticket string) AuthToken

KerberosAuth generates a kerberos authentication token with provided base-64 encoded kerberos ticket

func NoAuth

func NoAuth() AuthToken

NoAuth generates an empty authentication token

type Config

type Config struct {
	// RootCAs defines the set of certificate authorities that the driver trusts. If set
	// to nil, the driver uses hosts system certificates.
	//
	// The trusted certificates are used to validate connections for URI schemes 'bolt+s'
	// and 'neo4j+s'.
	RootCAs *x509.CertPool

	// Logging target the driver will send its log outputs
	//
	// Possible to use custom logger (implement log.Logger interface) or
	// use neo4j.ConsoleLogger.
	//
	// default: No Op Logger (log.Void)
	Log log.Logger
	// Resolver that would be used to resolve initial router address. This may
	// be useful if you want to provide more than one URL for initial router.
	// If not specified, the URL provided to NewDriver is used as the initial
	// router.
	//
	// default: nil
	AddressResolver ServerAddressResolver
	// Maximum amount of time a retriable operation would continue retrying. It
	// cannot be specified as a negative value.
	//
	// default: 30 * time.Second
	MaxTransactionRetryTime time.Duration
	// Maximum number of connections per URL to allow on this driver. It
	// cannot be specified as 0 and negative values are interpreted as
	// math.MaxInt32.
	//
	// default: 100
	MaxConnectionPoolSize int
	// Maximum connection life time on pooled connections. Values less than
	// or equal to 0 disables the lifetime check.
	//
	// default: 1 * time.Hour
	MaxConnectionLifetime time.Duration
	// Maximum amount of time to either acquire an idle connection from the pool
	// or create a new connection (when the pool is not full). Negative values
	// result in an infinite wait time where 0 value results in no timeout which
	// results in immediate failure when there are no available connections.
	//
	// default: 1 * time.Minute
	ConnectionAcquisitionTimeout time.Duration
	// Connect timeout that will be set on underlying sockets. Values less than
	// or equal to 0 results in no timeout being applied.
	//
	// default: 5 * time.Second
	SocketConnectTimeout time.Duration
	// Whether to enable TCP keep alive on underlying sockets.
	//
	// default: true
	SocketKeepalive bool
	// Optionally override the user agent string sent to Neo4j server.
	//
	// default: neo4j.UserAgent
	UserAgent string
}

A Config contains options that can be used to customize certain aspects of the driver

type ConnectivityError added in v4.2.0

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

ConnectivityError represent errors caused by the driver not being able to connect to Neo4j services, or lost connections.

func (*ConnectivityError) Error added in v4.2.0

func (e *ConnectivityError) Error() string

type Counters

type Counters interface {
	// Whether there were any updates at all, eg. any of the counters are greater than 0.
	ContainsUpdates() bool
	// The number of nodes created.
	NodesCreated() int
	// The number of nodes deleted.
	NodesDeleted() int
	// The number of relationships created.
	RelationshipsCreated() int
	// The number of relationships deleted.
	RelationshipsDeleted() int
	PropertiesSet() int
	// The number of labels added to nodes.
	LabelsAdded() int
	// The number of labels removed from nodes.
	LabelsRemoved() int
	// The number of indexes added to the schema.
	IndexesAdded() int
	// The number of indexes removed from the schema.
	IndexesRemoved() int
	// The number of constraints added to the schema.
	ConstraintsAdded() int
	// The number of constraints removed from the schema.
	ConstraintsRemoved() int
}

Counters contains statistics about the changes made to the database made as part of the statement execution.

type DatabaseInfo added in v4.3.2

type DatabaseInfo interface {
	Name() string
}

DatabaseInfo contains basic information of the database the query result has been obtained from.

type Date

type Date = dbtype.Date

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

func DateOf

func DateOf(t time.Time) Date

DateOf creates a neo4j.Date from time.Time. Hour, minute, second and nanoseconds are set to zero and location is set to UTC.

Conversion can also be done by casting a time.Time to neo4j.Date but beware that time components and location will be left as is but ignored when used as query parameter.

type Driver

type Driver interface {
	// The url this driver is bootstrapped
	Target() url.URL
	// Creates a new session based on the specified session configuration.
	NewSession(config SessionConfig) Session
	// Deprecated: Use NewSession instead
	Session(accessMode AccessMode, bookmarks ...string) (Session, error)
	// Verifies that the driver can connect to a remote server or cluster by
	// establishing a network connection with the remote. Returns nil if succesful
	// or error describing the problem.
	VerifyConnectivity() error
	// Close the driver and all underlying connections
	Close() error
}

Driver represents a pool(s) of connections to a neo4j server or cluster. It's safe for concurrent use.

func NewDriver

func NewDriver(target string, auth AuthToken, configurers ...func(*Config)) (Driver, error)

NewDriver is the entry point to the neo4j driver to create an instance of a Driver. It is the first function to be called in order to establish a connection to a neo4j database. It requires a Bolt URI and an authentication token as parameters and can also take optional configuration function(s) as variadic parameters.

In order to connect to a single instance database, you need to pass a URI with scheme 'bolt', 'bolt+s' or 'bolt+ssc'.

driver, err = NewDriver("bolt://db.server:7687", BasicAuth(username, password))

In order to connect to a causal cluster database, you need to pass a URI with scheme 'neo4j', 'neo4j+s' or 'neo4j+ssc' and its host part set to be one of the core cluster members.

driver, err = NewDriver("neo4j://core.db.server:7687", BasicAuth(username, password))

You can override default configuration options by providing a configuration function(s)

driver, err = NewDriver(uri, BasicAuth(username, password), function (config *Config) {
	config.MaxConnectionPoolSize = 10
})

type Duration

type Duration = dbtype.Duration

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

func DurationOf

func DurationOf(months, days, seconds int64, nanos int) Duration

DurationOf creates neo4j.Duration from specified time parts.

type InputPosition

type InputPosition interface {
	// Offset returns the character offset referred to by this position; offset numbers start at 0.
	Offset() int
	// Line returns the line number referred to by this position; line numbers start at 1.
	Line() int
	// Column returns the column number referred to by this position; column numbers start at 1.
	Column() int
}

InputPosition contains information about a specific position in a statement

type LocalDateTime

type LocalDateTime = dbtype.LocalDateTime

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

func LocalDateTimeOf

func LocalDateTimeOf(t time.Time) LocalDateTime

LocalDateTimeOf creates a neo4j.Local from time.Time.

Conversion can also be done by casting a time.Time to neo4j.LocalTime but beware that location will be left as is but interpreted as local when used as query parameter.

type LocalTime

type LocalTime = dbtype.LocalTime

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

func LocalTimeOf

func LocalTimeOf(t time.Time) LocalTime

LocalTimeOf creates a neo4j.LocalTime from time.Time. Year, month and day are set to zero and location is set to local.

Conversion can also be done by casting a time.Time to neo4j.LocalTime but beware that date components and location will be left as is but ignored when used as query parameter.

type LogLevel

type LogLevel int

LogLevel is the type that default logging implementations use for available log levels

type Neo4jError added in v4.2.0

type Neo4jError = db.Neo4jError

Neo4jError represents errors originating from Neo4j service. Alias for convenience. This error is defined in db package and used internally.

type Node

type Node = dbtype.Node

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

type Notification

type Notification interface {
	// Code returns a notification code for the discovered issue of this notification.
	Code() string
	// Title returns a short summary of this notification.
	Title() string
	// Description returns a longer description of this notification.
	Description() string
	// Position returns the position in the statement where this notification points to.
	// Not all notifications have a unique position to point to and in that case the position would be set to nil.
	Position() InputPosition
	// Severity returns the severity level of this notification.
	Severity() string
}

Notification represents notifications generated when executing a statement. A notification can be visualized in a client pinpointing problems or other information about the statement.

type OffsetTime

type OffsetTime = dbtype.Time

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

func OffsetTimeOf

func OffsetTimeOf(t time.Time) OffsetTime

OffsetTimeOf creates a neo4j.OffsetTime from time.Time. Year, month and day are set to zero and location is set to "Offset" using zone offset from time.Time.

Conversion can also be done by casting a time.Time to neo4j.OffsetTime but beware that date components and location will be left as is but ignored when used as query parameter. Since location will contain the original value, the value "offset" will not be used by the driver but the actual name of the location in time.Time and that offset.

type Path

type Path = dbtype.Path

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

type Plan

type Plan interface {
	// Operator returns the operation this plan is performing.
	Operator() string
	// Arguments returns the arguments for the operator used.
	// Many operators have arguments defining their specific behavior. This map contains those arguments.
	Arguments() map[string]interface{}
	// Identifiers returns a list of identifiers used by this plan. Identifiers used by this part of the plan.
	// These can be both identifiers introduced by you, or automatically generated.
	Identifiers() []string
	// Children returns zero or more child plans. A plan is a tree, where each child is another plan.
	// The children are where this part of the plan gets its input records - unless this is an operator that
	// introduces new records on its own.
	Children() []Plan
}

Plan describes the actual plan that the database planner produced and used (or will use) to execute your statement. This can be extremely helpful in understanding what a statement is doing, and how to optimize it. For more details, see the Neo4j Manual. The plan for the statement is a tree of plans - each sub-tree containing zero or more child plans. The statement starts with the root plan. Each sub-plan is of a specific operator, which describes what that part of the plan does - for instance, perform an index lookup or filter results. The Neo4j Manual contains a reference of the available operator types, and these may differ across Neo4j versions.

type Point2D

type Point2D = dbtype.Point2D

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

type Point3D

type Point3D = dbtype.Point3D

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

type ProfiledPlan

type ProfiledPlan interface {
	// Operator returns the operation this plan is performing.
	Operator() string
	// Arguments returns the arguments for the operator used.
	// Many operators have arguments defining their specific behavior. This map contains those arguments.
	Arguments() map[string]interface{}
	// Identifiers returns a list of identifiers used by this plan. Identifiers used by this part of the plan.
	// These can be both identifiers introduced by you, or automatically generated.
	Identifiers() []string
	// DbHits returns the number of times this part of the plan touched the underlying data stores/
	DbHits() int64
	// Records returns the number of records this part of the plan produced.
	Records() int64
	// Children returns zero or more child plans. A plan is a tree, where each child is another plan.
	// The children are where this part of the plan gets its input records - unless this is an operator that
	// introduces new records on its own.
	Children() []ProfiledPlan
}

ProfiledPlan is the same as a regular Plan - except this plan has been executed, meaning it also contains detailed information about how much work each step of the plan incurred on the database.

type Record

type Record = db.Record

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

func AsRecord added in v4.2.0

func AsRecord(from interface{}, err error) (*Record, error)

AsRecord passes any existing error or casts from to a record. Use in combination with Single and transactional functions:

record, err := neo4j.AsRecord(session.ReadTransaction(func (tx neo4j.Transaction) {
    return neo4j.Single(tx.Run(...))
}))

func AsRecords added in v4.2.0

func AsRecords(from interface{}, err error) ([]*Record, error)

AsRecords passes any existing error or casts from to a slice of records. Use in combination with Collect and transactional functions:

records, err := neo4j.AsRecords(session.ReadTransaction(func (tx neo4j.Transaction) {
    return neo4j.Collect(tx.Run(...))
}))

func Collect

func Collect(result Result, err error) ([]*Record, error)

Collect loops through the result stream, collects records into a slice and returns the resulting slice. Any error passed in or reported while navigating the result stream is returned without any conversion.

records, err := neo4j.Collect(session.Run(...))

func Single

func Single(result Result, err error) (*Record, error)

Single returns one and only one record from the result stream. Any error passed in or reported while navigating the result stream is returned without any conversion. If the result stream contains zero or more than one records error is returned.

record, err := neo4j.Single(session.Run(...))

type Relationship

type Relationship = dbtype.Relationship

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

type Result

type Result interface {
	// Keys returns the keys available on the result set.
	Keys() ([]string, error)
	// Next returns true only if there is a record to be processed.
	Next() bool
	// NextRecord returns true if there is a record to be processed, record parameter is set
	// to point to current record.
	NextRecord(record **Record) bool
	// Err returns the latest error that caused this Next to return false.
	Err() error
	// Record returns the current record.
	Record() *Record
	// Collect fetches all remaining records and returns them.
	Collect() ([]*Record, error)
	// Single returns one and only one record from the stream.
	// If the result stream contains zero or more than one records, error is returned.
	Single() (*Record, error)
	// Consume discards all remaining records and returns the summary information
	// about the statement execution.
	Consume() (ResultSummary, error)
}

type ResultSummary

type ResultSummary interface {
	// Server returns basic information about the server where the statement is carried out.
	Server() ServerInfo
	// Statement returns statement that has been executed.
	Statement() Statement
	// StatementType returns type of statement that has been executed.
	StatementType() StatementType
	// Counters returns statistics counts for the statement.
	Counters() Counters
	// Plan returns statement plan for the executed statement if available, otherwise null.
	Plan() Plan
	// Profile returns profiled statement plan for the executed statement if available, otherwise null.
	Profile() ProfiledPlan
	// Notifications returns a slice of notifications produced while executing the statement.
	// The list will be empty if no notifications produced while executing the statement.
	Notifications() []Notification
	// ResultAvailableAfter returns the time it took for the server to make the result available for consumption.
	ResultAvailableAfter() time.Duration
	// ResultConsumedAfter returns the time it took the server to consume the result.
	ResultConsumedAfter() time.Duration
	// Database returns information about the database where the result is obtained from
	// Returns nil for Neo4j versions prior to v4.
	// Returns the default "neo4j" database for Community Edition servers.
	Database() DatabaseInfo
}

type ServerAddress

type ServerAddress interface {
	// Hostname returns the host portion of this ServerAddress.
	Hostname() string
	// Port returns the port portion of this ServerAddress.
	Port() string
}

ServerAddress represents a host and port. Host can either be an IP address or a DNS name. Both IPv4 and IPv6 hosts are supported.

func NewServerAddress

func NewServerAddress(hostname string, port string) ServerAddress

NewServerAddress generates a ServerAddress with provided hostname and port information.

type ServerAddressResolver

type ServerAddressResolver func(address ServerAddress) []ServerAddress

ServerAddressResolver is a function type that defines the resolver function used by the routing driver to resolve the initial address used to create the driver.

type ServerInfo

type ServerInfo interface {
	// Address returns the address of the server.
	Address() string
	// Version returns the version of Neo4j running at the server.
	// Deprecated: since 4.3, this function is deprecated. It will be removed in 5.0. please use Agent, ProtocolVersion, or call the dbms.components procedure instead
	Version() string
	Agent() string
	ProtocolVersion() db.ProtocolVersion
}

ServerInfo contains basic information of the server.

type Session

type Session interface {
	// LastBookmark returns the bookmark received following the last successfully completed transaction.
	// If no bookmark was received or if this transaction was rolled back, the bookmark value will not be changed.
	LastBookmark() string
	// BeginTransaction starts a new explicit transaction on this session
	BeginTransaction(configurers ...func(*TransactionConfig)) (Transaction, error)
	// ReadTransaction executes the given unit of work in a AccessModeRead transaction with
	// retry logic in place
	ReadTransaction(work TransactionWork, configurers ...func(*TransactionConfig)) (interface{}, error)
	// WriteTransaction executes the given unit of work in a AccessModeWrite transaction with
	// retry logic in place
	WriteTransaction(work TransactionWork, configurers ...func(*TransactionConfig)) (interface{}, error)
	// Run executes an auto-commit statement and returns a result
	Run(cypher string, params map[string]interface{}, configurers ...func(*TransactionConfig)) (Result, error)
	// Close closes any open resources and marks this session as unusable
	Close() error
}

Session represents a logical connection (which is not tied to a physical connection) to the server

type SessionConfig

type SessionConfig struct {
	// AccessMode used when using Session.Run and explicit transactions. Used to route query to
	// to read or write servers when running in a cluster. Session.ReadTransaction and Session.WriteTransaction
	// does not rely on this mode.
	AccessMode AccessMode
	// Bookmarks are the initial bookmarks used to ensure that the executing server is at least up
	// to date to the point represented by the latest of the provided bookmarks. After running commands
	// on the session the bookmark can be retrieved with Session.LastBookmark. All commands executing
	// within the same session will automatically use the bookmark from the previous command in the
	// session.
	Bookmarks []string
	// DatabaseName contains the name of the database that the commands in the session will execute on.
	DatabaseName string
	// FetchSize defines how many records to pull from server in each batch.
	// From Bolt protocol v4 (Neo4j 4+) records can be fetched in batches as compared to fetching
	// all in previous versions.
	//
	// If FetchSize is set to FetchDefault, the driver decides the appropriate size. If set to a positive value
	// that size is used if the underlying protocol supports it otherwise it is ignored.
	//
	// To turn off fetching in batches and always fetch everything, set FetchSize to FetchAll.
	// If a single large result is to be retrieved this is the most performant setting.
	FetchSize int
	// Logging target the session will send its Bolt message traces
	//
	// Possible to use custom logger (implement log.BoltLogger interface) or
	// use neo4j.ConsoleBoltLogger.
	BoltLogger log.BoltLogger
}

SessionConfig is used to configure a new session, its zero value uses safe defaults.

type Statement

type Statement interface {
	// Text returns the statement's text.
	Text() string
	// Params returns the statement's parameters.
	Params() map[string]interface{}
}

type StatementType

type StatementType int

StatementType defines the type of the statement

const (
	// StatementTypeUnknown identifies an unknown statement type
	StatementTypeUnknown StatementType = 0
	// StatementTypeReadOnly identifies a read-only statement
	StatementTypeReadOnly StatementType = 1
	// StatementTypeReadWrite identifies a read-write statement
	StatementTypeReadWrite StatementType = 2
	// StatementTypeWriteOnly identifies a write-only statement
	StatementTypeWriteOnly StatementType = 3
	// StatementTypeSchemaWrite identifies a schema-write statement
	StatementTypeSchemaWrite StatementType = 4
)

type Time

type Time = dbtype.Time

Aliases to simplify client usage (fewer imports) and to provide some backwards compatibility with 1.x driver.

A separate dbtype package is needed to avoid circular package references and to avoid unnecessary copying/conversions between structs since serializing/deserializing is handled within bolt package and bolt package is used from this package.

type Transaction

type Transaction interface {
	// Run executes a statement on this transaction and returns a result
	Run(cypher string, params map[string]interface{}) (Result, error)
	// Commit commits the transaction
	Commit() error
	// Rollback rolls back the transaction
	Rollback() error
	// Close rolls back the actual transaction if it's not already committed/rolled back
	// and closes all resources associated with this transaction
	Close() error
}

Transaction represents a transaction in the Neo4j database

type TransactionConfig

type TransactionConfig struct {
	// Timeout is the configured transaction timeout.
	Timeout time.Duration
	// Metadata is the configured transaction metadata that will be attached to the underlying transaction.
	Metadata map[string]interface{}
}

TransactionConfig holds the settings for explicit and auto-commit transactions. Actual configuration is expected to be done using configuration functions that are predefined, i.e. 'WithTxTimeout' and 'WithTxMetadata', or one that you could write by your own.

type TransactionExecutionLimit added in v4.2.0

type TransactionExecutionLimit struct {
	Errors []error
	Causes []string
}

TransactionExecutionLimit error indicates that a retryable transaction has failed due to reaching a limit like a timeout or maximum number of attempts.

func (*TransactionExecutionLimit) Error added in v4.2.0

func (e *TransactionExecutionLimit) Error() string

type TransactionWork

type TransactionWork func(tx Transaction) (interface{}, error)

TransactionWork represents a unit of work that will be executed against the provided transaction

type UsageError added in v4.2.0

type UsageError struct {
	Message string
}

UsageError represents errors caused by incorrect usage of the driver API. This does not include Cypher syntax (those errors will be Neo4jError).

func (*UsageError) Error added in v4.2.0

func (e *UsageError) Error() string

Directories

Path Synopsis
Package db defines generic database functionality.
Package db defines generic database functionality.
Package dbtype contains definitions of supported database types.
Package dbtype contains definitions of supported database types.
internal
bolt
Package bolt contains implementations of the database functionality.
Package bolt contains implementations of the database functionality.
connector
Package connector is responsible for connecting to a database server.
Package connector is responsible for connecting to a database server.
packstream
Package packstream handles serialization of data sent to database server and deserialization of data received from database server.
Package packstream handles serialization of data sent to database server and deserialization of data received from database server.
pool
Package pool handles the database connection pool.
Package pool handles the database connection pool.
retry
Package retry handles retry operations.
Package retry handles retry operations.
testutil
Package testutil contains shared test functionality
Package testutil contains shared test functionality
Package log defines the logging interface used internally by the driver and provides default logging implementations.
Package log defines the logging interface used internally by the driver and provides default logging implementations.
test-integration
dbserver
Package dbserver is used by integration tests to connect to databases
Package dbserver is used by integration tests to connect to databases

Jump to

Keyboard shortcuts

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