encoding

package
v30.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRequestMessage

func BuildRequestMessage(desc *MethodDescriptor, fields map[string]string) (protoiface.MessageV1, error)

BuildRequestMessage instantiates and populates the protobuf request expected by the target gRPC method using the provided field map.

func CamelToSnake

func CamelToSnake(input string) string

CamelToSnake converts CamelCase identifiers to snake_case.

func ExtractParams

func ExtractParams(desc *MethodDescriptor, msg protoreflect.Message) (map[string]string, error)

ExtractParams collects scalar request field values present on the provided message.

func NewMessageByName

func NewMessageByName(typeName string) (protoiface.MessageV1, error)

NewMessageByName returns an empty protobuf message for the provided type name.

func SnakeToCamel

func SnakeToCamel(input string) string

SnakeToCamel converts snake_case identifiers to CamelCase.

Types

type DynamicRegistry

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

DynamicRegistry inspects the application's gRPC query router and reflection registry to discover the full set of query methods that are available at runtime. It offers lightweight search helpers that caller code can use to experiment with building stream definitions on the fly.

func NewDynamicRegistry

func NewDynamicRegistry(app *baseapp.BaseApp) (*DynamicRegistry, error)

NewDynamicRegistry constructs a dynamic registry for the provided BaseApp. It immediately scans all registered gRPC services and keeps the discovered metadata in memory

func NewFilesRegistry

func NewFilesRegistry(files *protoregistry.Files) (*DynamicRegistry, error)

NewFilesRegistry builds a dynamic registry using the provided file set. This constructor does not require access to the application's router and therefore does not filter methods by handler availability.

func (*DynamicRegistry) List

func (r *DynamicRegistry) List() []*MethodDescriptor

List returns all discovered methods sorted lexicographically by their full gRPC method path.

func (*DynamicRegistry) LookupByFullMethod

func (r *DynamicRegistry) LookupByFullMethod(fullMethod string) (*MethodDescriptor, bool)

LookupByFullMethod returns the descriptor for the provided gRPC method path.

func (*DynamicRegistry) LookupByModuleAndStream

func (r *DynamicRegistry) LookupByModuleAndStream(module, stream string) (*MethodDescriptor, bool)

LookupByModuleAndStream attempts to resolve a method descriptor using the provided module and stream identifiers. Both lookups are case-insensitive.

func (*DynamicRegistry) LookupByRequest

func (r *DynamicRegistry) LookupByRequest(requestType string) (*MethodDescriptor, bool)

LookupByRequest returns the descriptor associated with the given request type if a handler exists.

func (*DynamicRegistry) Refresh

func (r *DynamicRegistry) Refresh(app *baseapp.BaseApp) error

Refresh rescans the router using the supplied app. It replaces the cached metadata atomically so callers can safely share a registry across updates.

func (*DynamicRegistry) Search

func (r *DynamicRegistry) Search(term string) []*MethodDescriptor

Search performs a case-insensitive substring search across the method path, service namespace, request type and response type. It returns the matching descriptors in lexical order.

type FieldDescriptor

type FieldDescriptor struct {
	Name        string
	JSONName    string
	Kind        string
	Cardinality string
	TypeName    string
}

FieldDescriptor models a single request field in a discovered RPC method

type MethodDescriptor

type MethodDescriptor struct {
	// FullMethod is the canonical gRPC method path (/package.Service/Method)
	FullMethod string
	// Method is the RPC name (e.g. Balance)
	Method string
	// Module is the short module identifier derived from the service namespace (e.g. bank).
	Module string
	// Version is best-effort metadata extracted from the service namespace
	// (e.g. v1beta1). It may be empty if no obvious version segment exists
	Version string
	// RequestType is the fully-qualified name of the request message
	RequestType string
	// ResponseType is the fully-qualified name of the response message
	ResponseType string
	// RequestFields enumerates the request message fields in declaration order
	RequestFields []FieldDescriptor
	// StreamName is the canonical name used by client APIs (typically snake_case)
	StreamName string
}

MethodDescriptor captures the key metadata required to reason about a discovered gRPC query. It intentionally avoids any stream-specific behaviour so higher layers can decide how to turn methods into subscription definitions.

type StreamEvent

type StreamEvent struct {
	Module string
	Method string
	Params map[string]string
}

StreamEvent represents a state change emitted by the dispatcher. It contains the module, method and parameters that identify the subscription that produced the event.

func (StreamEvent) String

func (e StreamEvent) String() string

String returns a canonical string representation suitable for map keys.

Jump to

Keyboard shortcuts

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