wire

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package wire is a store helper package that handles "wire" representations of the objects being managed in the store - e.g. marshalling and unmarshalling data from protocol buffers or json data and performing common operations across multiple data types that would otherwise require a switch statement and type checking.

Index

Constants

View Source
const (
	NamespaceVASPs         = "vasps"
	NamespaceCerts         = "certs"
	NamespaceCertReqs      = "certreqs"
	NamespaceReplicas      = "peers"
	NamespaceIndices       = "index"
	NamespaceSequence      = "sequence"
	NamespaceAnnouncements = "announcements"
	NamespaceActivities    = "activities"
	NamespaceOrganizations = "organizations"
	NamespaceContacts      = "contacts"
)

Namespace constants for all managed objects in GDS

Variables

View Source
var (
	ErrCannotReplicate = errors.New("object in namespace cannot be replicated")
	ErrObjectNotFound  = errors.New("object not found in local store")
)

Namespaces defines all possible namespaces that GDS manages TODO: do we need to add the BFF namespaces here as well?

Functions

func DecodeKey

func DecodeKey(keys string, b64decode bool) (key []byte, err error)

DecodeKey returns the byte representation of the key, base64 decoding if necessary.

func EncodeKey

func EncodeKey(key []byte, b64encode bool) string

EncodeKey returns the string representation of the key, base64 encoding if necessary.

func RemarshalJSON

func RemarshalJSON(namespace string, in []byte) (out []byte, err error)

RemarshalJSON is an odd utility, it takes raw JSON data and converts it to the appropriate type for database storage, e.g. marshaled protocol buffers or compressed json for an index. This is primarily used to take JSON data from disk and put it into a form that UnmarshalProto or UnmarshalIndex can use.

func Rewire

func Rewire(m protoreflect.ProtoMessage) (out map[string]interface{}, err error)

Rewire a protocol buffer message into a generic map[string]interface{} as an intermediate step before JSON or YAML marshalling. This is typically unnecessary work and is used as a workaround for multi-protocol systems. This method is primarily being used by the Admin API to convert protocol buffer messages into JSON generics for serialization by Gin.

func UnmarshalIndex

func UnmarshalIndex(data []byte) (index map[string]interface{}, err error)

UnmarshalIndex extracts a map[string]interface{} from the gzip compressed index.

func UnmarshalProto

func UnmarshalProto(namespace string, data []byte) (_ proto.Message, err error)

UnmarshalProto expects protocol buffer data and unmarshals it to the correct type based on the namespace. This is a utility function for dealing with the various namespaces and types that GDS manages and is not a substitute for direct unmarshalling.

func UnmarshalSequence

func UnmarshalSequence(data []byte) (seq uint64, err error)

UnmarshalSequence extracts a uint64 from the binary data

func Unwire

func Unwire(entry map[string]interface{}, msg protoreflect.ProtoMessage) (err error)

Unwire a generic map[string]interface{} into a protocol buffer message as an intermediate step to parsing a JSON or YAML request instead of protocol buffers. Like Rewire, this is a workaround for multi-protocol systems. This method is primarily being used by the Admin API to convert JSON generics unmarshaled by Gin into protocol buffers for interacting with the data store.

Types

This section is empty.

Jump to

Keyboard shortcuts

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