config

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: Apache-2.0 Imports: 18 Imported by: 12

README

Compiling the proto file is done out of band, it is not done automatically. See https://github.com/google/knative-gcp/issues/2017.

  1. Download and install a release.
  2. From the root of the repo, run:
    protoc pkg/broker/config/targets.proto --go_out=$GOPATH/src
    

Note that I had also initially run:

  • go get -u github.com/golang/protobuf/protoc-gen-go
  • go install github.com/golang/protobuf/protoc-gen-go

But as far as I am aware, they did not affect anything. Only noted here in case it actually did make a difference and are required steps. If so, please update these instructions to say so.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	State_name = map[int32]string{
		0: "UNKNOWN",
		1: "READY",
	}
	State_value = map[string]int32{
		"UNKNOWN": 0,
		"READY":   1,
	}
)

Enum value maps for State.

View Source
var (
	CellTenantType_name = map[int32]string{
		0: "UNKNOWN_CELL_TENANT_TYPE",
		1: "BROKER",
		2: "CHANNEL",
	}
	CellTenantType_value = map[string]int32{
		"UNKNOWN_CELL_TENANT_TYPE": 0,
		"BROKER":                   1,
		"CHANNEL":                  2,
	}
)

Enum value maps for CellTenantType.

View Source
var File_pkg_broker_config_targets_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type CachedTargets

type CachedTargets struct {
	Value atomic.Value
}

CachedTargets provides a in-memory cached copy of targets.

func (*CachedTargets) Bytes

func (ct *CachedTargets) Bytes() ([]byte, error)

Bytes serializes all the targets.

func (*CachedTargets) DebugString added in v0.20.0

func (ct *CachedTargets) DebugString() string

DebugString returns the text format of all the targets. It is for _debug_ purposes only. The output format is not guaranteed to be stable and may change at any time.

func (*CachedTargets) GetCellTenantByKey added in v0.21.0

func (ct *CachedTargets) GetCellTenantByKey(key *CellTenantKey) (*CellTenant, bool)

GetBrokerByKey returns a broker and its targets if it exists. Do not modify the returned Broker copy.

func (*CachedTargets) GetTargetByKey added in v0.15.0

func (ct *CachedTargets) GetTargetByKey(key *TargetKey) (*Target, bool)

GetTargetByKey returns a target by its trigger key. The format of trigger key is namespace/brokerName/targetName. Do not modify the returned Target copy.

func (*CachedTargets) Load

func (ct *CachedTargets) Load() *TargetsConfig

Load atomically loads a stored TargetsConfig. If there was no TargetsConfig stored, nil will be returned.

func (*CachedTargets) RangeAllTargets

func (ct *CachedTargets) RangeAllTargets(f func(*Target) bool)

RangeAllTargets ranges over all targets. Do not modify the given Target copy.

func (*CachedTargets) RangeCellTenants added in v0.21.0

func (ct *CachedTargets) RangeCellTenants(f func(*CellTenant) bool)

RangeBrokers ranges over all brokers. Do not modify the given Broker copy.

func (*CachedTargets) Store

func (ct *CachedTargets) Store(t *TargetsConfig)

Store atomically stores a TargetsConfig.

type CellTenant added in v0.21.0

type CellTenant struct {

	// The type of this CellTenant (e.g. Broker, Channel, etc.).
	Type CellTenantType `protobuf:"varint,8,opt,name=type,proto3,enum=config.CellTenantType" json:"type,omitempty"`
	// The id of the object. E.g. UID of the resource.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The name of the object.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// The namespace of the object.
	Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// The object's subscriber's address.
	// Will we have more than one address?
	Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
	// The decouple queue for the cell tenant.
	DecoupleQueue *Queue `protobuf:"bytes,5,opt,name=decouple_queue,json=decoupleQueue,proto3" json:"decouple_queue,omitempty"`
	// All targets of the cell tenant. Key is defined by the CellTenant's type:
	// - Broker: Key is the name of the Trigger.
	Targets map[string]*Target `` /* 155-byte string literal not displayed */
	// The CellTenant's state.
	State State `protobuf:"varint,7,opt,name=state,proto3,enum=config.State" json:"state,omitempty"`
	// contains filtered or unexported fields
}

Represents a tenant of the Cell. E.g. Broker, Channel, etc.

