Revision: Rename to 'maglevd'; Refactor config structure
This commit is contained in:
@@ -1,776 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
// 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",
|
||||
}
|
||||
1232
internal/grpcapi/maglev.pb.go
Normal file
1232
internal/grpcapi/maglev.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
433
internal/grpcapi/maglev_grpc.pb.go
Normal file
433
internal/grpcapi/maglev_grpc.pb.go
Normal file
@@ -0,0 +1,433 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v3.21.12
|
||||
// source: proto/maglev.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 (
|
||||
Maglev_ListFrontends_FullMethodName = "/maglev.Maglev/ListFrontends"
|
||||
Maglev_GetFrontend_FullMethodName = "/maglev.Maglev/GetFrontend"
|
||||
Maglev_ListBackends_FullMethodName = "/maglev.Maglev/ListBackends"
|
||||
Maglev_GetBackend_FullMethodName = "/maglev.Maglev/GetBackend"
|
||||
Maglev_PauseBackend_FullMethodName = "/maglev.Maglev/PauseBackend"
|
||||
Maglev_ResumeBackend_FullMethodName = "/maglev.Maglev/ResumeBackend"
|
||||
Maglev_ListHealthChecks_FullMethodName = "/maglev.Maglev/ListHealthChecks"
|
||||
Maglev_GetHealthCheck_FullMethodName = "/maglev.Maglev/GetHealthCheck"
|
||||
Maglev_WatchBackendEvents_FullMethodName = "/maglev.Maglev/WatchBackendEvents"
|
||||
)
|
||||
|
||||
// MaglevClient is the client API for Maglev 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.
|
||||
//
|
||||
// Maglev exposes the state of backend health for all frontends.
|
||||
type MaglevClient interface {
|
||||
ListFrontends(ctx context.Context, in *ListFrontendsRequest, opts ...grpc.CallOption) (*ListFrontendsResponse, error)
|
||||
GetFrontend(ctx context.Context, in *GetFrontendRequest, opts ...grpc.CallOption) (*FrontendInfo, 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)
|
||||
ListHealthChecks(ctx context.Context, in *ListHealthChecksRequest, opts ...grpc.CallOption) (*ListHealthChecksResponse, error)
|
||||
GetHealthCheck(ctx context.Context, in *GetHealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckInfo, error)
|
||||
WatchBackendEvents(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[BackendEvent], error)
|
||||
}
|
||||
|
||||
type maglevClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewMaglevClient(cc grpc.ClientConnInterface) MaglevClient {
|
||||
return &maglevClient{cc}
|
||||
}
|
||||
|
||||
func (c *maglevClient) ListFrontends(ctx context.Context, in *ListFrontendsRequest, opts ...grpc.CallOption) (*ListFrontendsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListFrontendsResponse)
|
||||
err := c.cc.Invoke(ctx, Maglev_ListFrontends_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) GetFrontend(ctx context.Context, in *GetFrontendRequest, opts ...grpc.CallOption) (*FrontendInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(FrontendInfo)
|
||||
err := c.cc.Invoke(ctx, Maglev_GetFrontend_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) 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, Maglev_ListBackends_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) 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, Maglev_GetBackend_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) 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, Maglev_PauseBackend_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) 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, Maglev_ResumeBackend_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) ListHealthChecks(ctx context.Context, in *ListHealthChecksRequest, opts ...grpc.CallOption) (*ListHealthChecksResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListHealthChecksResponse)
|
||||
err := c.cc.Invoke(ctx, Maglev_ListHealthChecks_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) GetHealthCheck(ctx context.Context, in *GetHealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(HealthCheckInfo)
|
||||
err := c.cc.Invoke(ctx, Maglev_GetHealthCheck_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *maglevClient) WatchBackendEvents(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[BackendEvent], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &Maglev_ServiceDesc.Streams[0], Maglev_WatchBackendEvents_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[WatchRequest, BackendEvent]{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 Maglev_WatchBackendEventsClient = grpc.ServerStreamingClient[BackendEvent]
|
||||
|
||||
// MaglevServer is the server API for Maglev service.
|
||||
// All implementations must embed UnimplementedMaglevServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// Maglev exposes the state of backend health for all frontends.
|
||||
type MaglevServer interface {
|
||||
ListFrontends(context.Context, *ListFrontendsRequest) (*ListFrontendsResponse, error)
|
||||
GetFrontend(context.Context, *GetFrontendRequest) (*FrontendInfo, 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)
|
||||
ListHealthChecks(context.Context, *ListHealthChecksRequest) (*ListHealthChecksResponse, error)
|
||||
GetHealthCheck(context.Context, *GetHealthCheckRequest) (*HealthCheckInfo, error)
|
||||
WatchBackendEvents(*WatchRequest, grpc.ServerStreamingServer[BackendEvent]) error
|
||||
mustEmbedUnimplementedMaglevServer()
|
||||
}
|
||||
|
||||
// UnimplementedMaglevServer 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 UnimplementedMaglevServer struct{}
|
||||
|
||||
func (UnimplementedMaglevServer) ListFrontends(context.Context, *ListFrontendsRequest) (*ListFrontendsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListFrontends not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) GetFrontend(context.Context, *GetFrontendRequest) (*FrontendInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetFrontend not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) ListBackends(context.Context, *ListBackendsRequest) (*ListBackendsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListBackends not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) GetBackend(context.Context, *GetBackendRequest) (*BackendInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetBackend not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) PauseBackend(context.Context, *PauseResumeRequest) (*BackendInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method PauseBackend not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) ResumeBackend(context.Context, *PauseResumeRequest) (*BackendInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ResumeBackend not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) ListHealthChecks(context.Context, *ListHealthChecksRequest) (*ListHealthChecksResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListHealthChecks not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) GetHealthCheck(context.Context, *GetHealthCheckRequest) (*HealthCheckInfo, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetHealthCheck not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) WatchBackendEvents(*WatchRequest, grpc.ServerStreamingServer[BackendEvent]) error {
|
||||
return status.Error(codes.Unimplemented, "method WatchBackendEvents not implemented")
|
||||
}
|
||||
func (UnimplementedMaglevServer) mustEmbedUnimplementedMaglevServer() {}
|
||||
func (UnimplementedMaglevServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeMaglevServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to MaglevServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeMaglevServer interface {
|
||||
mustEmbedUnimplementedMaglevServer()
|
||||
}
|
||||
|
||||
func RegisterMaglevServer(s grpc.ServiceRegistrar, srv MaglevServer) {
|
||||
// If the following call panics, it indicates UnimplementedMaglevServer 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(&Maglev_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Maglev_ListFrontends_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListFrontendsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MaglevServer).ListFrontends(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_ListFrontends_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).ListFrontends(ctx, req.(*ListFrontendsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_GetFrontend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetFrontendRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MaglevServer).GetFrontend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_GetFrontend_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).GetFrontend(ctx, req.(*GetFrontendRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_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.(MaglevServer).ListBackends(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_ListBackends_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).ListBackends(ctx, req.(*ListBackendsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_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.(MaglevServer).GetBackend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_GetBackend_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).GetBackend(ctx, req.(*GetBackendRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_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.(MaglevServer).PauseBackend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_PauseBackend_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).PauseBackend(ctx, req.(*PauseResumeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_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.(MaglevServer).ResumeBackend(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_ResumeBackend_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).ResumeBackend(ctx, req.(*PauseResumeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_ListHealthChecks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListHealthChecksRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MaglevServer).ListHealthChecks(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_ListHealthChecks_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).ListHealthChecks(ctx, req.(*ListHealthChecksRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_GetHealthCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetHealthCheckRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MaglevServer).GetHealthCheck(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Maglev_GetHealthCheck_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MaglevServer).GetHealthCheck(ctx, req.(*GetHealthCheckRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Maglev_WatchBackendEvents_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(WatchRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(MaglevServer).WatchBackendEvents(m, &grpc.GenericServerStream[WatchRequest, BackendEvent]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type Maglev_WatchBackendEventsServer = grpc.ServerStreamingServer[BackendEvent]
|
||||
|
||||
// Maglev_ServiceDesc is the grpc.ServiceDesc for Maglev service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Maglev_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "maglev.Maglev",
|
||||
HandlerType: (*MaglevServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "ListFrontends",
|
||||
Handler: _Maglev_ListFrontends_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetFrontend",
|
||||
Handler: _Maglev_GetFrontend_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListBackends",
|
||||
Handler: _Maglev_ListBackends_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBackend",
|
||||
Handler: _Maglev_GetBackend_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PauseBackend",
|
||||
Handler: _Maglev_PauseBackend_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ResumeBackend",
|
||||
Handler: _Maglev_ResumeBackend_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListHealthChecks",
|
||||
Handler: _Maglev_ListHealthChecks_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetHealthCheck",
|
||||
Handler: _Maglev_GetHealthCheck_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "WatchBackendEvents",
|
||||
Handler: _Maglev_WatchBackendEvents_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "proto/maglev.proto",
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package grpcapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -13,9 +12,9 @@ import (
|
||||
"git.ipng.ch/ipng/vpp-maglev/internal/health"
|
||||
)
|
||||
|
||||
// Server implements the HealthCheckerServer gRPC interface.
|
||||
// Server implements the MaglevServer gRPC interface.
|
||||
type Server struct {
|
||||
UnimplementedHealthCheckerServer
|
||||
UnimplementedMaglevServer
|
||||
checker *checker.Checker
|
||||
}
|
||||
|
||||
@@ -24,85 +23,88 @@ 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
|
||||
// ListFrontends returns the names of all configured frontends.
|
||||
func (s *Server) ListFrontends(_ context.Context, _ *ListFrontendsRequest) (*ListFrontendsResponse, error) {
|
||||
return &ListFrontendsResponse{FrontendNames: s.checker.ListFrontends()}, 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)
|
||||
// GetFrontend returns configuration details for a single frontend.
|
||||
func (s *Server) GetFrontend(_ context.Context, req *GetFrontendRequest) (*FrontendInfo, error) {
|
||||
fe, ok := s.checker.GetFrontend(req.Name)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "vip %q not found", req.VipName)
|
||||
return nil, status.Errorf(codes.NotFound, "frontend %q not found", req.Name)
|
||||
}
|
||||
return vipToProto(req.VipName, vip), nil
|
||||
return frontendToProto(req.Name, fe), 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
|
||||
// ListBackends returns the names of all active backends.
|
||||
func (s *Server) ListBackends(_ context.Context, _ *ListBackendsRequest) (*ListBackendsResponse, error) {
|
||||
return &ListBackendsResponse{BackendNames: s.checker.ListBackends()}, nil
|
||||
}
|
||||
|
||||
// GetBackend returns health state for a specific VIP:backend tuple.
|
||||
// GetBackend returns health state for a backend by name.
|
||||
func (s *Server) GetBackend(_ context.Context, req *GetBackendRequest) (*BackendInfo, error) {
|
||||
b, ok := s.checker.GetBackend(req.VipName, req.BackendAddress)
|
||||
b, ok := s.checker.GetBackend(req.Name)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q in vip %q not found",
|
||||
req.BackendAddress, req.VipName)
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q not found", req.Name)
|
||||
}
|
||||
return backendToProto(b), nil
|
||||
}
|
||||
|
||||
// PauseBackend pauses health checking for a specific backend.
|
||||
// PauseBackend pauses health checking for a backend by name.
|
||||
func (s *Server) PauseBackend(_ context.Context, req *PauseResumeRequest) (*BackendInfo, error) {
|
||||
b, ok := s.checker.PauseBackend(req.VipName, req.BackendAddress)
|
||||
b, ok := s.checker.PauseBackend(req.Name)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q in vip %q not found",
|
||||
req.BackendAddress, req.VipName)
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q not found", req.Name)
|
||||
}
|
||||
return backendToProto(b), nil
|
||||
}
|
||||
|
||||
// ResumeBackend resumes health checking for a specific backend.
|
||||
// ResumeBackend resumes health checking for a backend by name.
|
||||
func (s *Server) ResumeBackend(_ context.Context, req *PauseResumeRequest) (*BackendInfo, error) {
|
||||
b, ok := s.checker.ResumeBackend(req.VipName, req.BackendAddress)
|
||||
b, ok := s.checker.ResumeBackend(req.Name)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q in vip %q not found",
|
||||
req.BackendAddress, req.VipName)
|
||||
return nil, status.Errorf(codes.NotFound, "backend %q not found", req.Name)
|
||||
}
|
||||
return backendToProto(b), nil
|
||||
}
|
||||
|
||||
// WatchTransitions streams the current state of all backends on connect, then
|
||||
// ListHealthChecks returns the names of all configured health checks.
|
||||
func (s *Server) ListHealthChecks(_ context.Context, _ *ListHealthChecksRequest) (*ListHealthChecksResponse, error) {
|
||||
return &ListHealthChecksResponse{Names: s.checker.ListHealthChecks()}, nil
|
||||
}
|
||||
|
||||
// GetHealthCheck returns the full configuration for a health check by name.
|
||||
func (s *Server) GetHealthCheck(_ context.Context, req *GetHealthCheckRequest) (*HealthCheckInfo, error) {
|
||||
hc, ok := s.checker.GetHealthCheck(req.Name)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "healthcheck %q not found", req.Name)
|
||||
}
|
||||
return healthCheckToProto(req.Name, hc), nil
|
||||
}
|
||||
|
||||
// WatchBackendEvents 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 {
|
||||
func (s *Server) WatchBackendEvents(_ *WatchRequest, stream Maglev_WatchBackendEventsServer) 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
|
||||
}
|
||||
for _, name := range s.checker.ListBackends() {
|
||||
snap, ok := s.checker.GetBackend(name)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
ev := &BackendEvent{
|
||||
BackendName: name,
|
||||
Transition: &TransitionRecord{
|
||||
From: snap.Health.State.String(),
|
||||
To: snap.Health.State.String(),
|
||||
AtUnixNs: 0,
|
||||
},
|
||||
}
|
||||
if err := stream.Send(ev); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Subscribe to live transitions.
|
||||
ch, unsub := s.checker.Subscribe()
|
||||
defer unsub()
|
||||
|
||||
@@ -114,10 +116,9 @@ func (s *Server) WatchTransitions(_ *WatchRequest, stream HealthChecker_WatchTra
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
ev := &TransitionEvent{
|
||||
VipName: e.VIPName,
|
||||
BackendAddress: e.Backend.String(),
|
||||
Transition: transitionToProto(e.Transition),
|
||||
ev := &BackendEvent{
|
||||
BackendName: e.BackendName,
|
||||
Transition: transitionToProto(e.Transition),
|
||||
}
|
||||
if err := stream.Send(ev); err != nil {
|
||||
return err
|
||||
@@ -128,28 +129,71 @@ func (s *Server) WatchTransitions(_ *WatchRequest, stream HealthChecker_WatchTra
|
||||
|
||||
// ---- 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,
|
||||
func frontendToProto(name string, fe config.Frontend) *FrontendInfo {
|
||||
return &FrontendInfo{
|
||||
Name: name,
|
||||
Address: fe.Address.String(),
|
||||
Protocol: fe.Protocol,
|
||||
Port: uint32(fe.Port),
|
||||
Description: fe.Description,
|
||||
BackendNames: fe.Backends,
|
||||
}
|
||||
for _, b := range v.Backends {
|
||||
info.Backends = append(info.Backends, b.String())
|
||||
}
|
||||
|
||||
func backendToProto(snap checker.BackendSnapshot) *BackendInfo {
|
||||
info := &BackendInfo{
|
||||
Name: snap.Health.Name,
|
||||
Address: snap.Health.Address.String(),
|
||||
State: snap.Health.State.String(),
|
||||
Enabled: snap.Config.Enabled,
|
||||
Weight: int32(snap.Config.Weight),
|
||||
Healthcheck: snap.Config.HealthCheck,
|
||||
}
|
||||
for _, t := range snap.Health.Transitions {
|
||||
info.Transitions = append(info.Transitions, transitionToProto(t))
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func backendToProto(b *health.Backend) *BackendInfo {
|
||||
info := &BackendInfo{
|
||||
VipName: b.VIPName,
|
||||
Address: b.Address.String(),
|
||||
State: b.State.String(),
|
||||
func healthCheckToProto(name string, hc config.HealthCheck) *HealthCheckInfo {
|
||||
info := &HealthCheckInfo{
|
||||
Name: name,
|
||||
Type: hc.Type,
|
||||
Port: uint32(hc.Port),
|
||||
IntervalNs: hc.Interval.Nanoseconds(),
|
||||
FastIntervalNs: hc.FastInterval.Nanoseconds(),
|
||||
DownIntervalNs: hc.DownInterval.Nanoseconds(),
|
||||
TimeoutNs: hc.Timeout.Nanoseconds(),
|
||||
Rise: int32(hc.Rise),
|
||||
Fall: int32(hc.Fall),
|
||||
}
|
||||
for _, t := range b.Transitions {
|
||||
info.Transitions = append(info.Transitions, transitionToProto(t))
|
||||
if hc.ProbeIPv4Src != nil {
|
||||
info.ProbeIpv4Src = hc.ProbeIPv4Src.String()
|
||||
}
|
||||
if hc.ProbeIPv6Src != nil {
|
||||
info.ProbeIpv6Src = hc.ProbeIPv6Src.String()
|
||||
}
|
||||
if hc.HTTP != nil {
|
||||
re := ""
|
||||
if hc.HTTP.ResponseRegexp != nil {
|
||||
re = hc.HTTP.ResponseRegexp.String()
|
||||
}
|
||||
info.Http = &HTTPCheckParams{
|
||||
Path: hc.HTTP.Path,
|
||||
Host: hc.HTTP.Host,
|
||||
ResponseCodeMin: int32(hc.HTTP.ResponseCodeMin),
|
||||
ResponseCodeMax: int32(hc.HTTP.ResponseCodeMax),
|
||||
ResponseRegexp: re,
|
||||
ServerName: hc.HTTP.ServerName,
|
||||
InsecureSkipVerify: hc.HTTP.InsecureSkipVerify,
|
||||
}
|
||||
}
|
||||
if hc.TCP != nil {
|
||||
info.Tcp = &TCPCheckParams{
|
||||
Ssl: hc.TCP.SSL,
|
||||
ServerName: hc.TCP.ServerName,
|
||||
InsecureSkipVerify: hc.TCP.InsecureSkipVerify,
|
||||
}
|
||||
}
|
||||
return info
|
||||
}
|
||||
@@ -164,4 +208,3 @@ func transitionToProto(t health.Transition) *TransitionRecord {
|
||||
|
||||
// Ensure net.IP is imported (used via b.Address.String()).
|
||||
var _ = net.IP{}
|
||||
var _ = fmt.Sprintf
|
||||
|
||||
@@ -15,22 +15,31 @@ import (
|
||||
)
|
||||
|
||||
func makeTestChecker(ctx context.Context) *checker.Checker {
|
||||
cfg := &config.Frontend{
|
||||
HealthCheckNetns: "test",
|
||||
HealthChecker: config.HealthCheckerConfig{TransitionHistory: 5},
|
||||
VIPs: map[string]config.VIP{
|
||||
cfg := &config.Config{
|
||||
HealthChecker: config.HealthCheckerConfig{TransitionHistory: 5},
|
||||
HealthChecks: map[string]config.HealthCheck{
|
||||
"icmp": {
|
||||
Type: "icmp",
|
||||
Interval: time.Hour, // long interval: probes won't fire during tests
|
||||
Timeout: time.Second,
|
||||
Fall: 3,
|
||||
Rise: 2,
|
||||
},
|
||||
},
|
||||
Backends: map[string]config.Backend{
|
||||
"be0": {
|
||||
Address: net.ParseIP("10.0.0.2"),
|
||||
HealthCheck: "icmp",
|
||||
Enabled: true,
|
||||
Weight: 100,
|
||||
},
|
||||
},
|
||||
Frontends: map[string]config.Frontend{
|
||||
"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,
|
||||
},
|
||||
Backends: []string{"be0"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -41,14 +50,14 @@ func makeTestChecker(ctx context.Context) *checker.Checker {
|
||||
return c
|
||||
}
|
||||
|
||||
func startTestServer(t *testing.T, c *checker.Checker) (HealthCheckerClient, func()) {
|
||||
func startTestServer(t *testing.T, c *checker.Checker) (MaglevClient, 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))
|
||||
RegisterMaglevServer(srv, NewServer(c))
|
||||
go srv.Serve(lis) //nolint:errcheck
|
||||
|
||||
conn, err := grpc.NewClient(lis.Addr().String(),
|
||||
@@ -56,13 +65,13 @@ func startTestServer(t *testing.T, c *checker.Checker) (HealthCheckerClient, fun
|
||||
if err != nil {
|
||||
t.Fatalf("dial: %v", err)
|
||||
}
|
||||
return NewHealthCheckerClient(conn), func() {
|
||||
return NewMaglevClient(conn), func() {
|
||||
conn.Close()
|
||||
srv.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
func TestListVIPs(t *testing.T) {
|
||||
func TestListFrontends(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
@@ -70,16 +79,16 @@ func TestListVIPs(t *testing.T) {
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
resp, err := client.ListVIPs(ctx, &ListVIPsRequest{})
|
||||
resp, err := client.ListFrontends(ctx, &ListFrontendsRequest{})
|
||||
if err != nil {
|
||||
t.Fatalf("ListVIPs: %v", err)
|
||||
t.Fatalf("ListFrontends: %v", err)
|
||||
}
|
||||
if len(resp.VipNames) != 1 || resp.VipNames[0] != "web" {
|
||||
t.Errorf("ListVIPs: got %v, want [web]", resp.VipNames)
|
||||
if len(resp.FrontendNames) != 1 || resp.FrontendNames[0] != "web" {
|
||||
t.Errorf("ListFrontends: got %v, want [web]", resp.FrontendNames)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetVIP(t *testing.T) {
|
||||
func TestGetFrontend(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
@@ -87,19 +96,22 @@ func TestGetVIP(t *testing.T) {
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
info, err := client.GetVIP(ctx, &GetVIPRequest{VipName: "web"})
|
||||
info, err := client.GetFrontend(ctx, &GetFrontendRequest{Name:"web"})
|
||||
if err != nil {
|
||||
t.Fatalf("GetVIP: %v", err)
|
||||
t.Fatalf("GetFrontend: %v", err)
|
||||
}
|
||||
if info.Address != "192.0.2.1" {
|
||||
t.Errorf("GetVIP address: got %q, want 192.0.2.1", info.Address)
|
||||
t.Errorf("GetFrontend address: got %q, want 192.0.2.1", info.Address)
|
||||
}
|
||||
if info.Port != 80 {
|
||||
t.Errorf("GetVIP port: got %d, want 80", info.Port)
|
||||
t.Errorf("GetFrontend port: got %d, want 80", info.Port)
|
||||
}
|
||||
if len(info.BackendNames) != 1 || info.BackendNames[0] != "be0" {
|
||||
t.Errorf("GetFrontend backend_names: got %v, want [be0]", info.BackendNames)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetVIPNotFound(t *testing.T) {
|
||||
func TestGetFrontendNotFound(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
@@ -107,9 +119,26 @@ func TestGetVIPNotFound(t *testing.T) {
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
_, err := client.GetVIP(ctx, &GetVIPRequest{VipName: "nope"})
|
||||
_, err := client.GetFrontend(ctx, &GetFrontendRequest{Name:"nope"})
|
||||
if err == nil {
|
||||
t.Error("expected error for unknown VIP")
|
||||
t.Error("expected error for unknown frontend")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListBackends(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
resp, err := client.ListBackends(ctx, &ListBackendsRequest{})
|
||||
if err != nil {
|
||||
t.Fatalf("ListBackends: %v", err)
|
||||
}
|
||||
if len(resp.BackendNames) != 1 || resp.BackendNames[0] != "be0" {
|
||||
t.Errorf("ListBackends: got %v, want [be0]", resp.BackendNames)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,16 +150,36 @@ func TestGetBackend(t *testing.T) {
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
info, err := client.GetBackend(ctx, &GetBackendRequest{
|
||||
VipName: "web",
|
||||
BackendAddress: "10.0.0.2",
|
||||
})
|
||||
info, err := client.GetBackend(ctx, &GetBackendRequest{Name:"be0"})
|
||||
if err != nil {
|
||||
t.Fatalf("GetBackend: %v", err)
|
||||
}
|
||||
if info.State != health.StateUnknown.String() {
|
||||
t.Errorf("initial state: got %q, want unknown", info.State)
|
||||
}
|
||||
if !info.Enabled {
|
||||
t.Error("expected enabled=true")
|
||||
}
|
||||
if info.Weight != 100 {
|
||||
t.Errorf("weight: got %d, want 100", info.Weight)
|
||||
}
|
||||
if info.Healthcheck != "icmp" {
|
||||
t.Errorf("healthcheck: got %q, want icmp", info.Healthcheck)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBackendNotFound(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
_, err := client.GetBackend(ctx, &GetBackendRequest{Name:"nope"})
|
||||
if err == nil {
|
||||
t.Error("expected error for unknown backend")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPauseResumeBackend(t *testing.T) {
|
||||
@@ -141,10 +190,7 @@ func TestPauseResumeBackend(t *testing.T) {
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
info, err := client.PauseBackend(ctx, &PauseResumeRequest{
|
||||
VipName: "web",
|
||||
BackendAddress: "10.0.0.2",
|
||||
})
|
||||
info, err := client.PauseBackend(ctx, &PauseResumeRequest{Name:"be0"})
|
||||
if err != nil {
|
||||
t.Fatalf("PauseBackend: %v", err)
|
||||
}
|
||||
@@ -152,10 +198,7 @@ func TestPauseResumeBackend(t *testing.T) {
|
||||
t.Errorf("after pause: got %q, want paused", info.State)
|
||||
}
|
||||
|
||||
info, err = client.ResumeBackend(ctx, &PauseResumeRequest{
|
||||
VipName: "web",
|
||||
BackendAddress: "10.0.0.2",
|
||||
})
|
||||
info, err = client.ResumeBackend(ctx, &PauseResumeRequest{Name:"be0"})
|
||||
if err != nil {
|
||||
t.Fatalf("ResumeBackend: %v", err)
|
||||
}
|
||||
@@ -164,7 +207,7 @@ func TestPauseResumeBackend(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWatchTransitions(t *testing.T) {
|
||||
func TestListHealthChecks(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
@@ -172,17 +215,68 @@ func TestWatchTransitions(t *testing.T) {
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
stream, err := client.WatchTransitions(ctx, &WatchRequest{})
|
||||
resp, err := client.ListHealthChecks(ctx, &ListHealthChecksRequest{})
|
||||
if err != nil {
|
||||
t.Fatalf("WatchTransitions: %v", err)
|
||||
t.Fatalf("ListHealthChecks: %v", err)
|
||||
}
|
||||
if len(resp.Names) != 1 || resp.Names[0] != "icmp" {
|
||||
t.Errorf("ListHealthChecks: got %v, want [icmp]", resp.Names)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetHealthCheck(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
info, err := client.GetHealthCheck(ctx, &GetHealthCheckRequest{Name: "icmp"})
|
||||
if err != nil {
|
||||
t.Fatalf("GetHealthCheck: %v", err)
|
||||
}
|
||||
if info.Type != "icmp" {
|
||||
t.Errorf("type: got %q, want icmp", info.Type)
|
||||
}
|
||||
if info.Fall != 3 || info.Rise != 2 {
|
||||
t.Errorf("fall/rise: got %d/%d, want 3/2", info.Fall, info.Rise)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetHealthCheckNotFound(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
_, err := client.GetHealthCheck(ctx, &GetHealthCheckRequest{Name: "nope"})
|
||||
if err == nil {
|
||||
t.Error("expected error for unknown healthcheck")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWatchBackendEvents(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
c := makeTestChecker(ctx)
|
||||
client, cleanup := startTestServer(t, c)
|
||||
defer cleanup()
|
||||
|
||||
stream, err := client.WatchBackendEvents(ctx, &WatchRequest{})
|
||||
if err != nil {
|
||||
t.Fatalf("WatchBackendEvents: %v", err)
|
||||
}
|
||||
|
||||
// Should receive the current state for web:10.0.0.2 immediately.
|
||||
// Should receive the current state for be0 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)
|
||||
if ev.BackendName != "be0" {
|
||||
t.Errorf("initial event: backend=%q, want be0", ev.BackendName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user