pbsubscribe

package
v1.12.3 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Topic_name = map[int32]string{
		0: "Unknown",
		1: "ServiceHealth",
		2: "ServiceHealthConnect",
	}
	Topic_value = map[string]int32{
		"Unknown":              0,
		"ServiceHealth":        1,
		"ServiceHealthConnect": 2,
	}
)

Enum value maps for Topic.

View Source
var (
	CatalogOp_name = map[int32]string{
		0: "Register",
		1: "Deregister",
	}
	CatalogOp_value = map[string]int32{
		"Register":   0,
		"Deregister": 1,
	}
)

Enum value maps for CatalogOp.

View Source
var File_proto_pbsubscribe_subscribe_proto protoreflect.FileDescriptor

Functions

func RegisterStateChangeSubscriptionServer

func RegisterStateChangeSubscriptionServer(s *grpc.Server, srv StateChangeSubscriptionServer)

Types

type CatalogOp

type CatalogOp int32
const (
	CatalogOp_Register   CatalogOp = 0
	CatalogOp_Deregister CatalogOp = 1
)

func (CatalogOp) Descriptor added in v1.12.0

func (CatalogOp) Descriptor() protoreflect.EnumDescriptor

func (CatalogOp) Enum added in v1.12.0

func (x CatalogOp) Enum() *CatalogOp

func (CatalogOp) EnumDescriptor deprecated

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

Deprecated: Use CatalogOp.Descriptor instead.

func (CatalogOp) Number added in v1.12.0

func (x CatalogOp) Number() protoreflect.EnumNumber

func (CatalogOp) String

func (x CatalogOp) String() string

func (CatalogOp) Type added in v1.12.0

type Event

type Event struct {

	// Index is the raft index at which the mutation took place. At the top
	// level of a subscription there will always be at most one Event per index.
	// If multiple events are published to the same topic in a single raft
	// transaction then the batch of events will be encoded inside a single
	// top-level event to ensure they are delivered atomically to clients.
	Index uint64 `protobuf:"varint,1,opt,name=Index,proto3" json:"Index,omitempty"`
	// Payload is the actual event content.
	//
	// Types that are assignable to Payload:
	//	*Event_EndOfSnapshot
	//	*Event_NewSnapshotToFollow
	//	*Event_EventBatch
	//	*Event_ServiceHealth
	Payload isEvent_Payload `protobuf_oneof:"Payload"`
	// contains filtered or unexported fields
}

Event describes a streaming update on a subscription. Events are used both to describe the current "snapshot" of the result as well as ongoing mutations to that snapshot.

func (*Event) Descriptor deprecated

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

Deprecated: Use Event.ProtoReflect.Descriptor instead.

func (*Event) GetEndOfSnapshot

func (x *Event) GetEndOfSnapshot() bool

func (*Event) GetEventBatch

func (x *Event) GetEventBatch() *EventBatch

func (*Event) GetIndex

func (x *Event) GetIndex() uint64

func (*Event) GetNewSnapshotToFollow

func (x *Event) GetNewSnapshotToFollow() bool

func (*Event) GetPayload

func (m *Event) GetPayload() isEvent_Payload

func (*Event) GetServiceHealth

func (x *Event) GetServiceHealth() *ServiceHealthUpdate

func (*Event) MarshalBinary

func (msg *Event) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) ProtoReflect added in v1.12.0

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

func (*Event) Reset

func (x *Event) Reset()

func (*Event) String

func (x *Event) String() string

func (*Event) UnmarshalBinary

func (msg *Event) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

type EventBatch

type EventBatch struct {
	Events []*Event `protobuf:"bytes,1,rep,name=Events,proto3" json:"Events,omitempty"`
	// contains filtered or unexported fields
}

func (*EventBatch) Descriptor deprecated

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

Deprecated: Use EventBatch.ProtoReflect.Descriptor instead.

func (*EventBatch) GetEvents

func (x *EventBatch) GetEvents() []*Event

func (*EventBatch) MarshalBinary

