types

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package types is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	LegacyEventTypeStorage = "storage"

	LegacyAttributeKeyPath  = "path"
	LegacyAttributeKeyValue = "value"

	AttributeValueCategory = ModuleName
)

swingset module event types

View Source
const (
	EventTypeIbcPublish = "ibc_publish"

	AttributeKeyFriendly = "friendly"
	AttributeKeyKey      = "key"
	AttributeKeyValue    = "value"
)
View Source
const (
	// module name
	ModuleName = "vstorage"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName
)
View Source
const RouterKey = ModuleName

Variables

View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	EncodedKeySeparator = []byte{0}
	PathSeparator       = "."
	EncodedDataPrefix   = []byte{0}
	EncodedNoDataValue  = []byte{255}
)

- A "path" is a sequence of zero or more dot-separated nonempty strings of 7-bit non-nul, non-dot ASCII characters. So `""`, `"foo"`, and `"foo.bar.baz"` are paths but `"."`, "foo.", and "fo\0o" are not.

- An encoded key for a path is the path prefixed with its length (in ASCII digits), separated by nul, followed by the path with dots replaced with nul. So the path key for the empty path is `0\0`.

- Store entries exist if and only if self or some descendant has an entry with data.

- Store entries with data contain `\0`-prefixed data, (just `\0` if data is empty).

- Placeholder store entries contain a single `\255` byte. These are used to indicate that the entry does not have any data (which is different from empty data). Placeholder entries are used when a descendant with data exists, similar to empty non-terminals in the DNS (cf. https://www.rfc-editor.org/rfc/rfc8499.html#section-7 ).

View Source
var (
	ErrInvalidLengthQuery        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowQuery          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthVstorage        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowVstorage          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupVstorage = fmt.Errorf("proto: unexpected end of group")
)

Functions

func EncodedKeyToPath

func EncodedKeyToPath(key []byte) string

EncodedKeyToPath converts a byte slice key to a string path

func NewIbcPublishEvent

func NewIbcPublishEvent(storeKey, friendly string, key, value []byte) sdk.Event

func NewLegacyStorageEvent

func NewLegacyStorageEvent(path, value string) sdk.Event

NewLegacyStorageEvent constructs a new storage change sdk.Event nolint: interfacer

func PathToChildrenPrefix

func PathToChildrenPrefix(path string) []byte

PathToChildrenPrefix converts a path to a prefix for its children

func PathToEncodedKey

func PathToEncodedKey(path string) []byte

PathToEncodedKey converts a path to a byte slice key

func RegisterQueryHandler

func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterQueryHandler registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterQueryHandlerClient

func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error

RegisterQueryHandlerClient registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "QueryClient" to call the correct interceptors.

func RegisterQueryHandlerFromEndpoint

func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterQueryHandlerServer

func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error

RegisterQueryHandlerServer registers the http handlers for service Query to "mux". UnaryRPC :call QueryServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.

func RegisterQueryServer

func RegisterQueryServer(s grpc1.Server, srv QueryServer)

func ValidatePath

func ValidatePath(path string) error

Types

type Children

type Children struct {
	Children []string `protobuf:"bytes,1,rep,name=children,proto3" json:"children" yaml:"children"`
}

Children are the immediate names (just one level deep) of subnodes leading to more data from a given vstorage node.

func NewChildren

func NewChildren() *Children

func (*Children) Descriptor

func (*Children) Descriptor() ([]byte, []int)

func (*Children) GetChildren

func (m *Children) GetChildren() []string

func (*Children) Marshal

func (m *Children) Marshal() (dAtA []byte, err error)

func (*Children) MarshalTo

func (m *Children) MarshalTo(dAtA []byte) (int, error)

func (*Children) MarshalToSizedBuffer

func (m *Children) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Children) ProtoMessage

func (*Children) ProtoMessage()

func (*Children) Reset

func (m *Children) Reset()

func (*Children) Size

func (m *Children) Size() (n int)

func (*Children) String

func (m *Children) String() string

func (*Children) Unmarshal

func (m *Children) Unmarshal(dAtA []byte) error

func (*Children) XXX_DiscardUnknown

func (m *Children) XXX_DiscardUnknown()

func (*Children) XXX_Marshal

func (m *Children) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Children) XXX_Merge

func (m *Children) XXX_Merge(src proto.Message)

func (*Children) XXX_Size

func (m *Children) XXX_Size() int

func (*Children) XXX_Unmarshal

func (m *Children) XXX_Unmarshal(b []byte) error

type Data

type Data struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value" yaml:"value"`
}