func (*CellTenant) Descriptor deprecated added in v0.21.0

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

Deprecated: Use CellTenant.ProtoReflect.Descriptor instead.

func (*CellTenant) GetAddress added in v0.21.0

func (x *CellTenant) GetAddress() string

func (*CellTenant) GetDecoupleQueue added in v0.21.0

func (x *CellTenant) GetDecoupleQueue() *Queue

func (*CellTenant) GetId added in v0.21.0

func (x *CellTenant) GetId() string

func (*CellTenant) GetName added in v0.21.0

func (x *CellTenant) GetName() string

func (*CellTenant) GetNamespace added in v0.21.0

func (x *CellTenant) GetNamespace() string

func (*CellTenant) GetState added in v0.21.0

func (x *CellTenant) GetState() State

func (*CellTenant) GetTargets added in v0.21.0

func (x *CellTenant) GetTargets() map[string]*Target

func (*CellTenant) GetType added in v0.21.0

func (x *CellTenant) GetType() CellTenantType

func (*CellTenant) Key added in v0.21.0

func (x *CellTenant) Key() *CellTenantKey

Key returns the CellTenantKey for this Broker.

func (*CellTenant) ProtoMessage added in v0.21.0

func (*CellTenant) ProtoMessage()

func (*CellTenant) ProtoReflect added in v0.21.0

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

func (*CellTenant) Reset added in v0.21.0

func (x *CellTenant) Reset()

func (*CellTenant) String added in v0.21.0

func (x *CellTenant) String() string

type CellTenantKey added in v0.21.0

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

CellTenantKey uniquely identifies a single CellTenant, at a given point in time.

func CellTenantKeyFromPersistenceString added in v0.21.0

func CellTenantKeyFromPersistenceString(s string) (*CellTenantKey, error)

func KeyFromBroker added in v0.20.0

func KeyFromBroker(b *brokerv1.Broker) *CellTenantKey

KeyFromBroker creates a CellTenantKey from a K8s Broker object.

func KeyFromChannel added in v0.21.0

func KeyFromChannel(c *v1beta1.Channel) *CellTenantKey

KeyFromBroker creates a CellTenantKey from a K8s Broker object.

func TestOnlyBrokerKey added in v0.20.0

func TestOnlyBrokerKey(namespace, name string) *CellTenantKey

TestOnlyBrokerKey returns the key of a broker. This method exists to make tests that need a CellTenantKey, but do not need an actual Broker, easier to write.

func (*CellTenantKey) CreateEmptyCellTenant added in v0.21.0

func (k *CellTenantKey) CreateEmptyCellTenant() *CellTenant

CreateEmptyCellTenant creates an empty CellTenant that corresponds to this CellTenantKey. It is empty except for the portions known about by the CellTenantKey.

func (*CellTenantKey) MetricsResource added in v0.21.0

func (k *CellTenantKey) MetricsResource() resource.Resource

MetricsResource generates the Resource object that metrics will be associated with.

func (*CellTenantKey) PersistenceString added in v0.21.0

func (k *CellTenantKey) PersistenceString() string

PersistenceString is the string that is persisted as the key for this Broker in the protobuf. It is stable and can only change if all existing usage locations are made backwards compatible, supporting _both_ the old and the new format, for at least one release.

func (*CellTenantKey) SpanMessagingDestination added in v0.21.0

func (k *CellTenantKey) SpanMessagingDestination() string

SpanMessagingDestination is the Messaging Destination of requests sent to this CellTenantKey.

func (*CellTenantKey) SpanMessagingDestinationAttribute added in v0.21.0

func (k *CellTenantKey) SpanMessagingDestinationAttribute() trace.Attribute

SpanMessagingDestinationAttribute is the Messaging Destination attribute that should be attached to the tracing Span.

func (*CellTenantKey) String added in v0.21.0

func (k *CellTenantKey) String() string

String creates a human readable version of this key. It is for debug purposes only. It is free to change at any time.

type CellTenantMutation added in v0.21.0

