api

package
v0.0.0-...-6753df2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SDK_Ready_FullMethodName           = "/github.com.kidecar.SDK/Ready"
	SDK_Shutdown_FullMethodName        = "/github.com.kidecar.SDK/Shutdown"
	SDK_SetLabel_FullMethodName        = "/github.com.kidecar.SDK/SetLabel"
	SDK_GetLabel_FullMethodName        = "/github.com.kidecar.SDK/GetLabel"
	SDK_SetAnnotation_FullMethodName   = "/github.com.kidecar.SDK/SetAnnotation"
	SDK_GetAnnotation_FullMethodName   = "/github.com.kidecar.SDK/GetAnnotation"
	SDK_Allocate_FullMethodName        = "/github.com.kidecar.SDK/Allocate"
	SDK_Reserve_FullMethodName         = "/github.com.kidecar.SDK/Reserve"
	SDK_SetCapacity_FullMethodName     = "/github.com.kidecar.SDK/SetCapacity"
	SDK_GetNetworkState_FullMethodName = "/github.com.kidecar.SDK/GetNetworkState"
	SDK_SetPriority_FullMethodName     = "/github.com.kidecar.SDK/SetPriority"
	SDK_GetPriority_FullMethodName     = "/github.com.kidecar.SDK/GetPriority"
)

Variables

View Source
var File_api_proto_sdk_proto protoreflect.FileDescriptor
View Source
var SDK_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "github.com.kidecar.SDK",
	HandlerType: (*SDKServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Ready",
			Handler:    _SDK_Ready_Handler,
		},
		{
			MethodName: "Shutdown",
			Handler:    _SDK_Shutdown_Handler,
		},
		{
			MethodName: "SetLabel",
			Handler:    _SDK_SetLabel_Handler,
		},
		{
			MethodName: "GetLabel",
			Handler:    _SDK_GetLabel_Handler,
		},
		{
			MethodName: "SetAnnotation",
			Handler:    _SDK_SetAnnotation_Handler,
		},
		{
			MethodName: "GetAnnotation",
			Handler:    _SDK_GetAnnotation_Handler,
		},
		{
			MethodName: "Allocate",
			Handler:    _SDK_Allocate_Handler,
		},
		{
			MethodName: "Reserve",
			Handler:    _SDK_Reserve_Handler,
		},
		{
			MethodName: "SetCapacity",
			Handler:    _SDK_SetCapacity_Handler,
		},
		{
			MethodName: "GetNetworkState",
			Handler:    _SDK_GetNetworkState_Handler,
		},
		{
			MethodName: "SetPriority",
			Handler:    _SDK_SetPriority_Handler,
		},
		{
			MethodName: "GetPriority",
			Handler:    _SDK_GetPriority_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "api/proto/sdk.proto",
}

SDK_ServiceDesc is the grpc.ServiceDesc for SDK service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterSDKServer

func RegisterSDKServer(s grpc.ServiceRegistrar, srv SDKServer)

Types

type AllocateRequest

type AllocateRequest struct {
	ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"`
	// contains filtered or unexported fields
}

资源分配与预留

func (*AllocateRequest) Descriptor deprecated

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

Deprecated: Use AllocateRequest.ProtoReflect.Descriptor instead.

func (*AllocateRequest) GetResourceId

func (x *AllocateRequest) GetResourceId() string

func (*AllocateRequest) ProtoMessage

func (*AllocateRequest) ProtoMessage()

func (*AllocateRequest) ProtoReflect

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

func (*AllocateRequest) Reset

func (x *AllocateRequest) Reset()

func (*AllocateRequest) String

func (x *AllocateRequest) String() string

type DBManager

type DBManager interface {
}

type GetAnnotationRequest

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

func (*GetAnnotationRequest) Descriptor deprecated

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

Deprecated: Use GetAnnotationRequest.ProtoReflect.Descriptor instead.

func (*GetAnnotationRequest) ProtoMessage

func (*GetAnnotationRequest) ProtoMessage()

func (*GetAnnotationRequest) ProtoReflect

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

func (*GetAnnotationRequest) Reset

func (x *GetAnnotationRequest) Reset()

func (*GetAnnotationRequest) String

func (x *GetAnnotationRequest) String() string

type GetAnnotationResponse