func (msg *EventBatch) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*EventBatch) ProtoMessage

func (*EventBatch) ProtoMessage()

func (*EventBatch) ProtoReflect added in v1.12.0

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

func (*EventBatch) Reset

func (x *EventBatch) Reset()

func (*EventBatch) String

func (x *EventBatch) String() string

func (*EventBatch) UnmarshalBinary

func (msg *EventBatch) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

type Event_EndOfSnapshot

type Event_EndOfSnapshot struct {
	// EndOfSnapshot indicates the event stream for the initial snapshot has
	// ended. Subsequent Events delivered will be mutations to that result.
	EndOfSnapshot bool `protobuf:"varint,2,opt,name=EndOfSnapshot,proto3,oneof"`
}

type Event_EventBatch

type Event_EventBatch struct {
	// EventBatch is a set of events. This is typically used as the payload
	// type where multiple events are emitted in a single topic and raft
	// index (e.g. transactional updates). In this case the Topic and Index
	// values of all events will match and the whole set should be delivered
	// and consumed atomically.
	EventBatch *EventBatch `protobuf:"bytes,4,opt,name=EventBatch,proto3,oneof"`
}

type Event_NewSnapshotToFollow

type Event_NewSnapshotToFollow struct {
	// NewSnapshotToFollow indicates that the client view is stale. The client
	// must reset its view before handing any more events. Subsequent events
	// in the stream will be for a new snapshot until an EndOfSnapshot event
	// is received.
	NewSnapshotToFollow bool `protobuf:"varint,3,opt,name=NewSnapshotToFollow,proto3,oneof"`
}

type Event_ServiceHealth

type Event_ServiceHealth struct {
	// ServiceHealth is used for ServiceHealth and ServiceHealthConnect
	// topics.
	ServiceHealth *ServiceHealthUpdate `protobuf:"bytes,10,opt,name=ServiceHealth,proto3,oneof"`
}

type ServiceHealthUpdate

type ServiceHealthUpdate struct {
	Op               CatalogOp                   `protobuf:"varint,1,opt,name=Op,proto3,enum=subscribe.CatalogOp" json:"Op,omitempty"`
	CheckServiceNode *pbservice.CheckServiceNode `protobuf:"bytes,2,opt,name=CheckServiceNode,proto3" json:"CheckServiceNode,omitempty"`
	// contains filtered or unexported fields
}

func (*ServiceHealthUpdate) Descriptor deprecated

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

Deprecated: Use ServiceHealthUpdate.ProtoReflect.Descriptor instead.

func (*ServiceHealthUpdate) GetCheckServiceNode

func (x *ServiceHealthUpdate) GetCheckServiceNode() *pbservice.CheckServiceNode

func (*ServiceHealthUpdate) GetOp

func (x *ServiceHealthUpdate) GetOp() CatalogOp

func (*ServiceHealthUpdate) MarshalBinary

func (msg *ServiceHealthUpdate) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*ServiceHealthUpdate) ProtoMessage

func (*ServiceHealthUpdate) ProtoMessage()

func (*ServiceHealthUpdate) ProtoReflect added in v1.12.0

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

func (*ServiceHealthUpdate) Reset

func (x *ServiceHealthUpdate) Reset()

func (*ServiceHealthUpdate) String

func (x *ServiceHealthUpdate) String() string

func (*ServiceHealthUpdate) UnmarshalBinary

func (msg *ServiceHealthUpdate) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

type StateChangeSubscriptionClient

type StateChangeSubscriptionClient interface {
	// Subscribe to a topic to receive events when there are changes to the topic.
	//
	// If SubscribeRequest.Index is 0 the event stream will start with one or
	// more snapshot events, followed by an EndOfSnapshot event. Subsequent
	// events will be a live stream of events as they happen.
	//
	// If SubscribeRequest.Index is > 0 it is assumed the client already has a
	// snapshot, and is trying to resume a stream that was disconnected. The
	// client will either receive a NewSnapshotToFollow event, indicating the
	// client view is stale and it must reset its view and prepare for a new
	// snapshot. Or, if no NewSnapshotToFollow event is received, the client
	// view is still fresh, and all events will be the live stream.
	//
	// Subscribe may return a gRPC status error with codes.ABORTED to indicate
	// the client view is now stale due to a change on the server. The client
	// must reset its view and issue a new Subscribe call to restart the stream.
	// This error is used when the server can no longer correctly maintain the
	// stream, for example because the ACL permissions for the token changed, or
	// because the server state was restored from a snapshot.
	Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (StateChangeSubscription_SubscribeClient, error)
}

