txsession

package
v1.5.2-hotfix Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientPolicyBinding

type ClientPolicyBinding struct {
	Principal   string
	Username    string
	Fingerprint string
	ReadOnly    bool
}

ClientPolicyBinding pins an explicit request transaction to its executing identity and authorization revision. The request lease owns this metadata.

type ExecutorFactory

type ExecutorFactory func(dbName string) (*cypher.StorageExecutor, error)

ExecutorFactory creates a fresh executor scoped to a database. Each explicit transaction gets its own executor instance.

type Lease

type Lease struct {
	Session *Session
	// contains filtered or unexported fields
}

Lease serializes one request's use of a session against expiry and other requests. Release it when the request has finished using Session.

func (*Lease) CommitAndDelete

func (l *Lease) CommitAndDelete(ctx context.Context) (result *cypher.ExecuteResult, err error)

CommitAndDelete commits within this request's existing admission. Release the lease after response publication; Delete would reacquire the same lease.

func (*Lease) ExecuteInSession

func (l *Lease) ExecuteInSession(ctx context.Context, query string, params map[string]interface{}) (result *cypher.ExecuteResult, err error)

ExecuteInSession executes within this already-admitted request. Retain the lease through response publication, and release it only on actual completion.

func (*Lease) Release

func (l *Lease) Release()

Release ends the request's exclusive use of the leased session.

func (*Lease) Retain

func (l *Lease) Retain() *Lease

Retain transfers another share of this accepted request's ownership to its response publisher. Each share is released on actual completion. A timeout can end one waiter while its handler or buffered publication is still active. Retain must be called before releasing the source share.

func (*Lease) RollbackAndDelete

func (l *Lease) RollbackAndDelete(ctx context.Context) error

RollbackAndDelete rolls back within the existing request admission. Keep the lease until the request and its response publication have actually completed.

type Manager

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

Manager tracks explicit transaction sessions and lifecycle operations.

func NewManager

func NewManager(ttl time.Duration, factory ExecutorFactory, parent context.Context) *Manager

NewManager binds its lifetime parent once, before any opening work. Start/transport contexts must never replace this owner after enrollment.

func (*Manager) AcquireForOwner

func (m *Manager) AcquireForOwner(txID, owner string) (*Lease, bool)

AcquireForOwner leases an active session to one request. Expiry is checked after the request has decoded its body, so a transaction that expires while the body is being read is reported as not found. The lease keeps an accepted request serialized with expiry and other session operations until Release.

func (*Manager) Close

func (m *Manager) Close() error

Close rejects new sessions, rolls back every remaining transaction, removes it from the manager and stops its expiry timer. It is safe to call repeatedly.

func (*Manager) CloseContext

func (m *Manager) CloseContext(ctx context.Context) error

CloseContext rejects new sessions, rolls back every registered session once its active request has released it, and joins the manager's actual completion: rollbacks, leased requests, expiry timers and terminal observers. Every caller, first or repeated, joins the same completion and receives the same outcomes; ctx bounds only this caller's wait. A nil context is a programmer error and panics before closing admission.

func (*Manager) CommitAndDelete

func (m *Manager) CommitAndDelete(ctx context.Context, session *Session) (*cypher.ExecuteResult, error)

CommitAndDelete admits and joins a legacy session terminal operation. Transports already holding a request Lease use Lease.CommitAndDelete.

func (*Manager) Delete

func (m *Manager) Delete(txID string)

Delete retires a forgotten session through the same terminal owner. Its legacy void API retains cleanup errors for WaitClosed.

func (*Manager) ExecuteInSession

func (m *Manager) ExecuteInSession(ctx context.Context, session *Session, query string, params map[string]interface{}) (*cypher.ExecuteResult, error)

ExecuteInSession retains a legacy session operation through actual return. Transports holding an opening/request Lease use Lease.ExecuteInSession.

func (*Manager) Get

func (m *Manager) Get(txID string) (*Session, bool)

func (*Manager) GetForOwner

func (m *Manager) GetForOwner(txID string, owner string) (*Session, bool)

func (*Manager) Open

func (m *Manager) Open(ctx context.Context, dbName string) (*Session, error)

func (*Manager) OpenForOwner

func (m *Manager) OpenForOwner(ctx context.Context, dbName string, owner string) (*Session, error)

func (*Manager) OpenRequestForOwner

func (m *Manager) OpenRequestForOwner(ctx context.Context, dbName, owner string) (*Lease, error)

OpenRequestForOwner opens and leases in one admission operation. HTTP and other request transports must retain this lease through response publication; acquiring a lease after OpenForOwner leaves an idle-expiry gap.

func (*Manager) OpenRequestWithExecutorForOwner

func (m *Manager) OpenRequestWithExecutorForOwner(ctx context.Context, dbName string, executor *cypher.StorageExecutor, owner string) (*Lease, error)

OpenRequestWithExecutorForOwner is the request opening contract for executors built with transport-specific authentication. It has the same lease lifetime as OpenRequestForOwner, including internal one-shot and fallback opens.

func (*Manager) OpenWithExecutorForOwner

func (m *Manager) OpenWithExecutorForOwner(ctx context.Context, dbName string, executor *cypher.StorageExecutor, owner string) (*Session, error)

func (*Manager) RollbackAndDelete

func (m *Manager) RollbackAndDelete(ctx context.Context, session *Session) error

RollbackAndDelete admits and joins a legacy session rollback. An already retired session remains an idempotent no-op; WaitClosed joins late cleanup.

func (*Manager) SetTerminalErrorObserver

func (m *Manager) SetTerminalErrorObserver(observer func(*Session, error))

func (*Manager) Touch

func (m *Manager) Touch(session *Session)

func (*Manager) WaitClosed

func (m *Manager) WaitClosed(ctx context.Context) error

WaitClosed waits for actual cleanup completion after Close/CloseContext starts, including expiry workers already absent from sessions and terminal observers. It does not initiate close.

type Session

type Session struct {
	ID           string
	Database     string
	Owner        string
	Executor     *cypher.StorageExecutor
	Expires      time.Time
	ClientPolicy ClientPolicyBinding
	// contains filtered or unexported fields
}

Session stores explicit transaction state shared across transports.

func (*Session) ExpiresAt

func (session *Session) ExpiresAt() time.Time

ExpiresAt returns the expiry timestamp under the session lock.

Jump to

Keyboard shortcuts

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