Documentation ¶
Overview ¶
Package proto contains protobuf-related utilities.
Index ¶
- Variables
- func FixFieldMasks(jsonMessage []byte, messageType reflect.Type) ([]byte, error)
- func PageQuery(c context.Context, lim int32, tok string, rsp PagedResponse, ...) error
- func ParseMultilineStrings(text string) (string, error)
- func UnmarshalTextML(s string, pb proto.Message) error
- type Metadata
- func (*Metadata) Descriptor() ([]byte, []int)
- func (m *Metadata) GetDocUrl() string
- func (*Metadata) ProtoMessage()
- func (m *Metadata) Reset()
- func (m *Metadata) String() string
- func (m *Metadata) XXX_DiscardUnknown()
- func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Metadata) XXX_Merge(src proto.Message)
- func (m *Metadata) XXX_Size() int
- func (m *Metadata) XXX_Unmarshal(b []byte) error
- type PagedResponse
Constants ¶
This section is empty.
Variables ¶
var E_FileMetadata = &proto.ExtensionDesc{ ExtendedType: (*descriptor.FileOptions)(nil), ExtensionType: (*Metadata)(nil), Field: 73700, Name: "luci.file_metadata", Tag: "bytes,73700,opt,name=file_metadata", Filename: "go.chromium.org/luci/common/proto/options.proto", }
Functions ¶
func FixFieldMasks ¶
FixFieldMasks reads FieldMask fields from a JSON-encoded message, parses them as a string according to https://github.com/protocolbuffers/protobuf/blob/ec1a70913e5793a7d0a7b5fbf7e0e4f75409dd41/src/google/protobuf/field_mask.proto#L180 and converts them to a JSON object that Golang Protobuf library understands. It is a workaround for https://github.com/golang/protobuf/issues/745.
messageType must be a struct, not a struct pointer.
func PageQuery ¶
func PageQuery(c context.Context, lim int32, tok string, rsp PagedResponse, q *datastore.Query, cb interface{}) error
PageQuery executes a query to fetch the given page of results, invoking a callback function for each key or entity returned by the query. If the page isn't the last of the query, the given response will have its next page token set appropriately.
A non-positive limit means to fetch all results starting at the given page token in a single page. An empty page token means to start at the first page.
The callback must be a function of one argument, the type of which is either *datastore.Key (implies keys-only query) or a pointer to a struct to decode the returned entity into. The callback should return an error, which if not nil halts the query, and if the error is not datastore.Stop, causes this function to return an error as well. See datastore.Run for more information. No maximum page size is imposed, use datastore.Stop to enforce one.
func ParseMultilineStrings ¶
ParseMultilineStrings looks for bash-style heredocs and replaces them with single-line text-proto-escaped strings.
This looks line by line for /<<\s*([_a-zA-Z]+)\s*$/. If this is found, the scanner then looks until it finds /^\s*\1\s*$/. Every line between these is joined like "\n".join(lines), and then printed back as an escaped proto string. The scanner then loops back to its initial state.
Not that nothing special needs to be done for e.g.
some_key: "string with << angles"
Such a line would be left alone, because the trailing quote (which is mandatory in text proto) cause the starting regex to not match.
For convenience, the inner lines will be treated with the equivalent of python's `textwrap.dedent`; any common leading whitespace that occurs on every line will be removed. Although both tabs and spaces count as whitespace, they are not equivalent (i.e. only exactly-matching whitespace prefixes count)
The only error this may return is if there's an open heredoc without a matching close marker.
Example:
this: <<EOF would turn \ninto a "single" line EOF
Turns into the same as:
this: "would\nturn \\ninto\n a \"single\"\nline"
Types ¶
type Metadata ¶
type Metadata struct { // URL to a human-readable proto schema definition doc. DocUrl *string `protobuf:"bytes,1,opt,name=doc_url,json=docUrl" json:"doc_url,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Metadata) Descriptor ¶
func (*Metadata) ProtoMessage ¶
func (*Metadata) ProtoMessage()
func (*Metadata) XXX_DiscardUnknown ¶
func (m *Metadata) XXX_DiscardUnknown()
func (*Metadata) XXX_Marshal ¶
func (*Metadata) XXX_Unmarshal ¶
type PagedResponse ¶
type PagedResponse interface { proto.Message // GetNextPageToken returns a token to use to fetch the next page of results. GetNextPageToken() string }
PagedResponse is an interface implemented by ListResponses which support page tokens.
Directories ¶
Path | Synopsis |
---|---|
Package access contains Access service protocol.
|
Package access contains Access service protocol. |
Package config contains luci-config protobuf definitions.
|
Package config contains luci-config protobuf definitions. |
Package examples shows how to design protos which adhere to the Google Cloud API design guide.
|
Package examples shows how to design protos which adhere to the Google Cloud API design guide. |
Package gerrit contains Gerrit service definition.
|
Package gerrit contains Gerrit service definition. |
Package git contains Git-related protobuf definitions.
|
Package git contains Git-related protobuf definitions. |
Package gitiles contains Gitiles service definition.
|
Package gitiles contains Gitiles service definition. |
Package google contains utility methods to help interface between Google standard protobufs and native Go types.
|
Package google contains utility methods to help interface between Google standard protobufs and native Go types. |
descutil
Package descutil contains utility functions for protobuf descriptor messages.
|
Package descutil contains utility functions for protobuf descriptor messages. |
internal
|
|
Package milo contains Milo protobuf definitions.
|
Package milo contains Milo protobuf definitions. |
Package srcman contains source manifest protobuf definitions.
|
Package srcman contains source manifest protobuf definitions. |