Data is the vstorage node data.

func NewData

func NewData() *Data

func (*Data) Descriptor

func (*Data) Descriptor() ([]byte, []int)

func (*Data) GetValue

func (m *Data) GetValue() string

func (*Data) Marshal

func (m *Data) Marshal() (dAtA []byte, err error)

func (*Data) MarshalTo

func (m *Data) MarshalTo(dAtA []byte) (int, error)

func (*Data) MarshalToSizedBuffer

func (m *Data) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Data) ProtoMessage

func (*Data) ProtoMessage()

func (*Data) Reset

func (m *Data) Reset()

func (*Data) Size

func (m *Data) Size() (n int)

func (*Data) String

func (m *Data) String() string

func (*Data) Unmarshal

func (m *Data) Unmarshal(dAtA []byte) error

func (*Data) XXX_DiscardUnknown

func (m *Data) XXX_DiscardUnknown()

func (*Data) XXX_Marshal

func (m *Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Data) XXX_Merge

func (m *Data) XXX_Merge(src proto.Message)

func (*Data) XXX_Size

func (m *Data) XXX_Size() int

func (*Data) XXX_Unmarshal

func (m *Data) XXX_Unmarshal(b []byte) error

type DataEntry

type DataEntry struct {
	// A "."-separated path with individual path elements matching
	// `[-_A-Za-z0-9]+`
	Path  string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}

A vstorage entry. The only necessary entries are those with data, as the ancestor nodes are reconstructed on import.

func (*DataEntry) Descriptor

func (*DataEntry) Descriptor() ([]byte, []int)

func (*DataEntry) GetPath

func (m *DataEntry) GetPath() string

func (*DataEntry) GetValue

func (m *DataEntry) GetValue() string

func (*DataEntry) Marshal

func (m *DataEntry) Marshal() (dAtA []byte, err error)

func (*DataEntry) MarshalTo

func (m *DataEntry) MarshalTo(dAtA []byte) (int, error)

func (*DataEntry) MarshalToSizedBuffer

func (m *DataEntry) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*DataEntry) ProtoMessage

func (*DataEntry) ProtoMessage()

func (*DataEntry) Reset

func (m *DataEntry) Reset()

func (*DataEntry) Size

func (m *DataEntry) Size() (n int)

func (*DataEntry) String

func (m *DataEntry) String() string

func (*DataEntry) Unmarshal

func (m *DataEntry) Unmarshal(dAtA []byte) error

func (*DataEntry) XXX_DiscardUnknown

func (m *DataEntry) XXX_DiscardUnknown()

func (*DataEntry) XXX_Marshal

func (m *DataEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DataEntry) XXX_Merge

func (m *DataEntry) XXX_Merge(src proto.Message)

func (*DataEntry) XXX_Size

func (m *DataEntry) XXX_Size() int

func (*DataEntry) XXX_Unmarshal

func (m *DataEntry) XXX_Unmarshal(b []byte) error

type GenesisState

type GenesisState struct {
	Data []*DataEntry `protobuf:"bytes,1,rep,name=data,proto3" json:"data" yaml:"data"`
}

The initial or exported state.

func (*GenesisState) Descriptor

func (*GenesisState) Descriptor() ([]byte, []int)

func (*GenesisState) GetData

func (m *GenesisState) GetData() []*DataEntry

func (*GenesisState) Marshal

func (m *GenesisState) Marshal() (dAtA []byte, err error)

func (*GenesisState) MarshalTo

func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)

func (*GenesisState) MarshalToSizedBuffer

func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GenesisState) ProtoMessage

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset

func (m *GenesisState) Reset()

func (*GenesisState) Size

func (m *GenesisState) Size() (n int)

func (*GenesisState) String

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal

func (m *GenesisState) Unmarshal(dAtA []byte) error

func (*GenesisState) XXX_DiscardUnknown

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal

func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GenesisState) XXX_Merge

func (m *GenesisState) XXX_Merge(src proto.Message)

func (*GenesisState) XXX_Size

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal

func (m *GenesisState) XXX_Unmarshal(b []byte) error

type QueryChildrenRequest

