protoconfig

package module
v0.0.0-...-665bf02 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const SupportPackageIsVersion1 = true

The SupportPackageIsVersion variables are referenced from generated protocol buffer files to ensure compatibility with the ProtoConfig version used. The latest support package version is 1.

Older versions are kept for compatibility. They may be removed if compatibility cannot be maintained.

These constants should not be referenced from any other code.

Variables

View Source
var (
	/// default represents an option that sets a default value for the field.
	//
	// optional string default = 5000;
	E_Default = &file_protoconfig_v1_extensions_proto_extTypes[1]
	/// hidden represents an option that marks a field as hidden. What it actually causes is up to the Configurable.
	/// ProtoConfig 1.0 recommends hiding it from the documentation.
	//
	// optional bool hidden = 5001;
	E_Hidden = &file_protoconfig_v1_extensions_proto_extTypes[2]
	/// required represents an option that marks a field as mandatory and if empty, Configurable does not accept the whole configuration.
	//
	// optional bool required = 5002;
	E_Required = &file_protoconfig_v1_extensions_proto_extTypes[3]
	/// experimental represents an option that marks a field as experimental. What it actually causes is up to the Configurable.
	/// ProtoConfig 1.0 recommends warning in the documentation.
	//
	// optional bool experimental = 5003;
	E_Experimental = &file_protoconfig_v1_extensions_proto_extTypes[4]
)

Extension fields to descriptor.FieldOptions.

View Source
var (
	/// metadata represents
	//
	// optional protoconfig.v1.Metadata metadata = 5000;
	E_Metadata = &file_protoconfig_v1_extensions_proto_extTypes[0]
)

Extension fields to descriptor.MessageOptions.

View Source
var File_protoconfig_v1_extensions_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Configurable

type Configurable interface {
	// Decode parses byte slice as `Encoded Configuration Message` in JSON or proto format and unmarshal it on
	// the Configurable struct. It supports all `Proto Config Extensions Format 1.0` extenstion
	// (validation, default values etc).
	// Use `proto.Unmarshal` or `protojson.Unmarshal` for decoding without `ProtoConfig 1.0` extension support.
	Decode(ecm []byte) error
	// DecodeString parses string `Encoded Configuration Message` in JSON or proto format and unmarshal it on
	// the Configurable struct. It supports all `Proto Config Extensions Format 1.0` extenstion
	// (validation, default values etc).
	// Use `proto.Unmarshal` or `protojson.Unmarshal` for decoding without `ProtoConfig 1.0` extension support.
	DecodeString(ecm string) error
}

type Configurator

type Configurator interface {
	// Encode encodes self as `Encoded Configuration Message` in proto format so it can be understood and
	// passed to Configurable struct. It supports all `Proto Config Extensions Format 1.0` extenstion
	// (validation, default values etc).
	// Use `proto.Marshal` encoding without `ProtoConfig 1.0` extension support.
	Encode() ([]byte, error)
	// EncodeJSON encodes self as `Encoded Configuration Message` in JSON format so it can be understood and
	// passed to Configurable struct. It supports all `Proto Config Extensions Format 1.0` extenstion
	// Use `protojson.Marshal` encoding without `ProtoConfig 1.0` extension support.
	EncodeJSON() ([]byte, error)

	// Metadata returns metadata defined in `Proto Config Extensions Format 1.0`.
	Metadata() Metadata
}

Configurator allows to produce `Encoded Configuration Messages` from the `Configuration Proto Definition`.

type FlagDelivery

type FlagDelivery struct {

	/// name represents custom flag name (including `-` if any) for a flag that consumes bytes of `Encoded Configuration Message`
	// ProtoConfig 1.0 recommends `--protoconfigv1` name.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*FlagDelivery) Descriptor deprecated

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

Deprecated: Use FlagDelivery.ProtoReflect.Descriptor instead.

func (*FlagDelivery) GetName

func (x *FlagDelivery) GetName() string

func (*FlagDelivery) ProtoMessage

func (*FlagDelivery) ProtoMessage()

func (*FlagDelivery) ProtoReflect

func (x *FlagDelivery) ProtoReflect() protoreflect.Message

func (*FlagDelivery) Reset

func (x *FlagDelivery) Reset()

func (*FlagDelivery) String

func (x *FlagDelivery) String() string

type Metadata

type Metadata struct {

	/// name represents name of annotated configuration entry point.
	/// It's recommended to use executable name here.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	/// version is the semantic version of the annotated configuration.
	Version     string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	/// delivery_mechanism optionally specifies the delivery that is implemented by configurable that consumes this
	/// configuration. This allows `Configurator` to discover how to pass the `Encoded Configuration Message`
	/// without extra information outside of definition.
	// TODO(bwplotka): This might be blocking reusability. Rethink?
	//
	// Types that are assignable to DeliveryMechanism:
	//	*Metadata_StdinDelivery
	//	*Metadata_FlagDelivery
	DeliveryMechanism isMetadata_DeliveryMechanism `protobuf_oneof:"delivery_mechanism"`
	// contains filtered or unexported fields
}

/ Metadata is an Message option that when put on message indicates an entry point for certain configuration. / One `Configuration Proto Definition` can have many structs marked as this option. / TODO(bwplotka): Make it non pointers (in Go).

func (*Metadata) Descriptor deprecated

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

Deprecated: Use Metadata.ProtoReflect.Descriptor instead.

func (*Metadata) GetDeliveryMechanism

func (m *Metadata) GetDeliveryMechanism() isMetadata_DeliveryMechanism

func (*Metadata) GetDescription

func (x *Metadata) GetDescription() string

func (*Metadata) GetFlagDelivery

func (x *Metadata) GetFlagDelivery() *FlagDelivery

func (*Metadata) GetName

func (x *Metadata) GetName() string

func (*Metadata) GetStdinDelivery

func (x *Metadata) GetStdinDelivery() *StdinDelivery

func (*Metadata) GetVersion

func (x *Metadata) GetVersion() string

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) ProtoReflect

func (x *Metadata) ProtoReflect() protoreflect.Message

func (*Metadata) Reset

func (x *Metadata) Reset()

func (*Metadata) String

func (x *Metadata) String() string

type Metadata_FlagDelivery

type Metadata_FlagDelivery struct {
	FlagDelivery *FlagDelivery `protobuf:"bytes,102,opt,name=flag_delivery,json=flagDelivery,proto3,oneof"`
}

type Metadata_StdinDelivery

type Metadata_StdinDelivery struct {
	StdinDelivery *StdinDelivery `protobuf:"bytes,101,opt,name=stdin_delivery,json=stdinDelivery,proto3,oneof"`
}

type StdinDelivery

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

func (*StdinDelivery) Descriptor deprecated

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

Deprecated: Use StdinDelivery.ProtoReflect.Descriptor instead.

func (*StdinDelivery) ProtoMessage

func (*StdinDelivery) ProtoMessage()

func (*StdinDelivery) ProtoReflect

func (x *StdinDelivery) ProtoReflect() protoreflect.Message

func (*StdinDelivery) Reset

func (x *StdinDelivery) Reset()

func (*StdinDelivery) String

func (x *StdinDelivery) String() string

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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