Initial revisin of healthchecker, inspired by HAProxy
This commit is contained in:
776
internal/grpcapi/healthchecker.pb.go
Normal file
776
internal/grpcapi/healthchecker.pb.go
Normal file
@@ -0,0 +1,776 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v3.21.12
|
||||
// source: proto/healthchecker.proto
|
||||
|
||||
package grpcapi
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type ListVIPsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListVIPsRequest) Reset() {
|
||||
*x = ListVIPsRequest{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListVIPsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListVIPsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListVIPsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListVIPsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListVIPsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type GetVIPRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
VipName string `protobuf:"bytes,1,opt,name=vip_name,json=vipName,proto3" json:"vip_name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetVIPRequest) Reset() {
|
||||
*x = GetVIPRequest{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetVIPRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetVIPRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetVIPRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetVIPRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetVIPRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetVIPRequest) GetVipName() string {
|
||||
if x != nil {
|
||||
return x.VipName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ListBackendsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
VipName string `protobuf:"bytes,1,opt,name=vip_name,json=vipName,proto3" json:"vip_name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListBackendsRequest) Reset() {
|
||||
*x = ListBackendsRequest{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListBackendsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListBackendsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListBackendsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListBackendsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListBackendsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ListBackendsRequest) GetVipName() string {
|
||||
if x != nil {
|
||||
return x.VipName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetBackendRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
VipName string `protobuf:"bytes,1,opt,name=vip_name,json=vipName,proto3" json:"vip_name,omitempty"`
|
||||
BackendAddress string `protobuf:"bytes,2,opt,name=backend_address,json=backendAddress,proto3" json:"backend_address,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetBackendRequest) Reset() {
|
||||
*x = GetBackendRequest{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetBackendRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetBackendRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetBackendRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetBackendRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetBackendRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *GetBackendRequest) GetVipName() string {
|
||||
if x != nil {
|
||||
return x.VipName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetBackendRequest) GetBackendAddress() string {
|
||||
if x != nil {
|
||||
return x.BackendAddress
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type PauseResumeRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
VipName string `protobuf:"bytes,1,opt,name=vip_name,json=vipName,proto3" json:"vip_name,omitempty"`
|
||||
BackendAddress string `protobuf:"bytes,2,opt,name=backend_address,json=backendAddress,proto3" json:"backend_address,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *PauseResumeRequest) Reset() {
|
||||
*x = PauseResumeRequest{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *PauseResumeRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PauseResumeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *PauseResumeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PauseResumeRequest.ProtoReflect.Descriptor instead.
|
||||
func (*PauseResumeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *PauseResumeRequest) GetVipName() string {
|
||||
if x != nil {
|
||||
return x.VipName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PauseResumeRequest) GetBackendAddress() string {
|
||||
if x != nil {
|
||||
return x.BackendAddress
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type WatchRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *WatchRequest) Reset() {
|
||||
*x = WatchRequest{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *WatchRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*WatchRequest) ProtoMessage() {}
|
||||
|
||||
func (x *WatchRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use WatchRequest.ProtoReflect.Descriptor instead.
|
||||
func (*WatchRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
type ListVIPsResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
VipNames []string `protobuf:"bytes,1,rep,name=vip_names,json=vipNames,proto3" json:"vip_names,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListVIPsResponse) Reset() {
|
||||
*x = ListVIPsResponse{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListVIPsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListVIPsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListVIPsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListVIPsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListVIPsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *ListVIPsResponse) GetVipNames() []string {
|
||||
if x != nil {
|
||||
return x.VipNames
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type VIPInfo struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"`
|
||||
Port uint32 `protobuf:"varint,4,opt,name=port,proto3" json:"port,omitempty"`
|
||||
Backends []string `protobuf:"bytes,5,rep,name=backends,proto3" json:"backends,omitempty"`
|
||||
Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *VIPInfo) Reset() {
|
||||
*x = VIPInfo{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *VIPInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*VIPInfo) ProtoMessage() {}
|
||||
|
||||
func (x *VIPInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use VIPInfo.ProtoReflect.Descriptor instead.
|
||||
func (*VIPInfo) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *VIPInfo) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *VIPInfo) GetAddress() string {
|
||||
if x != nil {
|
||||
return x.Address
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *VIPInfo) GetProtocol() string {
|
||||
if x != nil {
|
||||
return x.Protocol
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *VIPInfo) GetPort() uint32 {
|
||||
if x != nil {
|
||||
return x.Port
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *VIPInfo) GetBackends() []string {
|
||||
if x != nil {
|
||||
return x.Backends
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *VIPInfo) GetDescription() string {
|
||||
if x != nil {
|
||||
return x.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ListBackendsResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Backends []*BackendInfo `protobuf:"bytes,1,rep,name=backends,proto3" json:"backends,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListBackendsResponse) Reset() {
|
||||
*x = ListBackendsResponse{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListBackendsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListBackendsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListBackendsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListBackendsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListBackendsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *ListBackendsResponse) GetBackends() []*BackendInfo {
|
||||
if x != nil {
|
||||
return x.Backends
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type BackendInfo struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
VipName string `protobuf:"bytes,1,opt,name=vip_name,json=vipName,proto3" json:"vip_name,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
State string `protobuf:"bytes,3,opt,name=state,proto3" json:"state,omitempty"`
|
||||
Transitions []*TransitionRecord `protobuf:"bytes,4,rep,name=transitions,proto3" json:"transitions,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BackendInfo) Reset() {
|
||||
*x = BackendInfo{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BackendInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BackendInfo) ProtoMessage() {}
|
||||
|
||||
func (x *BackendInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use BackendInfo.ProtoReflect.Descriptor instead.
|
||||
func (*BackendInfo) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *BackendInfo) GetVipName() string {
|
||||
if x != nil {
|
||||
return x.VipName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BackendInfo) GetAddress() string {
|
||||
if x != nil {
|
||||
return x.Address
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BackendInfo) GetState() string {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BackendInfo) GetTransitions() []*TransitionRecord {
|
||||
if x != nil {
|
||||
return x.Transitions
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type TransitionRecord struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
|
||||
To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
|
||||
AtUnixNs int64 `protobuf:"varint,3,opt,name=at_unix_ns,json=atUnixNs,proto3" json:"at_unix_ns,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *TransitionRecord) Reset() {
|
||||
*x = TransitionRecord{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *TransitionRecord) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TransitionRecord) ProtoMessage() {}
|
||||
|
||||
func (x *TransitionRecord) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[10]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TransitionRecord.ProtoReflect.Descriptor instead.
|
||||
func (*TransitionRecord) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
func (x *TransitionRecord) GetFrom() string {
|
||||
if x != nil {
|
||||
return x.From
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TransitionRecord) GetTo() string {
|
||||
if x != nil {
|
||||
return x.To
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TransitionRecord) GetAtUnixNs() int64 {
|
||||
if x != nil {
|
||||
return x.AtUnixNs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type TransitionEvent struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
VipName string `protobuf:"bytes,1,opt,name=vip_name,json=vipName,proto3" json:"vip_name,omitempty"`
|
||||
BackendAddress string `protobuf:"bytes,2,opt,name=backend_address,json=backendAddress,proto3" json:"backend_address,omitempty"`
|
||||
Transition *TransitionRecord `protobuf:"bytes,3,opt,name=transition,proto3" json:"transition,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *TransitionEvent) Reset() {
|
||||
*x = TransitionEvent{}
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *TransitionEvent) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TransitionEvent) ProtoMessage() {}
|
||||
|
||||
func (x *TransitionEvent) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_healthchecker_proto_msgTypes[11]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TransitionEvent.ProtoReflect.Descriptor instead.
|
||||
func (*TransitionEvent) Descriptor() ([]byte, []int) {
|
||||
return file_proto_healthchecker_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
func (x *TransitionEvent) GetVipName() string {
|
||||
if x != nil {
|
||||
return x.VipName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TransitionEvent) GetBackendAddress() string {
|
||||
if x != nil {
|
||||
return x.BackendAddress
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TransitionEvent) GetTransition() *TransitionRecord {
|
||||
if x != nil {
|
||||
return x.Transition
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proto_healthchecker_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_proto_healthchecker_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x19proto/healthchecker.proto\x12\rhealthchecker\"\x11\n" +
|
||||
"\x0fListVIPsRequest\"*\n" +
|
||||
"\rGetVIPRequest\x12\x19\n" +
|
||||
"\bvip_name\x18\x01 \x01(\tR\avipName\"0\n" +
|
||||
"\x13ListBackendsRequest\x12\x19\n" +
|
||||
"\bvip_name\x18\x01 \x01(\tR\avipName\"W\n" +
|
||||
"\x11GetBackendRequest\x12\x19\n" +
|
||||
"\bvip_name\x18\x01 \x01(\tR\avipName\x12'\n" +
|
||||
"\x0fbackend_address\x18\x02 \x01(\tR\x0ebackendAddress\"X\n" +
|
||||
"\x12PauseResumeRequest\x12\x19\n" +
|
||||
"\bvip_name\x18\x01 \x01(\tR\avipName\x12'\n" +
|
||||
"\x0fbackend_address\x18\x02 \x01(\tR\x0ebackendAddress\"\x0e\n" +
|
||||
"\fWatchRequest\"/\n" +
|
||||
"\x10ListVIPsResponse\x12\x1b\n" +
|
||||
"\tvip_names\x18\x01 \x03(\tR\bvipNames\"\xa5\x01\n" +
|
||||
"\aVIPInfo\x12\x12\n" +
|
||||
"\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" +
|
||||
"\aaddress\x18\x02 \x01(\tR\aaddress\x12\x1a\n" +
|
||||
"\bprotocol\x18\x03 \x01(\tR\bprotocol\x12\x12\n" +
|
||||
"\x04port\x18\x04 \x01(\rR\x04port\x12\x1a\n" +
|
||||
"\bbackends\x18\x05 \x03(\tR\bbackends\x12 \n" +
|
||||
"\vdescription\x18\x06 \x01(\tR\vdescription\"N\n" +
|
||||
"\x14ListBackendsResponse\x126\n" +
|
||||
"\bbackends\x18\x01 \x03(\v2\x1a.healthchecker.BackendInfoR\bbackends\"\x9b\x01\n" +
|
||||
"\vBackendInfo\x12\x19\n" +
|
||||
"\bvip_name\x18\x01 \x01(\tR\avipName\x12\x18\n" +
|
||||
"\aaddress\x18\x02 \x01(\tR\aaddress\x12\x14\n" +
|
||||
"\x05state\x18\x03 \x01(\tR\x05state\x12A\n" +
|
||||
"\vtransitions\x18\x04 \x03(\v2\x1f.healthchecker.TransitionRecordR\vtransitions\"T\n" +
|
||||
"\x10TransitionRecord\x12\x12\n" +
|
||||
"\x04from\x18\x01 \x01(\tR\x04from\x12\x0e\n" +
|
||||
"\x02to\x18\x02 \x01(\tR\x02to\x12\x1c\n" +
|
||||
"\n" +
|
||||
"at_unix_ns\x18\x03 \x01(\x03R\batUnixNs\"\x96\x01\n" +
|
||||
"\x0fTransitionEvent\x12\x19\n" +
|
||||
"\bvip_name\x18\x01 \x01(\tR\avipName\x12'\n" +
|
||||
"\x0fbackend_address\x18\x02 \x01(\tR\x0ebackendAddress\x12?\n" +
|
||||
"\n" +
|
||||
"transition\x18\x03 \x01(\v2\x1f.healthchecker.TransitionRecordR\n" +
|
||||
"transition2\xb3\x04\n" +
|
||||
"\rHealthChecker\x12K\n" +
|
||||
"\bListVIPs\x12\x1e.healthchecker.ListVIPsRequest\x1a\x1f.healthchecker.ListVIPsResponse\x12>\n" +
|
||||
"\x06GetVIP\x12\x1c.healthchecker.GetVIPRequest\x1a\x16.healthchecker.VIPInfo\x12W\n" +
|
||||
"\fListBackends\x12\".healthchecker.ListBackendsRequest\x1a#.healthchecker.ListBackendsResponse\x12J\n" +
|
||||
"\n" +
|
||||
"GetBackend\x12 .healthchecker.GetBackendRequest\x1a\x1a.healthchecker.BackendInfo\x12M\n" +
|
||||
"\fPauseBackend\x12!.healthchecker.PauseResumeRequest\x1a\x1a.healthchecker.BackendInfo\x12N\n" +
|
||||
"\rResumeBackend\x12!.healthchecker.PauseResumeRequest\x1a\x1a.healthchecker.BackendInfo\x12Q\n" +
|
||||
"\x10WatchTransitions\x12\x1b.healthchecker.WatchRequest\x1a\x1e.healthchecker.TransitionEvent0\x01B.Z,git.ipng.ch/ipng/vpp-maglev/internal/grpcapib\x06proto3"
|
||||
|
||||
var (
|
||||
file_proto_healthchecker_proto_rawDescOnce sync.Once
|
||||
file_proto_healthchecker_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_proto_healthchecker_proto_rawDescGZIP() []byte {
|
||||
file_proto_healthchecker_proto_rawDescOnce.Do(func() {
|
||||
file_proto_healthchecker_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_proto_healthchecker_proto_rawDesc), len(file_proto_healthchecker_proto_rawDesc)))
|
||||
})
|
||||
return file_proto_healthchecker_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_healthchecker_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_proto_healthchecker_proto_goTypes = []any{
|
||||
(*ListVIPsRequest)(nil), // 0: healthchecker.ListVIPsRequest
|
||||
(*GetVIPRequest)(nil), // 1: healthchecker.GetVIPRequest
|
||||
(*ListBackendsRequest)(nil), // 2: healthchecker.ListBackendsRequest
|
||||
(*GetBackendRequest)(nil), // 3: healthchecker.GetBackendRequest
|
||||
(*PauseResumeRequest)(nil), // 4: healthchecker.PauseResumeRequest
|
||||
(*WatchRequest)(nil), // 5: healthchecker.WatchRequest
|
||||
(*ListVIPsResponse)(nil), // 6: healthchecker.ListVIPsResponse
|
||||
(*VIPInfo)(nil), // 7: healthchecker.VIPInfo
|
||||
(*ListBackendsResponse)(nil), // 8: healthchecker.ListBackendsResponse
|
||||
(*BackendInfo)(nil), // 9: healthchecker.BackendInfo
|
||||
(*TransitionRecord)(nil), // 10: healthchecker.TransitionRecord
|
||||
(*TransitionEvent)(nil), // 11: healthchecker.TransitionEvent
|
||||
}
|
||||
var file_proto_healthchecker_proto_depIdxs = []int32{
|
||||
9, // 0: healthchecker.ListBackendsResponse.backends:type_name -> healthchecker.BackendInfo
|
||||
10, // 1: healthchecker.BackendInfo.transitions:type_name -> healthchecker.TransitionRecord
|
||||
10, // 2: healthchecker.TransitionEvent.transition:type_name -> healthchecker.TransitionRecord
|
||||
0, // 3: healthchecker.HealthChecker.ListVIPs:input_type -> healthchecker.ListVIPsRequest
|
||||
1, // 4: healthchecker.HealthChecker.GetVIP:input_type -> healthchecker.GetVIPRequest
|
||||
2, // 5: healthchecker.HealthChecker.ListBackends:input_type -> healthchecker.ListBackendsRequest
|
||||
3, // 6: healthchecker.HealthChecker.GetBackend:input_type -> healthchecker.GetBackendRequest
|
||||
4, // 7: healthchecker.HealthChecker.PauseBackend:input_type -> healthchecker.PauseResumeRequest
|
||||
4, // 8: healthchecker.HealthChecker.ResumeBackend:input_type -> healthchecker.PauseResumeRequest
|
||||
5, // 9: healthchecker.HealthChecker.WatchTransitions:input_type -> healthchecker.WatchRequest
|
||||
6, // 10: healthchecker.HealthChecker.ListVIPs:output_type -> healthchecker.ListVIPsResponse
|
||||
7, // 11: healthchecker.HealthChecker.GetVIP:output_type -> healthchecker.VIPInfo
|
||||
8, // 12: healthchecker.HealthChecker.ListBackends:output_type -> healthchecker.ListBackendsResponse
|
||||
9, // 13: healthchecker.HealthChecker.GetBackend:output_type -> healthchecker.BackendInfo
|
||||
9, // 14: healthchecker.HealthChecker.PauseBackend:output_type -> healthchecker.BackendInfo
|
||||
9, // 15: healthchecker.HealthChecker.ResumeBackend:output_type -> healthchecker.BackendInfo
|
||||
11, // 16: healthchecker.HealthChecker.WatchTransitions:output_type -> healthchecker.TransitionEvent
|
||||
10, // [10:17] is the sub-list for method output_type
|
||||
3, // [3:10] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_healthchecker_proto_init() }
|
||||
func file_proto_healthchecker_proto_init() {
|
||||
if File_proto_healthchecker_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_healthchecker_proto_rawDesc), len(file_proto_healthchecker_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 12,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_healthchecker_proto_goTypes,
|
||||
DependencyIndexes: file_proto_healthchecker_proto_depIdxs,
|
||||
MessageInfos: file_proto_healthchecker_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_healthchecker_proto = out.File
|
||||
file_proto_healthchecker_proto_goTypes = nil
|
||||
file_proto_healthchecker_proto_depIdxs = nil
|
||||
}
|
||||
357
internal/grpcapi/healthchecker_grpc.pb.go
Normal file
357
internal/grpcapi/healthchecker_grpc.pb.go
Normal file
@@ -0,0 +1,357 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v3.21.12
|
||||
// source: proto/healthchecker.proto
|
||||
|
||||
package grpcapi
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
HealthChecker_ListVIPs_FullMethodName = "/healthchecker.HealthChecker/ListVIPs"
|
||||
HealthChecker_GetVIP_FullMethodName = "/healthchecker.HealthChecker/GetVIP"
|
||||
HealthChecker_ListBackends_FullMethodName = "/healthchecker.HealthChecker/ListBackends"
|
||||
HealthChecker_GetBackend_FullMethodName = "/healthchecker.HealthChecker/GetBackend"
|
||||
HealthChecker_PauseBackend_FullMethodName = "/healthchecker.HealthChecker/PauseBackend"
|
||||
HealthChecker_ResumeBackend_FullMethodName = "/healthchecker.HealthChecker/ResumeBackend"
|
||||
HealthChecker_WatchTransitions_FullMethodName = "/healthchecker.HealthChecker/WatchTransitions"
|
||||
)
|
||||
|
||||
// HealthCheckerClient is the client API for HealthChecker service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// HealthChecker exposes the state of backend health for all VIPs.
|
||||
type HealthCheckerClient interface {
|
||||
ListVIPs(ctx context.Context, in *ListVIPsRequest, opts ...grpc.CallOption) (*ListVIPsResponse, error)
|
||||
GetVIP(ctx context.Context, in *GetVIPRequest, opts ...grpc.CallOption) (*VIPInfo, error)
|
||||
ListBackends(ctx context.Context, in *ListBackendsRequest, opts ...grpc.CallOption) (*ListBackendsResponse, error)
|
||||
GetBackend(ctx context.Context, in *GetBackendRequest, opts ...grpc.CallOption) (*BackendInfo, error)
|
||||
PauseBackend(ctx context.Context, in *PauseResumeRequest, opts ...grpc.CallOption) (*BackendInfo, error)
|
||||
ResumeBackend(ctx context.Context, in *PauseResumeRequest, opts ...grpc.CallOption) (*BackendInfo, error)
|
||||
WatchTransitions(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[TransitionEvent], error)
|
||||
}
|
||||
|
||||
type healthCheckerClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewHealthCheckerClient(cc grpc.ClientConnInterface) HealthCheckerClient {
|
||||
return &healthCheckerClient{cc}
|
||||
}
|
||||
|
||||
func (c *healthCheckerClient) ListVIPs(ctx context.Context, in *ListVIPsRequest, opts ...grpc.CallOption) (*ListVIPsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListVIPsResponse)
|
||||
err := c.cc.Invoke(ctx, HealthChecker_ListVIPs_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *healthCheckerClient) GetVIP(ctx context.Context, in *GetVIPRequest, opts ...grpc.CallOption) (*VIPInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(VIPInfo)
|
||||
err := c.cc.Invoke(ctx, HealthChecker_GetVIP_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *healthCheckerClient) ListBackends(ctx context.Context, in *ListBackendsRequest, opts ...grpc.CallOption) (*ListBackendsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListBackendsResponse)
|
||||
err := c.cc.Invoke(ctx, HealthChecker_ListBackends_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *healthCheckerClient) GetBackend(ctx context.Context, in *GetBackendRequest, opts ...grpc.CallOption) (*BackendInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(BackendInfo)
|
||||
err := c.cc.Invoke(ctx, HealthChecker_GetBackend_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *healthCheckerClient) PauseBackend(ctx context.Context, in *PauseResumeRequest, opts ...grpc.CallOption) (*BackendInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(BackendInfo)
|
||||
err := c.cc.Invoke(ctx, HealthChecker_PauseBackend_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *healthCheckerClient) ResumeBackend(ctx context.Context, in *PauseResumeRequest, opts ...grpc.CallOption) (*BackendInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(BackendInfo)
|
||||
err := c.cc.Invoke(ctx, HealthChecker_ResumeBackend_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *healthCheckerClient) WatchTransitions(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[TransitionEvent], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &HealthChecker_ServiceDesc.Streams[0], HealthChecker_WatchTransitions_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[WatchRequest, TransitionEvent]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type HealthChecker_WatchTransitionsClient = grpc.ServerStreamingClient[TransitionEvent]
|
||||
|
||||
// HealthCheckerServer is the server API for HealthChecker service.
|
||||
// All implementations must embed UnimplementedHealthCheckerServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// HealthChecker exposes the state of backend health for all VIPs.
|
||||
type HealthCheckerServer interface {
|
||||
ListVIPs(context.Context, *ListVIPsRequest) (*ListVIPsResponse, error)
|
||||
GetVIP(context.Context, *GetVIPRequest) (*VIPInfo, error)
|
||||
ListBackends(context.Context, *ListBackendsRequest) (*ListBackendsResponse, error)
|
||||
GetBackend(context.Context, *GetBackendRequest) (*BackendInfo, error)
|
||||
PauseBackend(context.Context, *PauseResumeRequest) (*BackendInfo, error)
|
||||
ResumeBackend(context.Context, *PauseResumeRequest) (*BackendInfo, error)
|
||||
WatchTransitions(*WatchRequest, grpc.ServerStreamingServer[TransitionEvent]) error
|
||||
mustEmbedUnimplementedHealthCheckerServer()
|
||||
}
|
||||
|
||||
// UnimplementedHealthCheckerServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedHealthCheckerServer struct{}
|
||||
|
||||
func (UnimplementedHealthCheckerServer) ListVIPs(context.Context, *ListVIPsRequest) (*ListVIPsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListVIPs not implemented")
|
||||
}
|
||||
func (UnimplementedHealthCheckerServer) GetVIP(context.Context, *GetVIPRequest) (*VIPInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetVIP not implemented")
|
||||
}
|
||||
func (UnimplementedHealthCheckerServer) ListBackends(context.Context, *ListBackendsRequest) (*ListBackendsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListBackends not implemented")
|
||||
}
|
||||
func (UnimplementedHealthCheckerServer) GetBackend(context.Context, *GetBackendRequest) (*BackendInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetBackend not implemented")
|
||||
}
|
||||
func (UnimplementedHealthCheckerServer) PauseBackend(context.Context, *PauseResumeRequest) (*BackendInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method PauseBackend not implemented")
|
||||
}
|
||||
func (UnimplementedHealthCheckerServer) ResumeBackend(context.Context, *PauseResumeRequest) (*BackendInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ResumeBackend not implemented")
|
||||
}
|
||||
func (UnimplementedHealthCheckerServer) WatchTransitions(*WatchRequest, grpc.ServerStreamingServer[TransitionEvent]) error {
|
||||
return status.Error(codes.Unimplemented, "method WatchTransitions not implemented")
|
||||
}
|
||||
func (UnimplementedHealthCheckerServer) mustEmbedUnimplementedHealthCheckerServer() {}
|
||||
func (UnimplementedHealthCheckerServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeHealthCheckerServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to HealthCheckerServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeHealthCheckerServer interface {
|
||||
mustEmbedUnimplementedHealthCheckerServer()
|
||||
}
|
||||
|
||||
func RegisterHealthCheckerServer(s grpc.ServiceRegistrar, srv HealthCheckerServer) {
|
||||
// If the following call panics, it indicates UnimplementedHealthCheckerServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&HealthChecker_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _HealthChecker_ListVIPs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListVIPsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HealthCheckerServer).ListVIPs(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HealthChecker_ListVIPs_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HealthCheckerServer).ListVIPs(ctx, req.(*ListVIPsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HealthChecker_GetVIP_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetVIPRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HealthCheckerServer).GetVIP(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HealthChecker_GetVIP_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HealthCheckerServer).GetVIP(ctx, req.(*GetVIPRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HealthChecker_ListBackends_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListBackendsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HealthCheckerServer).ListBackends(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HealthChecker_ListBackends_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HealthCheckerServer).ListBackends(ctx, req.(*ListBackendsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HealthChecker_GetBackend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetBackendRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HealthCheckerServer).GetBackend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HealthChecker_GetBackend_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HealthCheckerServer).GetBackend(ctx, req.(*GetBackendRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HealthChecker_PauseBackend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PauseResumeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HealthCheckerServer).PauseBackend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HealthChecker_PauseBackend_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HealthCheckerServer).PauseBackend(ctx, req.(*PauseResumeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HealthChecker_ResumeBackend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PauseResumeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HealthCheckerServer).ResumeBackend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HealthChecker_ResumeBackend_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HealthCheckerServer).ResumeBackend(ctx, req.(*PauseResumeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HealthChecker_WatchTransitions_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(WatchRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(HealthCheckerServer).WatchTransitions(m, &grpc.GenericServerStream[WatchRequest, TransitionEvent]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type HealthChecker_WatchTransitionsServer = grpc.ServerStreamingServer[TransitionEvent]
|
||||
|
||||
// HealthChecker_ServiceDesc is the grpc.ServiceDesc for HealthChecker service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var HealthChecker_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "healthchecker.HealthChecker",
|
||||
HandlerType: (*HealthCheckerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "ListVIPs",
|
||||
Handler: _HealthChecker_ListVIPs_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetVIP",
|
||||
Handler: _HealthChecker_GetVIP_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListBackends",
|
||||
Handler: _HealthChecker_ListBackends_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBackend",
|
||||
Handler: _HealthChecker_GetBackend_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PauseBackend",
|
||||
Handler: _HealthChecker_PauseBackend_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ResumeBackend",
|
||||
Handler: _HealthChecker_ResumeBackend_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "WatchTransitions",
|
||||
Handler: _HealthChecker_WatchTransitions_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "proto/healthchecker.proto",
|
||||
}
|
||||
167
internal/grpcapi/server.go
Normal file
167
internal/grpcapi/server.go
Normal file
@@ -0,0 +1,167 @@
|
||||
package grpcapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"git.ipng.ch/ipng/vpp-maglev/internal/checker"
|
||||
"git.ipng.ch/ipng/vpp-maglev/internal/config"
|
||||
"git.ipng.ch/ipng/vpp-maglev/internal/health"
|
||||
)
|
||||
|
||||
// Server implements the HealthCheckerServer gRPC interface.
|
||||
type Server struct {
|
||||
UnimplementedHealthCheckerServer
|
||||
checker *checker.Checker
|
||||
}
|
||||
|
||||
// NewServer creates a Server backed by the given Checker.
|
||||
func NewServer(c *checker.Checker) *Server {
|
||||
return &Server{checker: c}
|
||||
}
|
||||
|
||||
// ListVIPs returns the names of all configured VIPs.
|
||||
func (s *Server) ListVIPs(_ context.Context, _ *ListVIPsRequest) (*ListVIPsResponse, error) {
|
||||
return &ListVIPsResponse{VipNames: s.checker.ListVIPs()}, nil
|
||||
}
|
||||
|
||||
// GetVIP returns configuration details for a single VIP.
|
||||
func (s *Server) GetVIP(_ context.Context, req *GetVIPRequest) (*VIPInfo, error) {
|
||||
vip, ok := s.checker.GetVIP(req.VipName)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "vip %q not found", req.VipName)
|
||||
}
|
||||
return vipToProto(req.VipName, vip), nil
|
||||
}
|
||||
|
||||
// ListBackends returns health state for all backends of a VIP.
|
||||
func (s *Server) ListBackends(_ context.Context, req *ListBackendsRequest) (*ListBackendsResponse, error) {
|
||||
if _, ok := s.checker.GetVIP(req.VipName); !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "vip %q not found", req.VipName)
|
||||
}
|
||||
backends := s.checker.ListBackends(req.VipName)
|
||||
resp := &ListBackendsResponse{}
|
||||
for _, b := range backends {
|
||||
resp.Backends = append(resp.Backends, backendToProto(b))
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetBackend returns health state for a specific VIP:backend tuple.
|
||||
func (s *Server) GetBackend(_ context.Context, req *GetBackendRequest) (*BackendInfo, error) {
|
||||
b, ok := s.checker.GetBackend(req.VipName, req.BackendAddress)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q in vip %q not found",
|
||||
req.BackendAddress, req.VipName)
|
||||
}
|
||||
return backendToProto(b), nil
|
||||
}
|
||||
|
||||
// PauseBackend pauses health checking for a specific backend.
|
||||
func (s *Server) PauseBackend(_ context.Context, req *PauseResumeRequest) (*BackendInfo, error) {
|
||||
b, ok := s.checker.PauseBackend(req.VipName, req.BackendAddress)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q in vip %q not found",
|
||||
req.BackendAddress, req.VipName)
|
||||
}
|
||||
return backendToProto(b), nil
|
||||
}
|
||||
|
||||
// ResumeBackend resumes health checking for a specific backend.
|
||||
func (s *Server) ResumeBackend(_ context.Context, req *PauseResumeRequest) (*BackendInfo, error) {
|
||||
b, ok := s.checker.ResumeBackend(req.VipName, req.BackendAddress)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q in vip %q not found",
|
||||
req.BackendAddress, req.VipName)
|
||||
}
|
||||
return backendToProto(b), nil
|
||||
}
|
||||
|
||||
// WatchTransitions streams the current state of all backends on connect, then
|
||||
// streams live state transitions until the client disconnects.
|
||||
func (s *Server) WatchTransitions(_ *WatchRequest, stream HealthChecker_WatchTransitionsServer) error {
|
||||
// Send current state of all backends as synthetic events.
|
||||
for _, vipName := range s.checker.ListVIPs() {
|
||||
for _, b := range s.checker.ListBackends(vipName) {
|
||||
ev := &TransitionEvent{
|
||||
VipName: vipName,
|
||||
BackendAddress: b.Address.String(),
|
||||
Transition: &TransitionRecord{
|
||||
From: b.State.String(),
|
||||
To: b.State.String(),
|
||||
AtUnixNs: 0,
|
||||
},
|
||||
}
|
||||
if err := stream.Send(ev); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Subscribe to live transitions.
|
||||
ch, unsub := s.checker.Subscribe()
|
||||
defer unsub()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-stream.Context().Done():
|
||||
return nil
|
||||
case e, ok := <-ch:
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
ev := &TransitionEvent{
|
||||
VipName: e.VIPName,
|
||||
BackendAddress: e.Backend.String(),
|
||||
Transition: transitionToProto(e.Transition),
|
||||
}
|
||||
if err := stream.Send(ev); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- conversion helpers ----------------------------------------------------
|
||||
|
||||
func vipToProto(name string, v config.VIP) *VIPInfo {
|
||||
info := &VIPInfo{
|
||||
Name: name,
|
||||
Address: v.Address.String(),
|
||||
Protocol: v.Protocol,
|
||||
Port: uint32(v.Port),
|
||||
Description: v.Description,
|
||||
}
|
||||
for _, b := range v.Backends {
|
||||
info.Backends = append(info.Backends, b.String())
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func backendToProto(b *health.Backend) *BackendInfo {
|
||||
info := &BackendInfo{
|
||||
VipName: b.VIPName,
|
||||
Address: b.Address.String(),
|
||||
State: b.State.String(),
|
||||
}
|
||||
for _, t := range b.Transitions {
|
||||
info.Transitions = append(info.Transitions, transitionToProto(t))
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func transitionToProto(t health.Transition) *TransitionRecord {
|
||||
return &TransitionRecord{
|
||||
From: t.From.String(),
|
||||
To: t.To.String(),
|
||||
AtUnixNs: t.At.UnixNano(),
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure net.IP is imported (used via b.Address.String()).
|
||||
var _ = net.IP{}
|
||||
var _ = fmt.Sprintf
|
||||
188
internal/grpcapi/server_test.go
Normal file
188
internal/grpcapi/server_test.go
Normal file
@@ -0,0 +1,188 @@
|
||||
package grpcapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
"git.ipng.ch/ipng/vpp-maglev/internal/checker"
|
||||
"git.ipng.ch/ipng/vpp-maglev/internal/config"
|
||||
"git.ipng.ch/ipng/vpp-maglev/internal/health"
|
||||
)
|
||||
|
||||
func makeTestChecker(ctx context.Context) *checker.Checker {
|
||||
cfg := &config.Frontend{
|
||||
HealthCheckNetns: "test",
|
||||
HealthChecker: config.HealthCheckerConfig{TransitionHistory: 5},
|
||||
VIPs: map[string]config.VIP{
|
||||
"web": {
|
||||
Address: net.ParseIP("192.0.2.1"),
|
||||
Protocol: "tcp",
|
||||
Port: 80,
|
||||
Backends: []net.IP{net.ParseIP("10.0.0.2")},
|
||||
HealthCheck: config.HealthCheck{
|
||||
Type: "icmp",
|
||||
Interval: time.Hour, // long interval: probes won't fire during tests
|
||||
Timeout: time.Second,
|
||||
Fall: 3,
|
||||
Rise: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
c := checker.New(cfg)
|
||||
go c.Run(ctx) //nolint:errcheck
|
||||
// Allow the Run goroutine to initialize workers.
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
return c
|
||||
}
|
||||
|
||||
func startTestServer(t *testing.T, c *checker.Checker) (HealthCheckerClient, func()) {
|
||||
t.Helper()
|
||||
lis, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatalf("listen: %v", err)
|
||||
}
|
||||
srv := grpc.NewServer()
|
||||
RegisterHealthCheckerServer(srv, NewServer(c))
|
||||
go srv.Serve(lis) //nolint:errcheck
|
||||
|
||||
conn, err := grpc.NewClient(lis.Addr().String(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("dial: %v", err)
|
||||
}
|
||||
return NewHealthCheckerClient(conn), func() {
|
||||
conn.Close()
|
||||
srv.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
func TestListVIPs(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
resp, err := client.ListVIPs(ctx, &ListVIPsRequest{})
|
||||
if err != nil {
|
||||
t.Fatalf("ListVIPs: %v", err)
|
||||
}
|
||||
if len(resp.VipNames) != 1 || resp.VipNames[0] != "web" {
|
||||
t.Errorf("ListVIPs: got %v, want [web]", resp.VipNames)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetVIP(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
info, err := client.GetVIP(ctx, &GetVIPRequest{VipName: "web"})
|
||||
if err != nil {
|
||||
t.Fatalf("GetVIP: %v", err)
|
||||
}
|
||||
if info.Address != "192.0.2.1" {
|
||||
t.Errorf("GetVIP address: got %q, want 192.0.2.1", info.Address)
|
||||
}
|
||||
if info.Port != 80 {
|
||||
t.Errorf("GetVIP port: got %d, want 80", info.Port)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetVIPNotFound(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
_, err := client.GetVIP(ctx, &GetVIPRequest{VipName: "nope"})
|
||||
if err == nil {
|
||||
t.Error("expected error for unknown VIP")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBackend(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
info, err := client.GetBackend(ctx, &GetBackendRequest{
|
||||
VipName: "web",
|
||||
BackendAddress: "10.0.0.2",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("GetBackend: %v", err)
|
||||
}
|
||||
if info.State != health.StateUnknown.String() {
|
||||
t.Errorf("initial state: got %q, want unknown", info.State)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPauseResumeBackend(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
info, err := client.PauseBackend(ctx, &PauseResumeRequest{
|
||||
VipName: "web",
|
||||
BackendAddress: "10.0.0.2",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("PauseBackend: %v", err)
|
||||
}
|
||||
if info.State != health.StatePaused.String() {
|
||||
t.Errorf("after pause: got %q, want paused", info.State)
|
||||
}
|
||||
|
||||
info, err = client.ResumeBackend(ctx, &PauseResumeRequest{
|
||||
VipName: "web",
|
||||
BackendAddress: "10.0.0.2",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("ResumeBackend: %v", err)
|
||||
}
|
||||
if info.State != health.StateUnknown.String() {
|
||||
t.Errorf("after resume: got %q, want unknown", info.State)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWatchTransitions(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
stream, err := client.WatchTransitions(ctx, &WatchRequest{})
|
||||
if err != nil {
|
||||
t.Fatalf("WatchTransitions: %v", err)
|
||||
}
|
||||
|
||||
// Should receive the current state for web:10.0.0.2 immediately.
|
||||
ev, err := stream.Recv()
|
||||
if err != nil {
|
||||
t.Fatalf("Recv: %v", err)
|
||||
}
|
||||
if ev.VipName != "web" || ev.BackendAddress != "10.0.0.2" {
|
||||
t.Errorf("initial event: vip=%q backend=%q", ev.VipName, ev.BackendAddress)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user