protoexpr

package
v0.0.0-...-f84996e Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Overview

Package protoexpr allows for a proto message, and its fields, to be declared as an Ident for an API filter string (https://google.aip.dev/160).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Declare

Declare iterates through all fields of a supplied protobuf Message to create Ident Declarations. This will produce Ident Declarations for the protobuf Message itself, as well as an overload for the `Has` function to check for field presence.

Each field will have an Ident produced with an appropriate expr.Type. All enums declared within the message will have their values declared as constants. All fields of message type will processed recursively, with their Indent name set to the relative path from the root message. google.protobuf.Timestamp and google.protobuf.Duration are well known types, and will return an appropriate WellKnown type rather than a Message type.

Types

type Client

type Client[T proto.Message] interface {
	Transpile(ctx context.Context, factory func() T, parent, collection, pageToken string, pageSize int32, filter *expr.CheckedExpr) (children []T, nextPageToken string, err error)
}

Client provides a concrete implementation of the Transpiler for a specific storage client.

type ListRequest

type ListRequest interface {
	proto.Message
	GetParent() string
	GetPageSize() int32
	GetPageToken() string
	GetFilter() string
}

ListRequest is an AIP-132 & AIP-160 compliant List Request.

type Transpiler

type Transpiler[T proto.Message] interface {
	Transpile(context.Context, ListRequest) (children []T, nextPageToken string, err error)
}

Transpiler is the service facing interface that should be used to filter an incoming request.

func New

func New[T proto.Message](client Client[T], mtd protoreflect.MethodDescriptor, msg T) (Transpiler[T], error)

New creates a new transpiler for requests to the specified List method. This should be used by the concrete Transpiler implementation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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