type GetAnnotationResponse struct {
	Annotations map[string]string `` /* 149-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*GetAnnotationResponse) Descriptor deprecated

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

Deprecated: Use GetAnnotationResponse.ProtoReflect.Descriptor instead.

func (*GetAnnotationResponse) GetAnnotations

func (x *GetAnnotationResponse) GetAnnotations() map[string]string

func (*GetAnnotationResponse) ProtoMessage

func (*GetAnnotationResponse) ProtoMessage()

func (*GetAnnotationResponse) ProtoReflect

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

func (*GetAnnotationResponse) Reset

func (x *GetAnnotationResponse) Reset()

func (*GetAnnotationResponse) String

func (x *GetAnnotationResponse) String() string

type GetLabelRequest

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

func (*GetLabelRequest) Descriptor deprecated

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

Deprecated: Use GetLabelRequest.ProtoReflect.Descriptor instead.

func (*GetLabelRequest) ProtoMessage

func (*GetLabelRequest) ProtoMessage()

func (*GetLabelRequest) ProtoReflect

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

func (*GetLabelRequest) Reset

func (x *GetLabelRequest) Reset()

func (*GetLabelRequest) String

func (x *GetLabelRequest) String() string

type GetLabelResponse

type GetLabelResponse struct {
	Labels map[string]string `` /* 139-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*GetLabelResponse) Descriptor deprecated

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

Deprecated: Use GetLabelResponse.ProtoReflect.Descriptor instead.

func (*GetLabelResponse) GetLabels

func (x *GetLabelResponse) GetLabels() map[string]string

func (*GetLabelResponse) ProtoMessage

func (*GetLabelResponse) ProtoMessage()

func (*GetLabelResponse) ProtoReflect

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

func (*GetLabelResponse) Reset

func (x *GetLabelResponse) Reset()

func (*GetLabelResponse) String

func (x *GetLabelResponse) String() string

type GetNetworkStateRequest

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

网络状态管理

func (*GetNetworkStateRequest) Descriptor deprecated

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

Deprecated: Use GetNetworkStateRequest.ProtoReflect.Descriptor instead.

func (*GetNetworkStateRequest) ProtoMessage

func (*GetNetworkStateRequest) ProtoMessage()

func (*GetNetworkStateRequest) ProtoReflect

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

func (*GetNetworkStateRequest) Reset

func (x *GetNetworkStateRequest) Reset()

func (*GetNetworkStateRequest) String

func (x *GetNetworkStateRequest) String() string

type GetNetworkStateResponse

type GetNetworkStateResponse struct {
	State string `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"` // 示例:idle, active, busy
	// contains filtered or unexported fields
}

func (*GetNetworkStateResponse) Descriptor deprecated

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

Deprecated: Use GetNetworkStateResponse.ProtoReflect.Descriptor instead.

func (*GetNetworkStateResponse) GetState

func (x *GetNetworkStateResponse) GetState() string

func (*GetNetworkStateResponse) ProtoMessage

func (*GetNetworkStateResponse) ProtoMessage()

func (*GetNetworkStateResponse) ProtoReflect

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

func (*GetNetworkStateResponse) Reset

func (x *GetNetworkStateResponse) Reset()

func (*GetNetworkStateResponse) String

func (x *GetNetworkStateResponse) String() string

type GetPriorityRequest

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

func (*GetPriorityRequest) Descriptor deprecated

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

Deprecated: Use GetPriorityRequest.ProtoReflect.Descriptor instead.

func (*GetPriorityRequest) ProtoMessage

func (*GetPriorityRequest) ProtoMessage()

func (*GetPriorityRequest) ProtoReflect

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

func (*GetPriorityRequest) Reset

func (x *GetPriorityRequest) Reset()

func (*GetPriorityRequest) String

func (x *GetPriorityRequest) String() string

type GetPriorityResponse

type GetPriorityResponse struct {
	Priority int32 `protobuf:"varint,1,opt,name=priority,proto3" json:"priority,omitempty"`
	// contains filtered or unexported fields
}

func (*GetPriorityResponse) Descriptor deprecated

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

Deprecated: Use GetPriorityResponse.ProtoReflect.Descriptor instead.

func (*GetPriorityResponse) GetPriority

func (x *GetPriorityResponse) GetPriority() int32

func (*GetPriorityResponse) ProtoMessage

func (*GetPriorityResponse) ProtoMessage()

func (*GetPriorityResponse) ProtoReflect

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

func (*GetPriorityResponse) Reset

func (x *GetPriorityResponse) Reset()

func (*GetPriorityResponse) String

func (x *GetPriorityResponse) String() string

type Plugin

type Plugin interface {
	Name() string
	Init(config interface{}, mgr SidecarManager) error
	Start(ctx context.Context, errCh chan<- error)
	Stop(ctx context.Context) error
	Version() string
	Status() (*PluginStatus, error)
	// must return a pointer of your config
	GetConfigType() interface{}
}

Plugin 定义所有插件必须实现的方法

type PluginConfig

type PluginConfig struct {
	Name      string           `json:"name"`
	Binary    *v1alpha1.Binary `json:"binary,omitempty"`
	Config    interface{}      `json:"config"`
	BootOrder int              `json:"bootOrder"`
}

PluginConfig 表示插件的配置

type PluginStatus

type PluginStatus struct {
	Name        string   `json:"name"`
	Version     string   `json:"version"`
	Running     bool     `json:"running"`
	LastChecked string   `json:"lastChecked"` // 上一次健康检查时间,格式为 YYYY-MM-DD HH:MM:SS
	Health      string   `json:"health"`      // 健康状态,例如 "Healthy", "Unhealthy"
	Infos       []string `json:"infos"`       // 插件的其他信息
}

PluginStatus 表示插件的状态

type ReserveRequest

type ReserveRequest struct {
	ReservationId string `protobuf:"bytes,1,opt,name=reservation_id,json=reservationId,proto3" json:"reservation_id,omitempty"`
	Duration      int32  `protobuf:"varint,2,opt,name=duration,proto3" json:"duration,omitempty"` // 以秒为单位
	// contains filtered or unexported fields
}

func (*ReserveRequest) Descriptor deprecated

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

Deprecated: Use ReserveRequest.ProtoReflect.Descriptor instead.

func (*ReserveRequest) GetDuration

func (x *ReserveRequest) GetDuration() int32

func (*ReserveRequest) GetReservationId

func (x *ReserveRequest) GetReservationId() string

func (*ReserveRequest) ProtoMessage

func (*ReserveRequest) ProtoMessage()

func (*ReserveRequest) ProtoReflect

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

func (*ReserveRequest) Reset

func (x *ReserveRequest) Reset()

func (*ReserveRequest) String

func (x *ReserveRequest) String() string

type SDKClient

type SDKClient interface {
	// 基础管理
	Ready(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
	Shutdown(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// 标签和注解管理
	SetLabel(ctx context.Context, in *SetLabelRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	GetLabel(ctx context.Context, in *GetLabelRequest, opts ...grpc.CallOption) (*GetLabelResponse, error)
	SetAnnotation(ctx context.Context, in *SetAnnotationRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	GetAnnotation(ctx context.Context, in *GetAnnotationRequest, opts ...grpc.CallOption) (*GetAnnotationResponse, error)
	// 资源分配与预留
	Allocate(ctx context.Context, in *AllocateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	Reserve(ctx context.Context, in *ReserveRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// 容量管理
	SetCapacity(ctx context.Context, in *SetCapacityRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// 网络状态管理
	GetNetworkState(ctx context.Context, in *GetNetworkStateRequest, opts ...grpc.CallOption) (*GetNetworkStateResponse, error)
	// 优先级管理
	SetPriority(ctx context.Context, in *SetPriorityRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	GetPriority(ctx context.Context, in *GetPriorityRequest, opts ...grpc.CallOption) (*GetPriorityResponse, error)
}

SDKClient is the client API for SDK 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.

定义 SDK 服务

func NewSDKClient

func NewSDKClient(cc grpc.ClientConnInterface) SDKClient

type SDKServer

type SDKServer interface {
	// 基础管理
	Ready(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
	Shutdown(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
	// 标签和注解管理
	SetLabel(context.Context, *SetLabelRequest) (*emptypb.Empty, error)
	GetLabel(context.Context, *GetLabelRequest) (*GetLabelResponse, error)
	SetAnnotation(context.Context, *SetAnnotationRequest) (*emptypb.Empty, error)
	GetAnnotation(context.Context, *GetAnnotationRequest) (*GetAnnotationResponse, error)
	// 资源分配与预留
	Allocate(context.Context, *AllocateRequest) (*emptypb.Empty, error)
	Reserve(context.Context, *ReserveRequest) (*emptypb.Empty, error)
	// 容量管理
	SetCapacity(context.Context, *SetCapacityRequest) (*emptypb.Empty, error)
	// 网络状态管理
	GetNetworkState(context.Context, *GetNetworkStateRequest) (*GetNetworkStateResponse, error)
	// 优先级管理
	SetPriority(context.Context, *SetPriorityRequest) (*emptypb.Empty, error)
	GetPriority(context.Context, *GetPriorityRequest) (*GetPriorityResponse, error)
	// contains filtered or unexported methods
}

SDKServer is the server API for SDK service. All implementations must embed UnimplementedSDKServer for forward compatibility.

定义 SDK 服务

type SetAnnotationRequest

type SetAnnotationRequest struct {
	Annotations map[string]string `` /* 149-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*SetAnnotationRequest) Descriptor deprecated

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

Deprecated: Use SetAnnotationRequest.ProtoReflect.Descriptor instead.

func (*SetAnnotationRequest) GetAnnotations

func (x *SetAnnotationRequest) GetAnnotations() map[string]string

func (*SetAnnotationRequest) ProtoMessage

func (*SetAnnotationRequest) ProtoMessage()

func (*SetAnnotationRequest) ProtoReflect

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

func (*SetAnnotationRequest) Reset

func (x *SetAnnotationRequest) Reset()

func (*SetAnnotationRequest) String

func (x *SetAnnotationRequest) String() string

type SetCapacityRequest

type SetCapacityRequest struct {
	Capacity int32 `protobuf:"varint,1,opt,name=capacity,proto3" json:"capacity,omitempty"`
	// contains filtered or unexported fields
}

容量管理

func (*SetCapacityRequest) Descriptor deprecated

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

Deprecated: Use SetCapacityRequest.ProtoReflect.Descriptor instead.

func (*SetCapacityRequest) GetCapacity

func (x *SetCapacityRequest) GetCapacity() int32

func (*SetCapacityRequest) ProtoMessage

func (*SetCapacityRequest) ProtoMessage()

func (*SetCapacityRequest) ProtoReflect

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

func (*SetCapacityRequest) Reset

func (x *SetCapacityRequest) Reset()

func (*SetCapacityRequest) String

func (x *SetCapacityRequest) String() string

type SetLabelRequest

type SetLabelRequest struct {
	Labels map[string]string `` /* 139-byte string literal not displayed */
	// contains filtered or unexported fields
}

