context

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ct ContextType, params map[string]any) (types.BlockchainContext, error)

Get returns a new instance of the specified context type

func GetDefault

func GetDefault(params map[string]any) (types.BlockchainContext, error)

GetDefault returns a new instance of the default context type

func Register

func Register(ct ContextType, constructor ContextConstructor) error

Register adds a new BlockchainContext implementation to the registry

func SetDefault

func SetDefault(ct ContextType) error

SetDefault sets the default context type

Types

type ContextConstructor

type ContextConstructor func(params map[string]any) types.BlockchainContext

ContextConstructor is a function type that creates a new BlockchainContext instance

type ContextType

type ContextType string

ContextType represents the type of blockchain context

const (
	// MemoryContextType represents in-memory context implementation
	MemoryContextType ContextType = "memory"
	// DBContextType represents database-backed context implementation
	DBContextType ContextType = "db"
)

func DefaultContextType

func DefaultContextType() ContextType

DefaultContextType returns the current default context type

func ListRegistered

func ListRegistered() []ContextType

ListRegistered returns a list of all registered context types

type Registry

type Registry interface {
	// Register adds a new BlockchainContext implementation to the registry
	Register(ct ContextType, constructor ContextConstructor) error
	// SetDefault sets the default context type
	SetDefault(ct ContextType) error
	// Get returns a new instance of the specified context type
	Get(ct ContextType, params map[string]any) (types.BlockchainContext, error)
	// GetDefault returns a new instance of the default context type
	GetDefault(params map[string]any) (types.BlockchainContext, error)
	// DefaultContextType returns the current default context type
	DefaultContextType() ContextType
	// ListRegistered returns a list of all registered context types
	ListRegistered() []ContextType
}

Registry defines the interface for managing BlockchainContext implementations

func GetRegistry

func GetRegistry() Registry

GetRegistry returns the global Registry instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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