informer

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyWatched is the error when watch the same entry again.
	ErrAlreadyWatched = fmt.Errorf("already watched")

	// ErrClosed is the error when watching a closed informer.
	ErrClosed = fmt.Errorf("informer already been closed")

	// ErrNotFound is the error when watching an entry which is not found.
	ErrNotFound = fmt.Errorf("not found")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	EventType string
	RawKV     *mvccpb.KeyValue
}

Event is the type of inform event.

type GJSONPath

type GJSONPath string

GJSONPath is the type of inform path, in GJSON syntax.

const (

	// EventUpdate is the update inform event.
	EventUpdate = "Update"
	// EventDelete is the delete inform event.
	EventDelete = "Delete"

	// AllParts is the path of the whole structure.
	AllParts GJSONPath = ""

	// ServiceObservability  is the path of service observability.
	ServiceObservability GJSONPath = "observability"

	// ServiceResilience is the path of service resilience.
	ServiceResilience GJSONPath = "resilience"

	// ServiceCanary is the path of service canary.
	ServiceCanary GJSONPath = "canary"

	// ServiceLoadBalance is the path of service loadbalance.
	ServiceLoadBalance GJSONPath = "loadBalance"

	// ServiceCircuitBreaker is the path of service resilience's circuitBreaker part.
	ServiceCircuitBreaker GJSONPath = "resilience.circuitBreaker"
)

type Informer

type Informer interface {
	OnPartOfServiceSpec(serviceName string, gjsonPath GJSONPath, fn ServiceSpecFunc) error
	OnAllServiceSpecs(fn ServiceSpecsFunc) error

	OnPartOfServiceInstanceSpec(serviceName, instanceID string, gjsonPath GJSONPath, fn ServicesInstanceSpecFunc) error
	OnServiceInstanceSpecs(serviceName string, fn ServiceInstanceSpecsFunc) error
	OnAllServiceInstanceSpecs(fn ServiceInstanceSpecsFunc) error

	OnPartOfServiceInstanceStatus(serviceName, instanceID string, gjsonPath GJSONPath, fn ServiceInstanceStatusFunc) error
	OnServiceInstanceStatuses(serviceName string, fn ServiceInstanceStatusesFunc) error
	OnAllServiceInstanceStatuses(fn ServiceInstanceStatusesFunc) error

	OnPartOfTenantSpec(tenantName string, gjsonPath GJSONPath, fn TenantSpecFunc) error
	OnAllTenantSpecs(fn TenantSpecsFunc) error

	OnPartOfIngressSpec(serviceName string, gjsonPath GJSONPath, fn IngressSpecFunc) error
	OnAllIngressSpecs(fn IngressSpecsFunc) error

	StopWatchServiceSpec(serviceName string, gjsonPath GJSONPath)
	StopWatchServiceInstanceSpec(serviceName string)

	Close()
}

Informer is the interface for informing two type of storage changed for every Mesh spec structure.

  1. Based on comparison between old and new part of entry.
  2. Based on comparison on entries with the same prefix.

func NewInformer

func NewInformer(store storage.Storage, service string) Informer

NewInformer creates an informer If service is specified, will only inform resource changes within the same tenant of the service and the global tenant, note this only apply to service, service instance and service status. if service is empty, will inform all resource changes.

type IngressSpecFunc

type IngressSpecFunc func(event Event, ingressSpec *spec.Ingress) bool

IngressSpecFunc is the callback function type for service spec.

type IngressSpecsFunc

type IngressSpecsFunc func(value map[string]*spec.Ingress) bool

IngressSpecsFunc is the callback function type for service specs.

type ServiceInstanceSpecsFunc

type ServiceInstanceSpecsFunc func(value map[string]*spec.ServiceInstanceSpec) bool

ServiceInstanceSpecsFunc is the callback function type for service instance specs.

type ServiceInstanceStatusFunc

type ServiceInstanceStatusFunc func(event Event, value *spec.ServiceInstanceStatus) bool

ServiceInstanceStatusFunc is the callback function type for service instance status.

type ServiceInstanceStatusesFunc

type ServiceInstanceStatusesFunc func(value map[string]*spec.ServiceInstanceStatus) bool

ServiceInstanceStatusesFunc is the callback function type for service instance statuses.

type ServiceSpecFunc

type ServiceSpecFunc func(event Event, serviceSpec *spec.Service) bool

ServiceSpecFunc is the callback function type for service spec.

type ServiceSpecsFunc

type ServiceSpecsFunc func(value map[string]*spec.Service) bool

ServiceSpecsFunc is the callback function type for service specs.

type ServicesInstanceSpecFunc

type ServicesInstanceSpecFunc func(event Event, instanceSpec *spec.ServiceInstanceSpec) bool

ServicesInstanceSpecFunc is the callback function type for service instance spec.

type TenantSpecFunc

type TenantSpecFunc func(event Event, value *spec.Tenant) bool

TenantSpecFunc is the callback function type for tenant spec.

type TenantSpecsFunc

type TenantSpecsFunc func(value map[string]*spec.Tenant) bool

TenantSpecsFunc is the callback function type for tenant specs.

Jump to

Keyboard shortcuts

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