标签和注解管理

func (*SetLabelRequest) Descriptor deprecated

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

Deprecated: Use SetLabelRequest.ProtoReflect.Descriptor instead.

func (*SetLabelRequest) GetLabels

func (x *SetLabelRequest) GetLabels() map[string]string

func (*SetLabelRequest) ProtoMessage

func (*SetLabelRequest) ProtoMessage()

func (*SetLabelRequest) ProtoReflect

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

func (*SetLabelRequest) Reset

func (x *SetLabelRequest) Reset()

func (*SetLabelRequest) String

func (x *SetLabelRequest) String() string

type SetPriorityRequest

type SetPriorityRequest struct {
	Priority int32 `protobuf:"varint,1,opt,name=priority,proto3" json:"priority,omitempty"` // 数值型优先级,例如 0-100
	// contains filtered or unexported fields
}

优先级管理

func (*SetPriorityRequest) Descriptor deprecated

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

Deprecated: Use SetPriorityRequest.ProtoReflect.Descriptor instead.

func (*SetPriorityRequest) GetPriority

func (x *SetPriorityRequest) GetPriority() int32

func (*SetPriorityRequest) ProtoMessage

func (*SetPriorityRequest) ProtoMessage()

func (*SetPriorityRequest) ProtoReflect

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

func (*SetPriorityRequest) Reset