StateChangeSubscriptionClient is the client API for StateChangeSubscription service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type StateChangeSubscriptionServer

type StateChangeSubscriptionServer interface {
	// Subscribe to a topic to receive events when there are changes to the topic.
	//
	// If SubscribeRequest.Index is 0 the event stream will start with one or
	// more snapshot events, followed by an EndOfSnapshot event. Subsequent
	// events will be a live stream of events as they happen.
	//
	// If SubscribeRequest.Index is > 0 it is assumed the client already has a
	// snapshot, and is trying to resume a stream that was disconnected. The
	// client will either receive a NewSnapshotToFollow event, indicating the
	// client view is stale and it must reset its view and prepare for a new
	// snapshot. Or, if no NewSnapshotToFollow event is received, the client
	// view is still fresh, and all events will be the live stream.
	//
	// Subscribe may return a gRPC status error with codes.ABORTED to indicate
	// the client view is now stale due to a change on the server. The client
	// must reset its view and issue a new Subscribe call to restart the stream.
	// This error is used when the server can no longer correctly maintain the
	// stream, for example because the ACL permissions for the token changed, or
	// because the server state was restored from a snapshot.
	Subscribe(*SubscribeRequest, StateChangeSubscription_SubscribeServer) error
}

StateChangeSubscriptionServer is the server API for StateChangeSubscription service.

type StateChangeSubscription_SubscribeClient

type StateChangeSubscription_SubscribeClient interface {
	Recv() (*Event, error)
	grpc.ClientStream
}

type StateChangeSubscription_SubscribeServer

type StateChangeSubscription_SubscribeServer interface {
	Send(*Event) error
	grpc.ServerStream
}

type SubscribeRequest

type SubscribeRequest struct {

	// Topic identifies the set of events the subscriber is interested in.
	Topic Topic `protobuf:"varint,1,opt,name=Topic,proto3,enum=subscribe.Topic" json:"Topic,omitempty"`
	// Key is a topic-specific identifier that restricts the scope of the
	// subscription to only events pertaining to that identifier. For example,
	// to receive events for a single service, the service's name is specified
	// as the key.
	Key string `protobuf:"bytes,2,opt,name=Key,proto3" json:"Key,omitempty"`
	// Token is the ACL token to authenticate the request. The token must have
	// sufficient privileges to read the requested information otherwise events
	// will be filtered, possibly resulting in an empty snapshot and no further
	// updates sent.
	Token string `protobuf:"bytes,3,opt,name=Token,proto3" json:"Token,omitempty"`
	// Index is the raft index the subscriber has already observed up to. This
	// is zero on an initial streaming call, but then can be provided by a
	// client on subsequent re-connections such that the full snapshot doesn't
	// need to be resent if the client is up to date.
	Index uint64 `protobuf:"varint,4,opt,name=Index,proto3" json:"Index,omitempty"`
	// Datacenter specifies the Consul datacenter the request is targeted at.
	// If it's not the local DC the server will forward the request to
	// the remote DC and proxy the results back  to the subscriber. An empty
	// string defaults to the local datacenter.
	Datacenter string `protobuf:"bytes,5,opt,name=Datacenter,proto3" json:"Datacenter,omitempty"`
	// Namespace which contains the resources. If Namespace is not specified the
	// default namespace will be used.
	//
	// Namespace is an enterprise-only feature.
	Namespace string `protobuf:"bytes,6,opt,name=Namespace,proto3" json:"Namespace,omitempty"`
	// Partition which contains the resources. If Partition is not specified the
	// default partition will be used.
	//
	// Partition is an enterprise-only feature.
	Partition string `protobuf:"bytes,7,opt,name=Partition,proto3" json:"Partition,omitempty"`
	// contains filtered or unexported fields
}