type CellTenantMutation interface {
	// SetID sets the CellTenant's ID.
	SetID(id string) CellTenantMutation
	// SetAddress sets the CellTenant's subscriber's address.
	SetAddress(address string) CellTenantMutation
	// SetDecoupleQueue sets the CellTenant's decouple queue.
	SetDecoupleQueue(q *Queue) CellTenantMutation
	// SetState sets the CellTenant's state.
	SetState(s State) CellTenantMutation
	// UpsertTargets upserts Targets to the CellTenant.
	// The targets' namespace, CellTenantType, and CellTenantName will be set to the CellTenant's
	// value.
	UpsertTargets(...*Target) CellTenantMutation
	// DeleteTargets targets deletes Targets from the CellTenant.
	DeleteTargets(...*Target) CellTenantMutation
	// Delete deletes the CellTenant.
	Delete()
}

CellTenantMutation provides functions to mutate a CellTenant. The changes made via the CellTenantMutation must be "committed" altogether.

type CellTenantType added in v0.21.0

type CellTenantType int32

CellTenantType is the type of the Cell Tenant.

const (
	CellTenantType_UNKNOWN_CELL_TENANT_TYPE CellTenantType = 0
	CellTenantType_BROKER                   CellTenantType = 1
	CellTenantType_CHANNEL                  CellTenantType = 2
)

func (CellTenantType) Descriptor added in v0.21.0

func (CellTenantType) Enum added in v0.21.0

func (x CellTenantType) Enum() *CellTenantType

func (CellTenantType) EnumDescriptor deprecated added in v0.21.0

func (CellTenantType) EnumDescriptor() ([]byte, []int)

Deprecated: Use CellTenantType.Descriptor instead.

func (CellTenantType) Number added in v0.21.0

func (CellTenantType) String added in v0.21.0

func (x CellTenantType) String() string

func (CellTenantType) Type added in v0.21.0

type Queue

type Queue struct {
	Topic        string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
	Subscription string `protobuf:"bytes,2,opt,name=subscription,proto3" json:"subscription,omitempty"`
	State        State  `protobuf:"varint,3,opt,name=state,proto3,enum=config.State" json:"state,omitempty"`
	// contains filtered or unexported fields
}

A pubsub "queue".

func (*Queue) Descriptor deprecated

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

Deprecated: Use Queue.ProtoReflect.Descriptor instead.

func (*Queue) GetState added in v0.16.2

func (x *Queue) GetState() State

func (*Queue) GetSubscription

func (x *Queue) GetSubscription() string

func (*Queue) GetTopic

func (x *Queue) GetTopic() string

func (*Queue) ProtoMessage

func (*Queue) ProtoMessage()

func (*Queue) ProtoReflect added in v0.15.0

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

func (*Queue) Reset

func (x *Queue) Reset()

func (*Queue) String

func (x *Queue) String() string

type ReadonlyTargets

type ReadonlyTargets interface {
	// RangeAllTargets ranges over all targets.
	// Do not modify the given Target copy.
	RangeAllTargets(func(*Target) bool)
	// GetTargetByKey returns a target by its trigger key, if it exists.
	// Do not modify the returned Target copy.
	GetTargetByKey(key *TargetKey) (*Target, bool)
	// GetCellTenantByKey returns a CellTenant and its Targets, if it exists.
	// Do not modify the returned CellTenant copy.
	GetCellTenantByKey(key *CellTenantKey) (*CellTenant, bool)
	// RangeCellTenants ranges over all CellTenants.
	// Do not modify the given CellTenant copy.
	RangeCellTenants(func(*CellTenant) bool)
	// Bytes serializes all the targets.
	Bytes() ([]byte, error)
	// DebugString returns the text format of all the targets. It is for _debug_ purposes only. The
	// output format is not guaranteed to be stable and may change at any time.
	DebugString() string
}

ReadonlyTargets provides "read" functions for CellTenants and targets.

type State

type State int32

The state of the object. We may add additional intermediate states if needed.

const (
	State_UNKNOWN State = 0
	State_READY   State = 1
)

func (State) Descriptor added in v0.15.0

func (State) Descriptor() protoreflect.EnumDescriptor

func (State) Enum added in v0.15.0

func (x State) Enum() *State

func (State) EnumDescriptor deprecated

func (State) EnumDescriptor() ([]byte, []int)

Deprecated: Use State.Descriptor instead.

func (State) Number added in v0.15.0

func (x State) Number() protoreflect.EnumNumber

func (State) String

func (x State) String() string

func (State) Type added in v0.15.0

func (State) Type() protoreflect.EnumType

type Target

