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
- Variables
- func DecodeKey(keys string, b64decode bool) (key []byte, err error)
- func EncodeKey(key []byte, b64encode bool) string
- func RemarshalJSON(namespace string, in []byte) (out []byte, err error)
- func Rewire(m protoreflect.ProtoMessage) (out map[string]interface{}, err error)
- func UnmarshalIndex(data []byte) (index map[string]interface{}, err error)
- func UnmarshalProto(namespace string, data []byte) (_ proto.Message, err error)
- func UnmarshalSequence(data []byte) (seq uint64, err error)
- func Unwire(entry map[string]interface{}, msg protoreflect.ProtoMessage) (err error)
Constants ¶
const ( NamespaceVASPs = "vasps" NamespaceCerts = "certs" NamespaceCertReqs = "certreqs" NamespaceReplicas = "peers" NamespaceIndices = "index" NamespaceSequence = "sequence" )
Namespace constants for all managed objects in GDS
Variables ¶
var ( ErrCannotReplicate = errors.New("object in namespace cannot be replicated") ErrObjectNotFound = errors.New("object not found in local store") )
var Namespaces = [3]string{NamespaceVASPs, NamespaceCertReqs, NamespaceReplicas}
Namespaces defines all possible namespaces that GDS manages
Functions ¶
func DecodeKey ¶
DecodeKey returns the byte representation of the key, base64 decoding if necessary.
func EncodeKey ¶
EncodeKey returns the string representation of the key, base64 encoding if necessary.
func RemarshalJSON ¶
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 ¶
UnmarshalIndex extracts a map[string]interface{} from the gzip compressed index.
func UnmarshalProto ¶
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 unmarshaling.
func UnmarshalSequence ¶
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.