api

package
v0.0.0-...-893ff65 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// IngesterFinalizer is used as the pre-delete hook for ingester controller.
	// If Ingester finalizer is presented in a CRD object, ingester shall check if
	// all the pre-delete actions are completed before removing this finalizer.
	IngesterFinalizer = "michelangelo/Ingester"

	// DeletingAnnotation is used to mark a CRD object is pending on deletion.
	// If this annotation is "true", ingester will delete this CRD in both k8s/ETCD and MySQL.
	DeletingAnnotation = "michelangelo/Deleting"

	// ImmutableAnnotation is used to mark a CRD object if the spec and status of the object
	// will no longer be updated .  If this annotation is set to "true", ingester will remove
	// this CRD object from k8s/ETCD and only the annotation and label of the immutable CRD
	// object can be changed in MySQL later on.
	ImmutableAnnotation = "michelangelo/Immutable"

	// SpecUpdateTimestampLabel is used to record the last time the spec of the object is updated.
	// The time is stored in Unix microseconds.
	SpecUpdateTimestampLabel = "michelangelo/SpecUpdateTimestamp"

	// UpdateTimestampLabel is used to record the last time the object is updated.
	// The time is stored in Unix microseconds.
	UpdateTimestampLabel = "michelangelo/UpdateTimestamp"
)
View Source
const DefaultContextTimeout = 30 * time.Second

DefaultContextTimeout defines the default timeout for the context

Variables

K8sStatusReasonToGrpcError map tries to map the K8s api server's error code to gRPC's status error code. As there is no exact one to one mapping between this two error systems, this map translates the mapping with the best effort. For unlisted StatusReason, surfaceGrpcError() will translate that into codes.Unknown. The api client shall use the detailed error message to determine the unknown error.

Functions

func GetGrpcStatusCode

func GetGrpcStatusCode(err error) codes.Code

GetGrpcStatusCode translates Kubernetes error to GRPC status code

func K8sError2GrpcError

func K8sError2GrpcError(err error, msg string) error

K8sError2GrpcError converts K8s error to GRPC error

func Validate

func Validate(obj interface{}) error

Validate an input message, if the message has Validate(string) error function

Types

type Handler

type Handler interface {
	// Create saves the API object obj into the unified API system.
	// Create API handler derives the name, namespace and object type from obj.
	// Returns nil if successful, otherwise a gRPC status error is returned.
	Create(ctx context.Context, obj client.Object, opts *metav1.CreateOptions) error

	// Get retrieves an API object by the given name and namespace from unified API system, and stores
	// that object into where the obj struct pointer pointed.
	// Get API handler derives the object type from obj.
	// Returns nil if successful, otherwise a gRPC status error is returned.
	Get(ctx context.Context, namespace string, name string, opts *metav1.GetOptions, obj client.Object) error

	// Update updates the given API object to the unified API system.
	// Update API handler derives the name, namespace and object type from obj.
	// Returns nil if successful, otherwise a gRPC status error is returned.
	Update(ctx context.Context, obj client.Object, opts *metav1.UpdateOptions) error

	// UpdateStatus updates Status of the given API object to the unified API system.
	// UpdateStatus API handler derives the name, namespace and object type from obj.
	// Returns nil if successful, otherwise a gRPC status error is returned.
	UpdateStatus(ctx context.Context, obj client.Object, opts *metav1.UpdateOptions) error

	// Delete deletes an API object specified by obj and opts.
	// Delete API handler derives name, namespace and object type from obj.
	// Returns nil if successful, otherwise a gRPC status error is returned.
	Delete(ctx context.Context, obj client.Object, opts *metav1.DeleteOptions) error

	// List retrieves a list of API objects in the given namespace specified by opts and listOptionsExt,
	// and stores the result into the list object pointed by list.
	// List API handler derives the object type from list.
	// Returns nil if successful, otherwise a gRPC status error is returned.
	List(ctx context.Context, namespace string, opts *metav1.ListOptions, listOptionsExt *apipb.ListOptionsExt,
		list client.ObjectList) error

	// DeleteCollection deletes a collection of API objects in the namespace specified by deleteOpts
	// and listOpts.
	// DeleteCollection API handler derives the object type from objType.
	// Returns nil if successful, otherwise a gRPC status error is returned.
	DeleteCollection(ctx context.Context, objType client.Object, namespace string,
		deleteOpts *metav1.DeleteOptions, listOpts *metav1.ListOptions) error
}

Handler defines an interface to handle the unified API objects with the underlying systems.

type TypedAPIHandler

type TypedAPIHandler[T runtime.Object, L client.ObjectList] interface {
	// Create saves the API object obj into the unified API system.
	Create(context.Context, T, *metav1.CreateOptions, ...yarpc.CallOption) error

	// Get retrieves an API object by the given name and namespace from unified API system
	Get(context.Context, string, string, *metav1.GetOptions, ...yarpc.CallOption) (T, error)

	// Update updates the given API object to the unified API system.
	Update(context.Context, T, *metav1.UpdateOptions, ...yarpc.CallOption) error

	// List retrieves a list of API objects in the given namespace specified by opts and listOptionsExt
	List(context.Context, string, *metav1.ListOptions, *apipb.ListOptionsExt, ...yarpc.CallOption) (L, error)

	// Delete deletes an API object specified by obj and opts.
	Delete(context.Context, T, *metav1.DeleteOptions, ...yarpc.CallOption) error

	// DeleteCollection deletes a collection of API objects in the namespace specified by deleteOpts and listOpts.
	DeleteCollection(context.Context, T, *metav1.DeleteOptions, *metav1.ListOptions, ...yarpc.CallOption) error
}

TypedAPIHandler defines an interface to handle a specific typed objects with the underlying systems.

Directories

Path Synopsis
Package apimocks is a generated GoMock package.
Package apimocks is a generated GoMock package.
crd
crdmocks
Package crdmocks is a generated GoMock package.
Package crdmocks is a generated GoMock package.
handlermocks
Package handlermocks is a generated GoMock package.
Package handlermocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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