type Target struct {

	// The id of the object. E.g. UID of the resource.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The name of the object.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// The namespace of the object.
	Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// The name of the CellTenant that this Target is associated with.
	CellTenantName string `protobuf:"bytes,4,opt,name=cell_tenant_name,json=cellTenantName,proto3" json:"cell_tenant_name,omitempty"`
	// The type of the CellTenant that this Target is associated with.
	CellTenantType CellTenantType `` /* 133-byte string literal not displayed */
	// The resolved subscriber URI of the target.
	Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"`
	// Optional filters from the trigger.
	FilterAttributes map[string]string `` /* 197-byte string literal not displayed */
	// The retry queue for the target.
	RetryQueue *Queue `protobuf:"bytes,7,opt,name=retry_queue,json=retryQueue,proto3" json:"retry_queue,omitempty"`
	// The target state.
	State State `protobuf:"varint,8,opt,name=state,proto3,enum=config.State" json:"state,omitempty"`
	// The resolved URI that replies are sent to.
	ReplyAddress string `protobuf:"bytes,10,opt,name=reply_address,json=replyAddress,proto3" json:"reply_address,omitempty"`
	// contains filtered or unexported fields
}

Target defines the config schema for a CellTenant's subscription's target.

func (*Target) Descriptor deprecated

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

Deprecated: Use Target.ProtoReflect.Descriptor instead.

func (*Target) GetAddress

func (x *Target) GetAddress() string

func (*Target) GetCellTenantName added in v0.21.0

func (x *Target) GetCellTenantName() string

func (*Target) GetCellTenantType added in v0.21.0

func (x *Target) GetCellTenantType() CellTenantType

func (*Target) GetFilterAttributes

func (x *Target) GetFilterAttributes() map[string]string

func (*Target) GetId

func (x *Target) GetId() string

func (*Target) GetName

func (x *Target) GetName() string

func (*Target) GetNamespace

func (x *Target) GetNamespace() string

func (*Target) GetReplyAddress added in v0.21.0

func (x *Target) GetReplyAddress() string

func (*Target) GetRetryQueue

func (x *Target) GetRetryQueue() *Queue

func (*Target) GetState

func (x *Target) GetState() State

func (*Target) Key added in v0.15.0

func (x *Target) Key() *TargetKey

Key returns the TargetKey for this Target.

func (*Target) ProtoMessage

func (*Target) ProtoMessage()

func (*Target) ProtoReflect added in v0.15.0

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

func (*Target) Reset

func (x *Target) Reset()

func (*Target) String

func (x *Target) String() string

type TargetKey added in v0.20.0

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

TargetKey uniquely identifies a single Target, at a given point in time.

func (*TargetKey) ParentKey added in v0.20.0

func (k *TargetKey) ParentKey() *CellTenantKey

ParentKey is the key of the parent this Target corresponds to.

func (*TargetKey) String added in v0.20.0

func (k *TargetKey) String() string

String creates a human readable version of this key. It is for debug purposes only. It is free to change at any time.

type Targets

type Targets interface {
	ReadonlyTargets
	// MutateCellTenant mutates a CellTenant by its key.
	// If the CellTenant doesn't exist, it will be added (unless Delete() is called).
	MutateCellTenant(key *CellTenantKey, mutate func(CellTenantMutation))
}

Targets provides "read" and "write" functions for BrokerCell targets.

type TargetsConfig

type TargetsConfig struct {

	// Keyed by the CellTenant's PersistenceString().
	// Broker: "<ns>/<brokerName>"
	CellTenants map[string]*CellTenant `` /* 182-byte string literal not displayed */
	// contains filtered or unexported fields
}

TargetsConfig is the collection of all Targets.

func (*TargetsConfig) Descriptor deprecated

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

Deprecated: Use TargetsConfig.ProtoReflect.Descriptor instead.

func (*TargetsConfig) GetCellTenants added in v0.21.0

func (x *TargetsConfig) GetCellTenants() map[string]*CellTenant

func (*TargetsConfig) ProtoMessage

func (*TargetsConfig) ProtoMessage()

func (*TargetsConfig) ProtoReflect added in v0.15.0

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

func (*TargetsConfig) Reset

func (x *TargetsConfig) Reset()

func (*TargetsConfig) String

func (x *TargetsConfig) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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