func (x *SetPriorityRequest) Reset()

func (*SetPriorityRequest) String

func (x *SetPriorityRequest) String() string

type Sidecar

type Sidecar interface {
	InitPlugins() error
	RemovePlugin(pluginName string) error
	GetVersion() string
	PluginStatus(pluginName string) (*PluginStatus, error)
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	SetupWithManager(mgr SidecarManager) error
	LoadConfig(path string) error
}

Sidecar 定义Sidecar对外的接口

type SidecarConfig

type SidecarConfig struct {
	Plugins           []PluginConfig    `json:"plugins"`           // 启动的插件及其配置
	RestartPolicy     string            `json:"restartPolicy"`     // 重启策略
	Resources         map[string]string `json:"resources"`         // Sidecar 所需的资源
	SidecarStartOrder string            `json:"sidecarStartOrder"` // Sidecar 的启动顺序,是在主容器之后还是之前
}

SidecarConfig 表示 Sidecar 的配置

type SidecarManager

type SidecarManager interface {
	ctrl.Manager
	DBManager
	kubernetes.Interface
}

type UnimplementedSDKServer

type UnimplementedSDKServer struct{}

UnimplementedSDKServer 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.

func (UnimplementedSDKServer) Allocate

func (UnimplementedSDKServer) GetAnnotation

func (UnimplementedSDKServer) GetLabel

func (UnimplementedSDKServer) GetNetworkState

func (UnimplementedSDKServer) GetPriority

func (UnimplementedSDKServer) Ready

func (UnimplementedSDKServer) Reserve

func (UnimplementedSDKServer) SetAnnotation

func (UnimplementedSDKServer) SetCapacity

func (UnimplementedSDKServer) SetLabel

func (UnimplementedSDKServer) SetPriority

func (UnimplementedSDKServer) Shutdown

type UnsafeSDKServer

type UnsafeSDKServer interface {
	// contains filtered or unexported methods
}

UnsafeSDKServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to SDKServer will result in compilation errors.

Directories

Path Synopsis
Package v1alpha1 contains API Schema definitions for the serverless v1alpha1 API group +kubebuilder:object:generate=true +groupName=serverless.vke.volcengine.com
Package v1alpha1 contains API Schema definitions for the serverless v1alpha1 API group +kubebuilder:object:generate=true +groupName=serverless.vke.volcengine.com

Jump to

Keyboard shortcuts

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