Help us shape the future of Go! Take the 2026 Go Developer Survey

lifecycle

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package lifecycle tracks whether a [synapse.Client] has been closed so that services derived from it can refuse new work with a clear error rather than making RPC calls on a closed ethclient.

Lifecycle is shared between the root Client and all of its services: Client.Close marks the Lifecycle closed; each service's public methods fail fast with ErrClosed while still being safe for concurrent use.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("synapse: client closed")

ErrClosed is returned from any service method called after the owning Client's Close has executed.

Functions

This section is empty.

Types

type Lifecycle

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

Lifecycle is safe for concurrent use. The zero value is a usable, unclosed lifecycle. A nil receiver is treated as a permanently-open lifecycle so services used without a root Client (e.g. in tests) skip the closed check entirely.

func New

func New() *Lifecycle

New returns a fresh, unclosed Lifecycle.

func (*Lifecycle) CheckClosed

func (l *Lifecycle) CheckClosed() error

CheckClosed returns ErrClosed if the lifecycle has been closed. Nil-safe.

func (*Lifecycle) Close

func (l *Lifecycle) Close()

Close marks the lifecycle closed. Idempotent and nil-safe.

func (*Lifecycle) IsClosed

func (l *Lifecycle) IsClosed() bool

IsClosed reports whether Close has been called. Nil-safe.

Jump to

Keyboard shortcuts

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