Documentation ¶
Overview ¶
Package nameindexer provides utilities for creating, decoding, storing, and searching indexable names.
Index ¶
- Constants
- func CloudEventToIndexKey(cloudHdr *cloudevent.CloudEventHeader) string
- func CloudTypeToFiller(eventTypes string) string
- func DecodeAddress(encodedAddress string) (common.Address, error)
- func DecodeDataType(dataType string) string
- func DecodeDateAndTime(datePart string, timePart string) (time.Time, error)
- func DecodeNFTDIDIndex(indexNFTDID string) (cloudevent.NFTDID, error)
- func DecodePrimaryFiller(primaryFiller string) string
- func DecodeProducer(producer string) string
- func DecodeSecondaryFiller(secondaryFiller string) string
- func DecodeSource(source string) string
- func DecodeSubject(subject string) string
- func EncodeAddress(address common.Address) string
- func EncodeDataType(dataType string) string
- func EncodeDate(date time.Time) (string, error)
- func EncodeIndex(origIndex *Index) (string, error)
- func EncodeNFTDID(did cloudevent.NFTDID) string
- func EncodePrimaryFiller(primaryFiller string) string
- func EncodeProducer(producer string) string
- func EncodeSecondaryFiller(secondaryFiller string) string
- func EncodeSource(source string) string
- func EncodeSubject(subject string) string
- func EncodeTime(ts time.Time) string
- func FillerToCloudType(filler string) string
- func ValidateDate(date time.Time) error
- type Index
- type InvalidError
Constants ¶
const ( // FillerStatus is the filler value for status type cloud events. FillerStatus = "A" // FillerFingerprint is the filler value for fingerprint type cloud events. FillerFingerprint = "E" // FillerVerifiableCredential is the filler value for verifiable credential type cloud events. FillerVerifiableCredential = "V" // FillerUnknown is the filler value for unknown type cloud events. FillerUnknown = "U" )
const ( // DateLength is the length of the date part of an index string. DateLength = 6 // FillerLength is the length of the filler parts of an index string. FillerLength = 2 // DataTypeLength is the length of the data type part of an index string. DataTypeLength = 20 // DIDLength is the length of the DID part of an index string. DIDLength = 64 // TimeLength is the length of the time part of an index string. TimeLength = 6 // AddressLength is the length of an ethereum address part of an index string. AddressLength = 40 // TotalLength is the total length of an index string. TotalLength = DIDLength + DateLength + FillerLength + DataTypeLength + TimeLength + AddressLength + DIDLength + FillerLength // DateMax is the maximum value used for date calculations in the index. DateMax = 999999 // HhmmssFormat is the time format used in the index string. HhmmssFormat = "150405" // DefaultPrimaryFiller is the default filler value between the date and data type. DefaultPrimaryFiller = "MM" // DefaultSecondaryFiller is the default filler value between the subject and time. DefaultSecondaryFiller = "00" DataTypePadding = "!" )
Variables ¶
This section is empty.
Functions ¶
func CloudEventToIndexKey ¶ added in v0.1.0
func CloudEventToIndexKey(cloudHdr *cloudevent.CloudEventHeader) string
CloudEventToIndex converts a CloudEventHeader to a Index.
func CloudTypeToFiller ¶ added in v0.0.8
CloudTypeToFiller converts a cloud event type to a filler string.
func DecodeAddress ¶ added in v0.0.8
DecodeAddress decodes an ethereum address from a string without the 0x prefix.
func DecodeDataType ¶ added in v0.0.8
DecodeDataType decodes a data type string by removing padding.
func DecodeDateAndTime ¶ added in v0.0.8
func DecodeNFTDIDIndex ¶ added in v0.0.8
func DecodeNFTDIDIndex(indexNFTDID string) (cloudevent.NFTDID, error)
DecodeNFTDIDIndex decodes an NFTDID string into a cloudevent.NFTDID struct.
func DecodePrimaryFiller ¶ added in v0.0.8
DecodePrimaryFiller decodes a primary filler string by removing padding.
func DecodeProducer ¶ added in v0.0.8
DecodeProducer decodes a producer string by removing padding.
func DecodeSecondaryFiller ¶ added in v0.0.8
DecodeSecondaryFiller decodes a secondary filler string by removing padding.
func DecodeSource ¶ added in v0.0.8
DecodeSource decodes a source string by removing padding
func DecodeSubject ¶
DecodeSubject decodes a subject string by removing padding.
func EncodeAddress ¶ added in v0.0.8
EncodeAddress encodes an ethereum address without the 0x prefix.
func EncodeDataType ¶ added in v0.0.8
EncodeDataType pads the data type with `*` if shorter than required. It truncates the data type if longer than required.
func EncodeDate ¶ added in v0.0.8
EncodeDate encodes a time.Time into a string.
func EncodeIndex ¶
EncodeIndex creates an indexable name string from the Index struct. This function will modify the index to have correctly padded values. The index string format is:
subject + date + time + primaryFiller + source + dataType + secondaryFiller + producer + optional
where:
- subject is the NFTDID of the data's subject -- chainId + contractAddress + tokenID -- chainId is a 16-character hexadecimal string representing the uint64 chain ID -- contractAddress is a 40-character hexadecimal string representing the contract address -- tokenID is an 8-character hexadecimal string representing the uint32 token ID
- date is calculated as 999999 - (<two-digit-year>*10000 + <two-digit-month>*100 + <two-digit-day>)
- time is the time in UTC in the format HHMMSS
- primaryFiller is a constant string of length 2
- source is a 40-character hexadecimal string representing the source address
- dataType is the data type left-padded with `!` or truncated to 20 characters
- secondaryFiller is a constant string of length 2
- producer is the NFTDID of the data's producer -- chainId + contractAddress + tokenID -- chainId is a 16-character hexadecimal string representing the uint64 chain ID -- contractAddress is a 40-character hexadecimal string representing the contract address -- tokenID is an 8-character hexadecimal string representing the uint32 token ID
- optional is an optional string that can be appended to the index
func EncodeNFTDID ¶ added in v0.0.8
func EncodeNFTDID(did cloudevent.NFTDID) string
EncodeNFTDID encodes an NFTDID struct into an indexable string. This format is different from the standard NFTDID.
func EncodePrimaryFiller ¶ added in v0.0.8
EncodePrimaryFiller pads the primary filler with `M` if shorter than required. It truncates the primary filler if longer than required.
func EncodeProducer ¶ added in v0.0.8
EncodeProducer pads the producer with `!` if shorter than required. It truncates the producer if longer than required.
func EncodeSecondaryFiller ¶ added in v0.0.8
EncodeSecondaryFiller pads the secondary filler with `0` if shorter than required. It truncates the secondary filler if longer than required.
func EncodeSource ¶ added in v0.0.8
EncodeSource pads the source with `!` if shorter than required. It truncates the source if longer than required.
func EncodeSubject ¶ added in v0.0.8
EncodeSubject pads the subject with `!` if shorter than required. It truncates the subject if longer than required.
func EncodeTime ¶ added in v0.0.8
EncodeTime encodes a time.Time into a string.
func FillerToCloudType ¶ added in v0.0.8
FillerToCloudType converts a filler string to a cloud event type.
func ValidateDate ¶ added in v0.0.8
ValidateDate validates the year of a timestamp is between 2000 and 2099.
Types ¶
type Index ¶
type Index struct { // Subject is the subject of the data represented by the index. Subject string // Timestamp is the full timestamp used for date and time. Timestamp time.Time // PrimaryFiller is the filler value between the date and data type, typically "MM". If empty, defaults to "MM". PrimaryFiller string // DataType is the type of data, left-padded with @ or truncated to 20 characters. DataType string // Source is the source of the data represented by the index. Source string `json:"source"` // Producer is the producer of the data represented by the index. Producer string `json:"producer"` // SecondaryFiller is the filler value between the subject and time, typically "00". If empty, defaults to "00". SecondaryFiller string // Optional data for additional metadata Optional string `json:"optional"` }
Index represents the components of a decoded index.
func DecodeIndex ¶
DecodeIndex decodes an index string into its constituent parts. It returns an Index struct containing the decoded components. The index string format is expected to be:
subject + date + time + primaryFiller + source + dataType + secondaryFiller + producer + optional
where:
- subject is the NFTDID of the data's subject -- chainId + contractAddress + tokenID -- chainId is a 16-character hexadecimal string representing the uint64 chain ID -- contractAddress is a 40-character hexadecimal string representing the contract address -- tokenID is an 8-character hexadecimal string representing the uint32 token ID
- date is calculated as 999999 - (<two-digit-year>*10000 + <two-digit-month>*100 + <two-digit-day>)
- time is the time in UTC in the format HHMMSS
- primaryFiller is a constant string of length 2
- source is a 40-character hexadecimal string representing the source address
- dataType is the data type left-padded with `!` or truncated to 20 characters
- secondaryFiller is a constant string of length 2
- producer is the NFTDID of the data's producer -- chainId + contractAddress + tokenID -- chainId is a 16-character hexadecimal string representing the uint64 chain ID -- contractAddress is a 40-character hexadecimal string representing the contract address -- tokenID is an 8-character hexadecimal string representing the uint32 token ID
- optional is an optional string that can be appended to the index
func (Index) WithEncodedParts ¶ added in v0.0.8
type InvalidError ¶
type InvalidError string
InvalidError represents an error type for invalid arguments.
func (InvalidError) Error ¶
func (e InvalidError) Error() string
Error implements the error interface for InvalidError.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
pkg
|
|
clickhouse/indexrepo
Package indexrepo contains service code for gettting and managing indexed objects.
|
Package indexrepo contains service code for gettting and managing indexed objects. |
clickhouse/migrations
Code generated by "clickhouse-infra" DO NOT EDIT.
|
Code generated by "clickhouse-infra" DO NOT EDIT. |