Documentation
¶
Index ¶
- Variables
- func As[T any](src any) (T, error)
- func IdentityUpdaterF(latest any, incoming any) (any, error)
- type AddressRef
- type AddressRefKey
- type AddressRefStore
- type BaseCatalogStore
- type BaseDataStore
- type BaseDataStoreV2
- type CatalogStore
- type ChainMetadata
- type ChainMetadataKey
- type ChainMetadataStore
- type Comparable
- type ContractMetadata
- type ContractMetadataKey
- type ContractMetadataStore
- type ContractType
- type DataStore
- type EnvMetadata
- type EnvMetadataStore
- type Fetcher
- type FetcherV2
- type FilterFunc
- func AddressRefByAddress(address string) FilterFunc[AddressRefKey, AddressRef]
- func AddressRefByChainSelector(chainSelector uint64) FilterFunc[AddressRefKey, AddressRef]
- func AddressRefByQualifier(qualifier string) FilterFunc[AddressRefKey, AddressRef]
- func AddressRefByType(contractType ContractType) FilterFunc[AddressRefKey, AddressRef]
- func AddressRefByVersion(version *semver.Version) FilterFunc[AddressRefKey, AddressRef]
- func ChainMetadataByChainSelector(chainSelector uint64) FilterFunc[ChainMetadataKey, ChainMetadata]
- func ContractMetadataByChainSelector(chainSelector uint64) FilterFunc[ContractMetadataKey, ContractMetadata]
- type Filterable
- type FilterableV2
- type GetOption
- type Getter
- type GetterV2
- type LabelSet
- func (s *LabelSet) Add(label string)
- func (s *LabelSet) Clone() LabelSet
- func (s *LabelSet) Contains(label string) bool
- func (s *LabelSet) Equal(other LabelSet) bool
- func (s *LabelSet) IsEmpty() bool
- func (s *LabelSet) Length() int
- func (s *LabelSet) List() []string
- func (s LabelSet) MarshalJSON() ([]byte, error)
- func (s *LabelSet) Remove(label string)
- func (s *LabelSet) String() string
- func (s *LabelSet) UnmarshalJSON(data []byte) error
- type MemoryAddressRefStore
- func (s *MemoryAddressRefStore) Add(record AddressRef) error
- func (s *MemoryAddressRefStore) Delete(key AddressRefKey) error
- func (s *MemoryAddressRefStore) Fetch() ([]AddressRef, error)
- func (s *MemoryAddressRefStore) Filter(filters ...FilterFunc[AddressRefKey, AddressRef]) []AddressRef
- func (s *MemoryAddressRefStore) Get(key AddressRefKey) (AddressRef, error)
- func (s *MemoryAddressRefStore) Update(record AddressRef) error
- func (s *MemoryAddressRefStore) Upsert(record AddressRef) error
- type MemoryChainMetadataStore
- func (s *MemoryChainMetadataStore) Add(record ChainMetadata) error
- func (s *MemoryChainMetadataStore) Delete(key ChainMetadataKey) error
- func (s *MemoryChainMetadataStore) Fetch() ([]ChainMetadata, error)
- func (s *MemoryChainMetadataStore) Filter(filters ...FilterFunc[ChainMetadataKey, ChainMetadata]) []ChainMetadata
- func (s *MemoryChainMetadataStore) Get(key ChainMetadataKey) (ChainMetadata, error)
- func (s *MemoryChainMetadataStore) Update(record ChainMetadata) error
- func (s *MemoryChainMetadataStore) Upsert(record ChainMetadata) error
- type MemoryContractMetadataStore
- func (s *MemoryContractMetadataStore) Add(record ContractMetadata) error
- func (s *MemoryContractMetadataStore) Delete(key ContractMetadataKey) error
- func (s *MemoryContractMetadataStore) Fetch() ([]ContractMetadata, error)
- func (s *MemoryContractMetadataStore) Filter(filters ...FilterFunc[ContractMetadataKey, ContractMetadata]) []ContractMetadata
- func (s *MemoryContractMetadataStore) Get(key ContractMetadataKey) (ContractMetadata, error)
- func (s *MemoryContractMetadataStore) Update(record ContractMetadata) error
- func (s *MemoryContractMetadataStore) Upsert(record ContractMetadata) error
- type MemoryDataStore
- func (s *MemoryDataStore) Addresses() MutableAddressRefStore
- func (s *MemoryDataStore) ChainMetadata() MutableChainMetadataStore
- func (s *MemoryDataStore) ContractMetadata() MutableContractMetadataStore
- func (s *MemoryDataStore) EnvMetadata() MutableEnvMetadataStore
- func (s *MemoryDataStore) Merge(other DataStore) error
- func (s *MemoryDataStore) Seal() DataStore
- type MemoryEnvMetadataStore
- type Merger
- type MetadataUpdaterF
- type MutableAddressRefStore
- type MutableChainMetadataStore
- type MutableContractMetadataStore
- type MutableDataStore
- type MutableEnvMetadataStore
- type MutableRefStoreV2
- type MutableStore
- type MutableStoreV2
- type MutableUnaryStore
- type MutableUnaryStoreV2
- type PrimaryKeyHolder
- type Sealer
- type Store
- type TransactionLogic
- type Transactional
- type UnaryStore
- type UniqueRecord
- type UpdateOption
- type UpdateOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrAddressRefNotFound = errors.New("no such address ref can be found for the provided key") ErrAddressRefExists = errors.New("an address ref with the supplied key already exists") )
var ErrChainMetadataExists = errors.New("a chain metadata record with the supplied key already exists")
var ErrChainMetadataNotFound = errors.New("no chain metadata record can be found for the provided key")
var ErrChainMetadataStale = errors.New("the chain metadata record with the given key is stale and cannot be updated")
var ErrContractMetadataExists = errors.New("a contract metadata record with the supplied key already exists")
var ErrContractMetadataNotFound = errors.New("no contract metadata record can be found for the provided key")
var ErrContractMetadataStale = errors.New("the contract metadata record with the given key is stale and cannot be updated")
var ErrEnvMetadataNotSet = errors.New("no environment metadata set")
var ErrEnvMetadataStale = errors.New("environment metadata version is stale")
Functions ¶
func As ¶ added in v0.9.0
As is a utility function that converts a source value of any type to a destination type T. It uses JSON marshaling and unmarshaling to perform the conversion. It can be used to convert metadata of any type to a specific type, as shown in the example below.
Example usage:
record, err := store.ContractMetadata().Get(NewContractMetadataKey(chainSelector, address)) if err != nil { return nil, err } concrete, err := As[ConcreteMetadataType](record.Metadata) if err != nil { return nil, err }
Types ¶
type AddressRef ¶
type AddressRef struct { // Address is the address of the contract on the chain. Address string `json:"address"` // ChainSelector is the chain-selector of the chain where the contract is deployed. ChainSelector uint64 `json:"chainSelector"` // Labels are the labels associated with the contract. Labels LabelSet `json:"labels"` // Qualifier is an optional qualifier for the contract. Qualifier string `json:"qualifier"` // ContractType is a simple string type for identifying contract types. Type ContractType `json:"type"` // Version is the version of the contract. Version *semver.Version `json:"version"` }
func (AddressRef) Clone ¶
func (r AddressRef) Clone() AddressRef
Clone creates a copy of the AddressRefRecord.
func (AddressRef) Key ¶
func (r AddressRef) Key() AddressRefKey
Key returns the AddressRefKey for the AddressRefRecord.
type AddressRefKey ¶
type AddressRefKey interface { Comparable[AddressRefKey] fmt.Stringer // ChainSelector returns the chain-selector selector of the chain where the contract is deployed. ChainSelector() uint64 // Type returns the contract type of the contract. // This is a simple string type for identifying contract Type() ContractType // Version returns the semantic version of the contract. Version() *semver.Version // Qualifier returns the optional qualifier for the contract. // This can be used to differentiate between different references of the same contract. Qualifier() string }
AddressRefKey is an interface that represents a key for AddressRef records. It is used to uniquely identify a record in the AddressRefStore.
func NewAddressRefKey ¶
func NewAddressRefKey(chainSelector uint64, contractType ContractType, version *semver.Version, qualifier string) AddressRefKey
NewAddressRefKey creates a new AddressRefKey instance.
type AddressRefStore ¶
type AddressRefStore interface { Store[AddressRefKey, AddressRef] }
AddressRefStore is an interface that represents an immutable view over a set of AddressRef records identified by AddressRefKey.
type BaseCatalogStore ¶ added in v0.25.0
type BaseCatalogStore interface { BaseDataStoreV2[ MutableRefStoreV2[AddressRefKey, AddressRef], MutableStoreV2[ChainMetadataKey, ChainMetadata], MutableStoreV2[ContractMetadataKey, ContractMetadata], MutableUnaryStoreV2[EnvMetadata], ] }
BaseCatalogStore is a convenience interface which pulls together all of the individual store (table) interfaces.
type BaseDataStore ¶
type BaseDataStore[ R AddressRefStore, CH ChainMetadataStore, CM ContractMetadataStore, EM EnvMetadataStore, ] interface { Addresses() R ChainMetadata() CH ContractMetadata() CM EnvMetadata() EM }
BaseDataStore is an interface that defines the basic operations for a data store. It is parameterized by the type of address reference store, chain metadata, contract metadata store and env metadata store it uses.
type BaseDataStoreV2 ¶ added in v0.18.0
type BaseDataStoreV2[ R MutableRefStoreV2[AddressRefKey, AddressRef], CH MutableStoreV2[ChainMetadataKey, ChainMetadata], CM MutableStoreV2[ContractMetadataKey, ContractMetadata], EM MutableUnaryStoreV2[EnvMetadata], ] interface { Addresses() R ChainMetadata() CH ContractMetadata() CM EnvMetadata() EM }
BaseDataStoreV2 is an interface that defines the basic operations for a data store using V2 interfaces.
type CatalogStore ¶ added in v0.18.0
type CatalogStore interface { Transactional BaseCatalogStore }
CatalogStore is a fully featured data store, with read/write access to all of the individual stores (tables), as well as supporting transaction handling.
type ChainMetadata ¶ added in v0.13.1
type ChainMetadata struct { // ChainSelector refers to the chain associated with the metadata. ChainSelector uint64 `json:"chainSelector"` // Metadata is the metadata associated with the chain. Metadata any `json:"metadata"` }
ChainMetadata is a struct that holds the metadata for a specific chain. It implements the UniqueRecord interface and is used to store chain metadata in the datastore. NOTE: Metadata can be of any type. To convert from any to a specific type, use the utility method As.
func (ChainMetadata) Clone ¶ added in v0.13.1
func (r ChainMetadata) Clone() (ChainMetadata, error)
Clone creates a copy of the ChainMetadata.
func (ChainMetadata) Key ¶ added in v0.13.1
func (r ChainMetadata) Key() ChainMetadataKey
Key returns the ChainMetadataKey for the ChainMetadata. It is used to uniquely identify the chain metadata in the datastore.
type ChainMetadataKey ¶ added in v0.13.1
type ChainMetadataKey interface { Comparable[ChainMetadataKey] fmt.Stringer // ChainSelector returns the chain-selector of the chain associated with the metadata. ChainSelector() uint64 }
ChainMetadataKey is an interface that represents a key for ChainMetadata records. It is used to uniquely identify a record in the ChainMetadataStore.
func NewChainMetadataKey ¶ added in v0.13.1
func NewChainMetadataKey(chainSelector uint64) ChainMetadataKey
NewChainMetadataKey creates a new ChainMetadataKey instance.
type ChainMetadataStore ¶ added in v0.13.1
type ChainMetadataStore interface { Store[ChainMetadataKey, ChainMetadata] }
ChainMetadataStore is an interface that represents an immutable view over a set of ChainMetadata records identified by ChainMetadataKey.
type Comparable ¶
type Comparable[T any] interface { // Equals returns true if the two instances are equal, false otherwise. Equals(T) bool }
Comparable provides an Equals() method which returns true if the two instances are equal, false otherwise.
type ContractMetadata ¶
type ContractMetadata struct { // Address is the address of the contract on the chain. Address string `json:"address"` // ChainSelector is the chain-selector of the chain where the contract is deployed. ChainSelector uint64 `json:"chainSelector"` // Metadata is the metadata associated with the contract. Metadata any `json:"metadata"` }
ContractMetadata is a struct that holds the metadata for a contract on a specific chain. It implements the UniqueRecord interface and is used to store contract metadata in the datastore. NOTE: Metadata can be of any type. To convert from any to a specific type, use the utility method As.
func (ContractMetadata) Clone ¶
func (r ContractMetadata) Clone() (ContractMetadata, error)
Clone creates a copy of the ContractMetadata.
func (ContractMetadata) Key ¶
func (r ContractMetadata) Key() ContractMetadataKey
Key returns the ContractMetadataKey for the ContractMetadata. It is used to uniquely identify the contract metadata in the datastore.
type ContractMetadataKey ¶
type ContractMetadataKey interface { Comparable[ContractMetadataKey] fmt.Stringer // Address returns the address of the contract on the chain. Address() string // ChainSelector returns the chain-selector of the chain where the contract is deployed. ChainSelector() uint64 }
ContractMetadataKey is an interface that represents a key for ContractMetadata records. It is used to uniquely identify a record in the ContractMetadataStore.
func NewContractMetadataKey ¶
func NewContractMetadataKey(chainSelector uint64, address string) ContractMetadataKey
NewContractMetadataKey creates a new ContractMetadataKey instance.
type ContractMetadataStore ¶
type ContractMetadataStore interface { Store[ContractMetadataKey, ContractMetadata] }
ContractMetadataStore is an interface that represents an immutable view over a set of ContractMetadata records identified by ContractMetadataKey.
type ContractType ¶
type ContractType string
ContractType is a simple string type for identifying contract types.
func (ContractType) String ¶
func (ct ContractType) String() string
String returns the string representation of the ContractType.
type DataStore ¶
type DataStore interface { BaseDataStore[ AddressRefStore, ChainMetadataStore, ContractMetadataStore, EnvMetadataStore, ] }
DataStore is an interface that defines the operations for a read-only data store.
type EnvMetadata ¶
type EnvMetadata struct { // Metadata is the metadata associated with the domain and environment. Metadata any `json:"metadata"` }
EnvMetadata is a struct that holds the metadata for a domain and environment. NOTE: Metadata can be of any type. To convert from any to a specific type, use the utility method As.
func (EnvMetadata) Clone ¶
func (r EnvMetadata) Clone() (EnvMetadata, error)
Clone creates a copy of the EnvMetadata.
type EnvMetadataStore ¶
type EnvMetadataStore interface { UnaryStore[EnvMetadata] }
EnvMetadataStore is an interface that defines the methods for a store that manages environment metadata.
type Fetcher ¶
type Fetcher[R any] interface { // Fetch returns a slice of records representing the entire data set. The returned slice // will be a newly allocated slice (not a reference to an existing one), and each record should // be a copy of the corresponding stored data. Modifying the returned slice or its records must // not affect the underlying data. Fetch() ([]R, error) }
Fetcher provides a Fetch() method which is used to complete a read query from a Store.
type FetcherV2 ¶ added in v0.18.0
type FetcherV2[R any] interface { // Fetch returns a slice of records representing the entire data set. The returned slice // will be a newly allocated slice (not a reference to an existing one), and each record should // be a copy of the corresponding stored data. Modifying the returned slice or its records must // not affect the underlying data. Fetch(context.Context) ([]R, error) }
FetcherV2 provides a Fetch() method which is used to complete a read query from a Store.
type FilterFunc ¶
type FilterFunc[K Comparable[K], R UniqueRecord[K, R]] func([]R) []R
FilterFunc is a function that filters a slice of records.
func AddressRefByAddress ¶ added in v0.0.5
func AddressRefByAddress(address string) FilterFunc[AddressRefKey, AddressRef]
AddressRefByAddress returns a filter that only includes records with the provided address
func AddressRefByChainSelector ¶
func AddressRefByChainSelector(chainSelector uint64) FilterFunc[AddressRefKey, AddressRef]
AddressRefByChainSelector returns a filter that only includes records with the provided chain.
func AddressRefByQualifier ¶
func AddressRefByQualifier(qualifier string) FilterFunc[AddressRefKey, AddressRef]
AddressRefByQualifier returns a filter that only includes records with the provided qualifier.
func AddressRefByType ¶
func AddressRefByType(contractType ContractType) FilterFunc[AddressRefKey, AddressRef]
AddressRefByType returns a filter that only includes records with the provided contract type.
func AddressRefByVersion ¶
func AddressRefByVersion(version *semver.Version) FilterFunc[AddressRefKey, AddressRef]
AddressRefByVersion returns a filter that only includes records with the provided version.
func ChainMetadataByChainSelector ¶ added in v0.13.1
func ChainMetadataByChainSelector(chainSelector uint64) FilterFunc[ChainMetadataKey, ChainMetadata]
ChainMetadataByChainSelector returns a filter that only includes records with the provided chain selector.
func ContractMetadataByChainSelector ¶
func ContractMetadataByChainSelector(chainSelector uint64) FilterFunc[ContractMetadataKey, ContractMetadata]
ContractMetadataByChainSelector returns a filter that only includes records with the provided chain.
type Filterable ¶
type Filterable[K Comparable[K], R UniqueRecord[K, R]] interface { Filter(filters ...FilterFunc[K, R]) []R }
Filterable provides a Filter() method which is used to complete a filtered query with from a Store.
type FilterableV2 ¶ added in v0.18.0
type FilterableV2[K Comparable[K], R UniqueRecord[K, R]] interface { Filter(context.Context, ...FilterFunc[K, R]) ([]R, error) }
FilterableV2 provides a Filter() method which is used to complete a filtered query with from a Store.
type GetOption ¶ added in v0.25.0
type GetOption interface {
// contains filtered or unexported methods
}
GetOption is a supertype of all options for fetching/getting. Only the options specified in this package are valid.
var IgnoreTransactionsGetOption GetOption = ignoreTransactionsGetOption{}
type Getter ¶
type Getter[K Comparable[K], R UniqueRecord[K, R]] interface { // Get returns the record with the given key, or an error if no such record exists. Get(K) (R, error) }
Getter provides a Get() method which is used to complete a read by key query from a Store.
type GetterV2 ¶ added in v0.18.0
type GetterV2[K Comparable[K], R UniqueRecord[K, R]] interface { // Get returns the record with the given key, or an error if no such record exists. // // GetOptions may be supplied to modify the semantics of the call, as specified in the option. Get(context.Context, K, ...GetOption) (R, error) }
GetterV2 provides a Get() method which is used to complete a read by key query from a Store.
type LabelSet ¶
type LabelSet struct {
// contains filtered or unexported fields
}
LabelSet represents a set of labels on an address book entry.
func NewLabelSet ¶
NewLabelSet initializes a new LabelSet with any number of labels.
func (LabelSet) MarshalJSON ¶ added in v0.0.5
MarshalJSON marshals the LabelSet as a JSON array of strings.
Implements the json.Marshaler interface.
func (*LabelSet) String ¶
String returns the labels as a sorted, space-separated string.
Implements the fmt.Stringer interface.
func (*LabelSet) UnmarshalJSON ¶ added in v0.0.5
UnmarshalJSON unmarshals a JSON array of strings into the LabelSet.
Implements the json.Unmarshaler interface.
type MemoryAddressRefStore ¶
type MemoryAddressRefStore struct { Records []AddressRef `json:"records"` // contains filtered or unexported fields }
MemoryAddressRefStore is an in-memory implementation of the AddressRefStore and MutableAddressRefStore interfaces.
func NewMemoryAddressRefStore ¶
func NewMemoryAddressRefStore() *MemoryAddressRefStore
NewMemoryAddressRefStore creates a new MemoryAddressRefStore instance.
func (*MemoryAddressRefStore) Add ¶
func (s *MemoryAddressRefStore) Add(record AddressRef) error
Add inserts a new record into the store. If a record with the same key already exists, an error is returned.
func (*MemoryAddressRefStore) Delete ¶
func (s *MemoryAddressRefStore) Delete(key AddressRefKey) error
Delete deletes record whose primary key elements match the supplied AddressRecord, returning an error if no such record exists to be deleted.
func (*MemoryAddressRefStore) Fetch ¶
func (s *MemoryAddressRefStore) Fetch() ([]AddressRef, error)
Fetch returns a copy of all AddressRef in the store.
func (*MemoryAddressRefStore) Filter ¶
func (s *MemoryAddressRefStore) Filter(filters ...FilterFunc[AddressRefKey, AddressRef]) []AddressRef
Filter returns a copy of all AddressRef in the store that pass all of the provided filters. Filters are applied in the order they are provided. If no filters are provided, all records are returned.
func (*MemoryAddressRefStore) Get ¶
func (s *MemoryAddressRefStore) Get(key AddressRefKey) (AddressRef, error)
Get returns the AddressRef for the provided key, or an error if no such record exists.
func (*MemoryAddressRefStore) Update ¶
func (s *MemoryAddressRefStore) Update(record AddressRef) error
Update edits an existing record whose fields match the primary key elements of the supplied AddressRecord, with the non-primary-key values of the supplied AddressRecord. If no such record exists, an error is returned.
func (*MemoryAddressRefStore) Upsert ¶
func (s *MemoryAddressRefStore) Upsert(record AddressRef) error
Upsert inserts a new record into the store if no record with the same key already exists. If a record with the same key already exists, it is updated.
type MemoryChainMetadataStore ¶ added in v0.13.1
type MemoryChainMetadataStore struct { Records []ChainMetadata `json:"records"` // contains filtered or unexported fields }
MemoryChainMetadataStore is an in-memory implementation of the ChainMetadataStore and MutableChainMetadataStore interfaces.
func NewMemoryChainMetadataStore ¶ added in v0.13.1
func NewMemoryChainMetadataStore() *MemoryChainMetadataStore
NewMemoryChainMetadataStore creates a new MemoryChainMetadataStore instance.
func (*MemoryChainMetadataStore) Add ¶ added in v0.13.1
func (s *MemoryChainMetadataStore) Add(record ChainMetadata) error
Add inserts a new record into the store. If a record with the same key already exists, an error is returned.
func (*MemoryChainMetadataStore) Delete ¶ added in v0.13.1
func (s *MemoryChainMetadataStore) Delete(key ChainMetadataKey) error
Delete deletes an existing record whose primary key elements match the supplied ChainMetadata, returning an error if no such record exists.
func (*MemoryChainMetadataStore) Fetch ¶ added in v0.13.1
func (s *MemoryChainMetadataStore) Fetch() ([]ChainMetadata, error)
Fetch returns a copy of all ChainMetadata in the store. NOTE: The returned ChainMetadata will have an any type for the Metadata field. To convert it to a specific type, use the utility method As.
func (*MemoryChainMetadataStore) Filter ¶ added in v0.13.1
func (s *MemoryChainMetadataStore) Filter(filters ...FilterFunc[ChainMetadataKey, ChainMetadata]) []ChainMetadata
Filter returns a copy of all ChainMetadata in the store that pass all of the provided filters. Filters are applied in the order they are provided. If no filters are provided, all records are returned. NOTE: The returned ChainMetadata will have an any type for the Metadata field. To convert it to a specific type, use the utility method As.
func (*MemoryChainMetadataStore) Get ¶ added in v0.13.1
func (s *MemoryChainMetadataStore) Get(key ChainMetadataKey) (ChainMetadata, error)
Get returns the ChainMetadata for the provided key, or an error if no such record exists. NOTE: The returned ChainMetadata will have an any type for the Metadata field. To convert it to a specific type, use the utility method As.
func (*MemoryChainMetadataStore) Update ¶ added in v0.13.1
func (s *MemoryChainMetadataStore) Update(record ChainMetadata) error
Update edits an existing record whose fields match the primary key elements of the supplied ChainMetadata, with the non-primary-key values of the supplied ChainMetadata. If no such record exists, an error is returned.
func (*MemoryChainMetadataStore) Upsert ¶ added in v0.13.1
func (s *MemoryChainMetadataStore) Upsert(record ChainMetadata) error
Upsert inserts a new record into the store if no record with the same key already exists. If a record with the same key already exists, it is updated.
type MemoryContractMetadataStore ¶
type MemoryContractMetadataStore struct { Records []ContractMetadata `json:"records"` // contains filtered or unexported fields }
MemoryContractMetadataStore is an in-memory implementation of the ContractMetadataStore and MutableContractMetadataStore interfaces.
func NewMemoryContractMetadataStore ¶
func NewMemoryContractMetadataStore() *MemoryContractMetadataStore
NewMemoryContractMetadataStore creates a new MemoryContractMetadataStore instance.
func (*MemoryContractMetadataStore) Add ¶
func (s *MemoryContractMetadataStore) Add(record ContractMetadata) error
Add inserts a new record into the store. If a record with the same key already exists, an error is returned.
func (*MemoryContractMetadataStore) Delete ¶
func (s *MemoryContractMetadataStore) Delete(key ContractMetadataKey) error
Delete deletes an existing record whose primary key elements match the supplied ContractMetadata, returning an error if no such record exists.
func (*MemoryContractMetadataStore) Fetch ¶
func (s *MemoryContractMetadataStore) Fetch() ([]ContractMetadata, error)
Fetch returns a copy of all ContractMetadata in the store. NOTE: The returned ContractMetadata will have an any type for the Metadata field. To convert it to a specific type, use the utility method As.
func (*MemoryContractMetadataStore) Filter ¶
func (s *MemoryContractMetadataStore) Filter(filters ...FilterFunc[ContractMetadataKey, ContractMetadata]) []ContractMetadata
Filter returns a copy of all ContractMetadata in the store that pass all of the provided filters. Filters are applied in the order they are provided. If no filters are provided, all records are returned. NOTE: The returned ContractMetadata will have an any type for the Metadata field. To convert it to a specific type, use the utility method As.
func (*MemoryContractMetadataStore) Get ¶
func (s *MemoryContractMetadataStore) Get(key ContractMetadataKey) (ContractMetadata, error)
Get returns the ContractMetadata for the provided key, or an error if no such record exists. NOTE: The returned ContractMetadata will have an any type for the Metadata field. To convert it to a specific type, use the utility method As.
func (*MemoryContractMetadataStore) Update ¶
func (s *MemoryContractMetadataStore) Update(record ContractMetadata) error
Update edits an existing record whose fields match the primary key elements of the supplied ContractMetadata, with the non-primary-key values of the supplied ContractMetadata. If no such record exists, an error is returned.
func (*MemoryContractMetadataStore) Upsert ¶
func (s *MemoryContractMetadataStore) Upsert(record ContractMetadata) error
Upsert inserts a new record into the store if no record with the same key already exists. If a record with the same key already exists, it is updated.
type MemoryDataStore ¶
type MemoryDataStore struct { AddressRefStore *MemoryAddressRefStore `json:"addressRefStore"` ChainMetadataStore *MemoryChainMetadataStore `json:"chainMetadataStore"` ContractMetadataStore *MemoryContractMetadataStore `json:"contractMetadataStore"` EnvMetadataStore *MemoryEnvMetadataStore `json:"envMetadataStore"` }
func NewMemoryDataStore ¶
func NewMemoryDataStore() *MemoryDataStore
NewMemoryDataStore creates a new instance of MemoryDataStore. NOTE: The instance returned is mutable and can be modified.
func (*MemoryDataStore) Addresses ¶
func (s *MemoryDataStore) Addresses() MutableAddressRefStore
Addresses returns the AddressRefStore of the MemoryDataStore.
func (*MemoryDataStore) ChainMetadata ¶ added in v0.13.1
func (s *MemoryDataStore) ChainMetadata() MutableChainMetadataStore
ChainMetadata returns the ChainMetadataStore of the MemoryDataStore.
func (*MemoryDataStore) ContractMetadata ¶
func (s *MemoryDataStore) ContractMetadata() MutableContractMetadataStore
ContractMetadata returns the ContractMetadataStore of the MemoryDataStore.
func (*MemoryDataStore) EnvMetadata ¶
func (s *MemoryDataStore) EnvMetadata() MutableEnvMetadataStore
EnvMetadata returns the EnvMetadataStore of the MutableEnvMetadataStore.
func (*MemoryDataStore) Merge ¶
func (s *MemoryDataStore) Merge(other DataStore) error
Merge merges the given mutable data store into the current MemoryDataStore.
func (*MemoryDataStore) Seal ¶
func (s *MemoryDataStore) Seal() DataStore
Seal seals the MemoryDataStore, by returning a new instance of sealedMemoryDataStore.
type MemoryEnvMetadataStore ¶
type MemoryEnvMetadataStore struct { Record *EnvMetadata `json:"record"` // contains filtered or unexported fields }
MemoryEnvMetadataStore is a concrete implementation of the EnvMetadataStore interface.
func NewMemoryEnvMetadataStore ¶
func NewMemoryEnvMetadataStore() *MemoryEnvMetadataStore
NewMemoryEnvMetadataStore creates a new MemoryEnvMetadataStore instance.
func (*MemoryEnvMetadataStore) Get ¶
func (s *MemoryEnvMetadataStore) Get() (EnvMetadata, error)
Get returns a copy of the stored EnvMetadata record if it exists or an error if any occurred. If no record exist, it returns an empty EnvMetadata and ErrEnvMetadataNotSet. If the record exists, it returns a copy of the record and a nil error. NOTE: The returned EnvMetadata will have an any type for the Metadata field. To convert it to a specific type, use the utility method As.
func (*MemoryEnvMetadataStore) Set ¶
func (s *MemoryEnvMetadataStore) Set(record EnvMetadata) error
Set sets the EnvMetadata record in the store. If the record already exists, it will be replaced.
type Merger ¶
type Merger[T any] interface { // Merge merges the given data into the current data store. // It should return an error if the merge fails. Merge(other T) error }
Merger is an interface that defines a method for merging two data stores.
type MetadataUpdaterF ¶ added in v0.18.0
MetadataUpdaterF characterises a change to some metadata as a sort of operational transform, which can be run against any conforming metadata object. It should be cautious - e.g. if it's adding to a slice in a sub-struct it should make sure the sub-struct was initialized, so the logic is universal to any version of that metadata struct it happens upon.
This approach, used via WithUpdater, allows for conflict-free update logic to be applied, with automatic handling of any data races.
type MutableAddressRefStore ¶
type MutableAddressRefStore interface { MutableStore[AddressRefKey, AddressRef] }
MutableAddressRefStore is an interface that represents a mutable AddressRefStore of AddressRef records identified by AddressRefKey.
type MutableChainMetadataStore ¶ added in v0.13.1
type MutableChainMetadataStore interface { MutableStore[ChainMetadataKey, ChainMetadata] }
MutableChainMetadataStore is an interface that represents a mutable ChainMetadataStore of ChainMetadata records identified by ChainMetadataKey.
type MutableContractMetadataStore ¶
type MutableContractMetadataStore interface { MutableStore[ContractMetadataKey, ContractMetadata] }
MutableContractMetadataStore is an interface that represents a mutable ContractMetadataStore of ContractMetadata records identified by ContractMetadataKey.
type MutableDataStore ¶
type MutableDataStore interface { Merger[DataStore] Sealer[DataStore] BaseDataStore[ MutableAddressRefStore, MutableChainMetadataStore, MutableContractMetadataStore, MutableEnvMetadataStore, ] }
MutableDataStore is an interface that defines the operations for a mutable data store.
type MutableEnvMetadataStore ¶
type MutableEnvMetadataStore interface { MutableUnaryStore[EnvMetadata] }
MutableEnvMetadataStore is an interface that defines the methods for a mutable store that manages environment metadata.
type MutableRefStoreV2 ¶ added in v0.18.0
type MutableStore ¶
type MutableStore[K Comparable[K], R UniqueRecord[K, R]] interface { Store[K, R] // Add inserts a new record into the MutableStore. Add(record R) error // Upsert behaves like Add where there is not already a record with the same composite primary key as the // supplied record, otherwise it behaves like an update. Upsert(record R) error // Update edits an existing record whose fields match the primary key elements of the supplied AddressRecord, with // the non-primary-key values of the supplied AddressRecord. Update(record R) error // Delete deletes record whose primary key elements match the supplied key, returning an error if no // such record exists to be deleted Delete(key K) error }
MutableStore is an interface that represents a mutable set of records.
type MutableStoreV2 ¶ added in v0.18.0
type MutableStoreV2[K Comparable[K], R UniqueRecord[K, R]] interface { FetcherV2[R] GetterV2[K, R] FilterableV2[K, R] // Add inserts a new record into the MutableStore. Add(ctx context.Context, record R) error // Upsert behaves like Add where there is not already a record with the same composite primary key as the // supplied record, otherwise it behaves like an update. // Options can be provided to customize the behavior (e.g., custom updater function). Upsert(ctx context.Context, key K, metadata any, opts ...UpdateOption) error // Update edits an existing record whose fields match the primary key elements of the supplied AddressRecord, with // the non-primary-key values of the supplied AddressRecord. // Options can be provided to customize the behavior (e.g., custom updater function). Update(ctx context.Context, key K, metadata any, opts ...UpdateOption) error // Delete deletes record whose primary key elements match the supplied key, returning an error if no // such record exists to be deleted Delete(ctx context.Context, key K) error }
MutableStoreV2 is an interface that represents a mutable set of records.
type MutableUnaryStore ¶
type MutableUnaryStore[R any] interface { // Get returns a copy of the record or an error. // If the record exists, the error should be nil. // If the record does not exist, the error should not be nil. Get() (R, error) // Set sets the record in the store. // If the record already exists, it should be replaced. // If the record does not exist, it should be added. Set(record R) error }
MutableUnaryStore is an interface that represents a mutable store that contains a single record.
type MutableUnaryStoreV2 ¶ added in v0.18.0
type MutableUnaryStoreV2[R any] interface { // Get returns a copy of the record or an error. // If the record exists, the error should be nil. // If the record does not exist, the error should not be nil. Get(ctx context.Context, options ...GetOption) (R, error) // Set sets the record in the store. // If the record already exists, it should be replaced. // If the record does not exist, it should be added. // Options can be provided to customize the behavior (e.g., custom updater function). Set(ctx context.Context, metadata any, opts ...UpdateOption) error }
MutableUnaryStoreV2 is an interface that represents a mutable store that contains a single record.
type PrimaryKeyHolder ¶
type PrimaryKeyHolder[K Comparable[K]] interface { // Key returns the primary key for the implementing type. Key() K }
PrimaryKeyHolder is an interface for types that can provide a unique identifier key for themselves.
type Sealer ¶
type Sealer[T any] interface { // Seal seals the data store, preventing further modifications. Seal() T }
Sealer is an interface that defines a method for sealing a data store. A sealed data store cannot be modified further.
type Store ¶
type Store[K Comparable[K], R UniqueRecord[K, R]] interface { Fetcher[R] Getter[K, R] Filterable[K, R] }
Store is an interface that represents an immutable set of records.
type TransactionLogic ¶ added in v0.25.0
type TransactionLogic func(ctx context.Context, catalog BaseCatalogStore) error
type Transactional ¶ added in v0.25.0
type Transactional interface { // WithTransaction allows the caller to wrap their datastore operations in a transactional // boundary, such that any datastore operations will succeed or fail together. The caller // supplies a lambda containing the operations, which the calling context being plumbed // through. Starting and committing the transaction is automated, and if an error is // returned, the transaction is rolled-back instead. WithTransaction(ctx context.Context, fn TransactionLogic) error }
Transactional is an interface which supports keeping datastore operations within transactional boundaries.
type UnaryStore ¶
type UnaryStore[R any] interface { // Get returns the record or an error. // if the record exists, the error should be nil. // If the record does not exist, the error should not be nil. Get() (R, error) }
UnaryStore is an interface that represents a read-only store that is limited to a single record.
type UniqueRecord ¶ added in v0.5.1
type UniqueRecord[K Comparable[K], R PrimaryKeyHolder[K]] interface { PrimaryKeyHolder[K] }
UniqueRecord represents a data entry that is uniquely identifiable by its primary key.
type UpdateOption ¶ added in v0.18.0
type UpdateOption func(*UpdateOptions)
UpdateOption is a function that modifies UpdateOption
func WithUpdater ¶ added in v0.18.0
func WithUpdater(updater MetadataUpdaterF) UpdateOption
WithUpdater sets a custom metadata updater for update operations.
type UpdateOptions ¶ added in v0.18.0
type UpdateOptions struct {
Updater MetadataUpdaterF
}
UpdateOptions holds configuration for update operations
Source Files
¶
- address_ref.go
- address_ref_key.go
- api_v1.go
- api_v2.go
- chain_metadata.go
- chain_metadata_key.go
- clone.go
- contract_metadata.go
- contract_metadata_key.go
- env_metadata.go
- filters.go
- label_set.go
- memory_address_ref_store.go
- memory_chain_metadata_store.go
- memory_contract_metadata_store.go
- memory_datastore.go
- memory_env_metadata_store.go
- test_helpers.go
- transform.go