type QueryChildrenRequest struct {
	Path       string             `protobuf:"bytes,1,opt,name=path,proto3" json:"path" yaml:"path"`
	Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

QueryChildrenRequest is the vstorage path children query.

func (*QueryChildrenRequest) Descriptor

func (*QueryChildrenRequest) Descriptor() ([]byte, []int)

func (*QueryChildrenRequest) GetPagination

func (m *QueryChildrenRequest) GetPagination() *query.PageRequest

func (*QueryChildrenRequest) GetPath

func (m *QueryChildrenRequest) GetPath() string

func (*QueryChildrenRequest) Marshal

func (m *QueryChildrenRequest) Marshal() (dAtA []byte, err error)

func (*QueryChildrenRequest) MarshalTo

func (m *QueryChildrenRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryChildrenRequest) MarshalToSizedBuffer

func (m *QueryChildrenRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryChildrenRequest) ProtoMessage

func (*QueryChildrenRequest) ProtoMessage()

func (*QueryChildrenRequest) Reset

func (m *QueryChildrenRequest) Reset()

func (*QueryChildrenRequest) Size

func (m *QueryChildrenRequest) Size() (n int)

func (*QueryChildrenRequest) String

func (m *QueryChildrenRequest) String() string

func (*QueryChildrenRequest) Unmarshal

func (m *QueryChildrenRequest) Unmarshal(dAtA []byte) error

func (*QueryChildrenRequest) XXX_DiscardUnknown

func (m *QueryChildrenRequest) XXX_DiscardUnknown()

func (*QueryChildrenRequest) XXX_Marshal

func (m *QueryChildrenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryChildrenRequest) XXX_Merge

func (m *QueryChildrenRequest) XXX_Merge(src proto.Message)

func (*QueryChildrenRequest) XXX_Size

func (m *QueryChildrenRequest) XXX_Size() int

func (*QueryChildrenRequest) XXX_Unmarshal

func (m *QueryChildrenRequest) XXX_Unmarshal(b []byte) error

type QueryChildrenResponse

type QueryChildrenResponse struct {
	Children   []string            `protobuf:"bytes,1,rep,name=children,proto3" json:"children" yaml:"children"`
	Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

QueryChildrenResponse is the vstorage path children response.

func (*QueryChildrenResponse) Descriptor

func (*QueryChildrenResponse) Descriptor() ([]byte, []int)

func (*QueryChildrenResponse) GetChildren

func (m *QueryChildrenResponse) GetChildren() []string

func (*QueryChildrenResponse) GetPagination

func (m *QueryChildrenResponse) GetPagination() *query.PageResponse

func (*QueryChildrenResponse) Marshal

func (m *QueryChildrenResponse) Marshal() (dAtA []byte, err error)

func (*QueryChildrenResponse) MarshalTo

func (m *QueryChildrenResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryChildrenResponse) MarshalToSizedBuffer

func (m *QueryChildrenResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryChildrenResponse) ProtoMessage

func (*QueryChildrenResponse) ProtoMessage()

func (*QueryChildrenResponse) Reset

func (m *QueryChildrenResponse) Reset()

func (*QueryChildrenResponse) Size

func (m *QueryChildrenResponse) Size() (n int)

func (*QueryChildrenResponse) String

func (m *QueryChildrenResponse) String() string

func (*QueryChildrenResponse) Unmarshal

func (m *QueryChildrenResponse) Unmarshal(dAtA []byte) error

func (*QueryChildrenResponse) XXX_DiscardUnknown

func (m *QueryChildrenResponse) XXX_DiscardUnknown()

func (*QueryChildrenResponse) XXX_Marshal

func (m *QueryChildrenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryChildrenResponse) XXX_Merge

func (m *QueryChildrenResponse) XXX_Merge(src proto.Message)

func (*QueryChildrenResponse) XXX_Size

func (m *QueryChildrenResponse) XXX_Size() int

func (*QueryChildrenResponse) XXX_Unmarshal

func (m *QueryChildrenResponse) XXX_Unmarshal(b []byte) error

type QueryClient

type QueryClient interface {
	// Return an arbitrary vstorage datum.
	Data(ctx context.Context, in *QueryDataRequest, opts ...grpc.CallOption) (*QueryDataResponse, error)
	// Return the children of a given vstorage path.
	Children(ctx context.Context, in *QueryChildrenRequest, opts ...grpc.CallOption) (*QueryChildrenResponse, error)
}

QueryClient is the client API for Query service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewQueryClient

func NewQueryClient(cc grpc1.ClientConn) QueryClient

type QueryDataRequest

type QueryDataRequest struct {
	Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path" yaml:"path"`
}

QueryDataRequest is the vstorage path data query.

func (*QueryDataRequest) Descriptor

func (*QueryDataRequest) Descriptor() ([]byte, []int)

func (*QueryDataRequest) GetPath

func (m *QueryDataRequest) GetPath() string

func (*QueryDataRequest) Marshal

func (m *QueryDataRequest) Marshal() (dAtA []byte, err error)

func (*QueryDataRequest) MarshalTo

func (m *QueryDataRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryDataRequest) MarshalToSizedBuffer

func (m *QueryDataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryDataRequest) ProtoMessage

func (*QueryDataRequest) ProtoMessage()

func (*QueryDataRequest) Reset

func (m *QueryDataRequest) Reset()

func (*QueryDataRequest) Size

func (m *QueryDataRequest) Size() (n int)

func (*QueryDataRequest) String

func (m *QueryDataRequest) String() string

func (*QueryDataRequest) Unmarshal

func (m *QueryDataRequest) Unmarshal(dAtA []byte) error

func (*QueryDataRequest) XXX_DiscardUnknown

func (m *QueryDataRequest) XXX_DiscardUnknown()

func (*QueryDataRequest) XXX_Marshal

func (m *QueryDataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryDataRequest) XXX_Merge

func (m *QueryDataRequest) XXX_Merge(src proto.Message)

func (*QueryDataRequest) XXX_Size

func (m *QueryDataRequest) XXX_Size() int

func (*QueryDataRequest) XXX_Unmarshal

func (m *QueryDataRequest) XXX_Unmarshal(b []byte) error

type QueryDataResponse

type QueryDataResponse struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value" yaml:"value"`
}

QueryDataResponse is the vstorage path data response.

func (*QueryDataResponse) Descriptor

func (*QueryDataResponse) Descriptor() ([]byte, []int)

func (*QueryDataResponse) GetValue

func (m *QueryDataResponse) GetValue() string

func (*QueryDataResponse) Marshal

func (m *QueryDataResponse) Marshal() (dAtA []byte, err error)

func (*QueryDataResponse) MarshalTo

func (m *QueryDataResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryDataResponse) MarshalToSizedBuffer

func (m *QueryDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryDataResponse) ProtoMessage

func (*QueryDataResponse) ProtoMessage()

func (*QueryDataResponse) Reset

func (m *QueryDataResponse) Reset()

func (*QueryDataResponse) Size

func (m *QueryDataResponse) Size() (n int)

func (*QueryDataResponse) String

func (m *QueryDataResponse) String() string

func (*QueryDataResponse) Unmarshal

func (m *QueryDataResponse) Unmarshal(dAtA []byte) error

func (*QueryDataResponse) XXX_DiscardUnknown

func (m *QueryDataResponse) XXX_DiscardUnknown()

func (*QueryDataResponse) XXX_Marshal

func (m *QueryDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryDataResponse) XXX_Merge

func (m *QueryDataResponse) XXX_Merge(src proto.Message)

func (*QueryDataResponse) XXX_Size

func (m *QueryDataResponse) XXX_Size() int

func (*QueryDataResponse) XXX_Unmarshal

func (m *QueryDataResponse) XXX_Unmarshal(b []byte) error

type QueryServer

type QueryServer interface {
	// Return an arbitrary vstorage datum.
	Data(context.Context, *QueryDataRequest) (*QueryDataResponse, error)
	// Return the children of a given vstorage path.
	Children(context.Context, *QueryChildrenRequest) (*QueryChildrenResponse, error)
}

QueryServer is the server API for Query service.

type StorageEntry added in v0.34.0

type StorageEntry struct {
	// contains filtered or unexported fields
}

func NewStorageEntry added in v0.34.0

func NewStorageEntry(path string, value string) StorageEntry

func NewStorageEntryWithNoData added in v0.34.0

func NewStorageEntryWithNoData(path string) StorageEntry

func UnmarshalStorageEntry added in v0.34.0

func UnmarshalStorageEntry(msg json.RawMessage) (entry StorageEntry, err error)

UnmarshalStorageEntry interprets its argument as a [key: string, value?: string | null] JSON array and returns a corresponding StorageEntry. The key must be a string, and the value (if present) must be a string or null.

func (StorageEntry) HasData added in v0.34.0

func (se StorageEntry) HasData() bool

func (StorageEntry) Path added in v0.34.0

func (se StorageEntry) Path() string

func (StorageEntry) StringValue added in v0.34.0

func (se StorageEntry) StringValue() string

func (StorageEntry) Value added in v0.34.0

func (se StorageEntry) Value() *string

type UnimplementedQueryServer

type UnimplementedQueryServer struct {
}

UnimplementedQueryServer can be embedded to have forward compatible implementations.

func (*UnimplementedQueryServer) Children

func (*UnimplementedQueryServer) Data

Jump to

Keyboard shortcuts

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