SubscribeRequest used to subscribe to a topic.

func (*SubscribeRequest) AllowStaleRead added in v1.10.3

func (req *SubscribeRequest) AllowStaleRead() bool

AllowStaleRead implements structs.RPCInfo

func (*SubscribeRequest) Descriptor deprecated

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

Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead.

func (*SubscribeRequest) GetDatacenter

func (x *SubscribeRequest) GetDatacenter() string

func (*SubscribeRequest) GetIndex

func (x *SubscribeRequest) GetIndex() uint64

func (*SubscribeRequest) GetKey

func (x *SubscribeRequest) GetKey() string

func (*SubscribeRequest) GetNamespace

func (x *SubscribeRequest) GetNamespace() string

func (*SubscribeRequest) GetPartition added in v1.11.0

func (x *SubscribeRequest) GetPartition() string

func (*SubscribeRequest) GetToken

func (x *SubscribeRequest) GetToken() string

func (*SubscribeRequest) GetTopic

func (x *SubscribeRequest) GetTopic() Topic

func (*SubscribeRequest) HasTimedOut added in v1.11.0

func (req *SubscribeRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error)

HasTimedOut implements structs.RPCInfo

func (*SubscribeRequest) IsRead added in v1.10.3

func (req *SubscribeRequest) IsRead() bool

IsRead implements structs.RPCInfo

func (*SubscribeRequest) MarshalBinary

func (msg *SubscribeRequest) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) ProtoReflect added in v1.12.0

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

func (*SubscribeRequest) RequestDatacenter added in v1.10.3

func (req *SubscribeRequest) RequestDatacenter() string

RequestDatacenter implements structs.RPCInfo

func (*SubscribeRequest) Reset

func (x *SubscribeRequest) Reset()

func (*SubscribeRequest) SetTokenSecret added in v1.10.3

func (req *SubscribeRequest) SetTokenSecret(token string)

SetTokenSecret implements structs.RPCInfo

func (*SubscribeRequest) String

func (x *SubscribeRequest) String() string

func (*SubscribeRequest) Timeout added in v1.11.9

func (req *SubscribeRequest) Timeout(rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) time.Duration

Timeout implements structs.RPCInfo

func (*SubscribeRequest) TokenSecret added in v1.10.3

func (req *SubscribeRequest) TokenSecret() string

TokenSecret implements structs.RPCInfo

func (*SubscribeRequest) UnmarshalBinary

func (msg *SubscribeRequest) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

type Topic

type Topic int32

Topic enumerates the supported event topics.

const (
	Topic_Unknown Topic = 0
	// ServiceHealth topic contains events for any changes to service health.
	Topic_ServiceHealth Topic = 1
	// ServiceHealthConnect topic contains events for any changes to service
	// health for connect-enabled services.
	Topic_ServiceHealthConnect Topic = 2
)

func (Topic) Descriptor added in v1.12.0

func (Topic) Descriptor() protoreflect.EnumDescriptor

func (Topic) Enum added in v1.12.0

func (x Topic) Enum() *Topic

func (Topic) EnumDescriptor deprecated

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

Deprecated: Use Topic.Descriptor instead.

func (Topic) Number added in v1.12.0

func (x Topic) Number() protoreflect.EnumNumber

func (Topic) String

func (x Topic) String() string

func (Topic) Type added in v1.12.0

func (Topic) Type() protoreflect.EnumType

type UnimplementedStateChangeSubscriptionServer

type UnimplementedStateChangeSubscriptionServer struct {
}

UnimplementedStateChangeSubscriptionServer can be embedded to have forward compatible implementations.

func (*UnimplementedStateChangeSubscriptionServer) Subscribe

Jump to

Keyboard shortcuts

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