spec

package
v1.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// RegistryTypeConsul is the consul registry type.
	RegistryTypeConsul = "consul"
	// RegistryTypeEureka is the eureka registry type.
	RegistryTypeEureka = "eureka"
	// RegistryTypeNacos is the eureka registry type.
	RegistryTypeNacos = "nacos"

	// GlobalTenant is the reserved name of the system scope tenant,
	// its services can be accessible in mesh wide.
	GlobalTenant = "global"

	// ServiceStatusUp indicates this service instance can accept ingress traffic
	ServiceStatusUp = "UP"

	// ServiceStatusOutOfService indicates this service instance can't accept ingress traffic
	ServiceStatusOutOfService = "OUT_OF_SERVICE"

	// WorkerAPIPort is the default port for worker's API server
	WorkerAPIPort = 13009

	// IngressPort is the default port for ingress controller
	IngressPort = 13010

	// HeartbeatInterval is the default heartbeat interval for checking service heartbeat
	HeartbeatInterval = "5s"

	// SecurityLevelPermissive is the level for not enabling mTLS.
	SecurityLevelPermissive = "permissive"

	// SecurityLevelStrict is the level for enabling mTLS.
	SecurityLevelStrict = "strict"

	// DefaultCommonName is the name of root ca cert.
	DefaultCommonName = "mesh-root-ca"

	// CertProviderSelfSign is the in-memory, self-sign cert provider.
	CertProviderSelfSign = "selfSign"

	// IngressControllerName is the name of easemesh ingress controller.
	IngressControllerName = "ingresscontroller"

	// PodEnvHostname is the name of the pod in environment variable.
	PodEnvHostname = "HOSTNAME"

	// PodEnvApplicationIP is the IP of the pod in environment variable.
	PodEnvApplicationIP = "APPLICATION_IP"
)

Variables

View Source
var (
	// ErrParamNotMatch means RESTful request URL's object name or other fields are not matched in this request's body
	ErrParamNotMatch = fmt.Errorf("param in url and body's spec not matched")
	// ErrAlreadyRegistered indicates this instance has already been registered
	ErrAlreadyRegistered = fmt.Errorf("service already registered")
	// ErrNoRegisteredYet indicates this instance haven't registered successfully yet
	ErrNoRegisteredYet = fmt.Errorf("service not registered yet")
	// ErrServiceNotFound indicates could find target service in its tenant or in global tenant
	ErrServiceNotFound = fmt.Errorf("can't find service in its tenant or in global tenant")
	// ErrServiceNotavailable indicates could find target service's available instances.
	ErrServiceNotavailable = fmt.Errorf("can't find service available instances")
)

Functions

func IngressHTTPServerSpec

func IngressHTTPServerSpec(port int, rules []*IngressRule) (*supervisor.Spec, error)

IngressHTTPServerSpec generates HTTP server spec for ingress. as ingress does not belong to a service, it is not a method of 'Service'

Types

type Admin

type Admin struct {
	// HeartbeatInterval is the interval for one service instance reporting its heartbeat.
	HeartbeatInterval string `yaml:"heartbeatInterval" jsonschema:"required,format=duration"`
	// RegistryTime indicates which protocol the registry center accepts.
	RegistryType string `yaml:"registryType" jsonschema:"required"`

	// APIPort is the port for worker's API server
	APIPort int `yaml:"apiPort" jsonschema:"required"`

	// IngressPort is the port for http server in mesh ingress
	IngressPort int `yaml:"ingressPort" jsonschema:"required"`

	ExternalServiceRegistry string `yaml:"externalServiceRegistry" jsonschema:"omitempty"`

	Security *Security `yaml:"security" jsonschema:"omitempty"`
}

Admin is the spec of MeshController.

func (Admin) EnablemTLS added in v1.3.1

func (a Admin) EnablemTLS() bool

EnablemTLS indicates whether we should enable mTLS in mesh or not.

func (Admin) Validate

func (a Admin) Validate() error

Validate validates Spec.

type Canary

type Canary struct {
	CanaryRules []*CanaryRule `yaml:"canaryRules" jsonschema:"omitempty"`
}

Canary is the spec of service canary.

type CanaryRule

type CanaryRule struct {
	ServiceInstanceLabels map[string]string               `yaml:"serviceInstanceLabels" jsonschema:"required"`
	Headers               map[string]*urlrule.StringMatch `yaml:"headers" jsonschema:"required"`
	URLs                  []*urlrule.URLRule              `yaml:"urls" jsonschema:"required"`
}

CanaryRule is one matching rule for canary.

type Certificate added in v1.3.1

type Certificate struct {
	IP          string `yaml:"ip" jsonschema:"required"`
	ServiceName string `yaml:"servieName" jsonschema:"required"`
	CertBase64  string `yaml:"certBase64" jsonschema:"required"`
	KeyBase64   string `yaml:"keyBase64" jsonschema:"required"`
	TTL         string `yaml:"ttl" jsonschema:"required,format=duration"`
	SignTime    string `yaml:"signTime" jsonschema:"required,format=timerfc3339"`
	HOST        string `yaml:"host" jsonschema:"required"`
}

Certificate is one cert for mesh service instance or root CA.

type CustomResource added in v1.3.0

type CustomResource DynamicObject

CustomResource defines the spec of a custom resource

func (CustomResource) Kind added in v1.3.0

func (cr CustomResource) Kind() string

Kind returns the 'kind' field of the custom resource

func (CustomResource) Name added in v1.3.0

func (cr CustomResource) Name() string

Name returns the 'name' field of the custom resource

func (*CustomResource) UnmarshalYAML added in v1.3.1

func (cr *CustomResource) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler

type CustomResourceKind added in v1.3.0

type CustomResourceKind struct {
	Name       string        `yaml:"name" jsonschema:"required"`
	JSONSchema DynamicObject `yaml:"jsonSchema" jsonschema:"omitempty"`
}

CustomResourceKind defines the spec of a custom resource kind

type DynamicObject added in v1.3.1

type DynamicObject map[string]interface{}

DynamicObject defines a dynamic object which is a map of string to interface{}. The value of this map could also be a dynamic object, but in this case, its type must be `map[string]interface{}`, and should not be `map[interface{}]interface{}`.

func (*DynamicObject) UnmarshalYAML added in v1.3.1

func (do *DynamicObject) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler the type of a DynamicObject field could be `map[interface{}]interface{}` if it is unmarshaled from yaml, but some packages, like the standard json package could not handle this type, so it must be converted to `map[string]interface{}`.

type GlobalCanaryHeaders

type GlobalCanaryHeaders struct {
	ServiceHeaders map[string][]string `yaml:"serviceHeaders" jsonschema:"omitempty"`
}

GlobalCanaryHeaders is the spec of global service

type Ingress

type Ingress struct {
	Name  string         `yaml:"name" jsonschema:"required"`
	Rules []*IngressRule `yaml:"rules" jsonschema:"required"`
}

Ingress is the spec of mesh ingress

type IngressPath

type IngressPath struct {
	Path          string `yaml:"path" jsonschema:"required"`
	RewriteTarget string `yaml:"rewriteTarget" jsonschema:"omitempty"`
	Backend       string `yaml:"backend" jsonschema:"required"`
}

IngressPath is the path for a mesh ingress rule

type IngressRule

type IngressRule struct {
	Host  string         `yaml:"host" jsonschema:"omitempty"`
	Paths []*IngressPath `yaml:"paths" jsonschema:"required"`
}

IngressRule is the rule for mesh ingress

type LoadBalance

type LoadBalance = proxy.LoadBalance

LoadBalance is the spec of service load balance.

type Mock added in v1.3.0

type Mock struct {
	// Enable is the mocking switch for this service.
	Enabled bool `yaml:"enabled" jsonschema:"required"`

	// Rules are the mocking matching and responding configurations.
	Rules []*mock.Rule `yaml:"rules" jsonschema:"omitempty"`
}

Mock is the spec of configured and static API responses for this service.

type Observability

type Observability struct {
	OutputServer *ObservabilityOutputServer `yaml:"outputServer" jsonschema:"omitempty"`
	Tracings     *ObservabilityTracings     `yaml:"tracings" jsonschema:"omitempty"`
	Metrics      *ObservabilityMetrics      `yaml:"metrics" jsonschema:"omitempty"`
}

Observability is the spec of service observability.

type ObservabilityMetrics

type ObservabilityMetrics struct {
	Enabled        bool                       `yaml:"enabled" jsonschema:"required"`
	Access         ObservabilityMetricsDetail `yaml:"access" jsonschema:"required"`
	Request        ObservabilityMetricsDetail `yaml:"request" jsonschema:"required"`
	JdbcStatement  ObservabilityMetricsDetail `yaml:"jdbcStatement" jsonschema:"required"`
	JdbcConnection ObservabilityMetricsDetail `yaml:"jdbcConnection" jsonschema:"required"`
	Rabbit         ObservabilityMetricsDetail `yaml:"rabbit" jsonschema:"required"`
	Kafka          ObservabilityMetricsDetail `yaml:"kafka" jsonschema:"required"`
	Redis          ObservabilityMetricsDetail `yaml:"redis" jsonschema:"required"`
	JvmGC          ObservabilityMetricsDetail `yaml:"jvmGc" jsonschema:"required"`
	JvmMemory      ObservabilityMetricsDetail `yaml:"jvmMemory" jsonschema:"required"`
	Md5Dictionary  ObservabilityMetricsDetail `yaml:"md5Dictionary" jsonschema:"required"`
}

ObservabilityMetrics is the metrics of observability.

type ObservabilityMetricsDetail

type ObservabilityMetricsDetail struct {
	Enabled  bool   `yaml:"enabled" jsonschema:"required"`
	Interval int    `yaml:"interval" jsonschema:"required"`
	Topic    string `yaml:"topic" jsonschema:"required"`
}

ObservabilityMetricsDetail is the metrics detail of observability.

type ObservabilityOutputServer

type ObservabilityOutputServer struct {
	Enabled         bool   `yaml:"enabled" jsonschema:"required"`
	BootstrapServer string `yaml:"bootstrapServer" jsonschema:"required"`
	Timeout         int    `yaml:"timeout" jsonschema:"required"`
}

ObservabilityOutputServer is the output server of observability.

type ObservabilityTracings

type ObservabilityTracings struct {
	Enabled     bool                              `yaml:"enabled" jsonschema:"required"`
	SampleByQPS int                               `yaml:"sampleByQPS" jsonschema:"required"`
	Output      ObservabilityTracingsOutputConfig `yaml:"output" jsonschema:"required"`

	Request      ObservabilityTracingsDetail `yaml:"request" jsonschema:"required"`
	RemoteInvoke ObservabilityTracingsDetail `yaml:"remoteInvoke" jsonschema:"required"`
	Kafka        ObservabilityTracingsDetail `yaml:"kafka" jsonschema:"required"`
	Jdbc         ObservabilityTracingsDetail `yaml:"jdbc" jsonschema:"required"`
	Redis        ObservabilityTracingsDetail `yaml:"redis" jsonschema:"required"`
	Rabbit       ObservabilityTracingsDetail `yaml:"rabbit" jsonschema:"required"`
}

ObservabilityTracings is the tracings of observability.

type ObservabilityTracingsDetail

type ObservabilityTracingsDetail struct {
	Enabled       bool   `yaml:"enabled" jsonschema:"required"`
	ServicePrefix string `yaml:"servicePrefix" jsonschema:"required"`
}

ObservabilityTracingsDetail is the tracing detail of observability.

type ObservabilityTracingsOutputConfig

type ObservabilityTracingsOutputConfig struct {
	Enabled         bool   `yaml:"enabled" jsonschema:"required"`
	ReportThread    int    `yaml:"reportThread" jsonschema:"required"`
	Topic           string `yaml:"topic" jsonschema:"required"`
	MessageMaxBytes int    `yaml:"messageMaxBytes" jsonschema:"required"`
	QueuedMaxSpans  int    `yaml:"queuedMaxSpans" jsonschema:"required"`
	QueuedMaxSize   int    `yaml:"queuedMaxSize" jsonschema:"required"`
	MessageTimeout  int    `yaml:"messageTimeout" jsonschema:"required"`
}

ObservabilityTracingsOutputConfig is the tracing output configuration

type Resilience

type Resilience struct {
	RateLimiter    *ratelimiter.Spec    `yaml:"rateLimiter" jsonschema:"omitempty"`
	CircuitBreaker *circuitbreaker.Spec `yaml:"circuitBreaker" jsonschema:"omitempty"`
	Retryer        *retryer.Spec        `yaml:"retryer" jsonschema:"omitempty"`
	TimeLimiter    *timelimiter.Spec    `yaml:"timeLimiter" jsonschema:"omitempty"`
}

Resilience is the spec of service resilience.

type Security added in v1.3.1

type Security struct {
	MTLSMode     string `yaml:"mtlsMode" jsonschema:"required"`
	CertProvider string `yaml:"certProvider" jsonschema:"required"`

	RootCertTTL string `yaml:"rootCertTTL" jsonschema:"required, format=duration"`
	AppCertTTL  string `yaml:"appCertTTL" jsonschema:"required, format=duration"`
}

Security is the spec for mesh-wide security.

type Service

type Service struct {
	// Empty means mesh registry itself.
	RegistryName   string `yaml:"registryName" jsonschema:"omitempty"`
	Name           string `yaml:"name" jsonschema:"required"`
	RegisterTenant string `yaml:"registerTenant" jsonschema:"required"`

	Sidecar       *Sidecar       `yaml:"sidecar" jsonschema:"required"`
	Mock          *Mock          `yaml:"mock" jsonschema:"omitempty"`
	Resilience    *Resilience    `yaml:"resilience" jsonschema:"omitempty"`
	Canary        *Canary        `yaml:"canary" jsonschema:"omitempty"`
	LoadBalance   *LoadBalance   `yaml:"loadBalance" jsonschema:"omitempty"`
	Observability *Observability `yaml:"observability" jsonschema:"omitempty"`
}

Service contains the information of service.

func (*Service) ApplicationEndpoint

func (s *Service) ApplicationEndpoint(port uint32) string

ApplicationEndpoint returns application endpoint URL string

func (*Service) BackendName added in v1.1.0

func (s *Service) BackendName() string

BackendName returns backend service name

func (*Service) EgressEndpoint

func (s *Service) EgressEndpoint() string

EgressEndpoint returns Egress endpoint URL string

func (*Service) EgressHTTPServerName

func (s *Service) EgressHTTPServerName() string

EgressHTTPServerName returns egress HTTP server name

func (*Service) EgressHandlerName

func (s *Service) EgressHandlerName() string

EgressHandlerName returns egress handler name.

func (*Service) EgressPipelineName

func (s *Service) EgressPipelineName() string

EgressPipelineName returns egress pipeline name

func (*Service) IngressEndpoint

func (s *Service) IngressEndpoint() string

IngressEndpoint returns Ingress endpoint URL string

func (*Service) IngressHTTPServerName

func (s *Service) IngressHTTPServerName() string

IngressHTTPServerName returns the ingress server name

func (*Service) IngressHandlerName

func (s *Service) IngressHandlerName() string

IngressHandlerName returns the ingress handler name

func (*Service) IngressPipelineName

func (s *Service) IngressPipelineName() string

IngressPipelineName returns the ingress pipeline name

func (*Service) IngressPipelineSpec

func (s *Service) IngressPipelineSpec(instanceSpecs []*ServiceInstanceSpec, cert, rootCert *Certificate) (*supervisor.Spec, error)

IngressPipelineSpec generates a spec for ingress pipeline spec

func (*Service) Runnable added in v1.3.0

func (s *Service) Runnable() bool

Runnable indicates this service is runnable inside mesh or not.

e.g., If this is a mock service, there is not need to be deployed and run.

func (*Service) SideCarEgressHTTPServerSpec

func (s *Service) SideCarEgressHTTPServerSpec() (*supervisor.Spec, error)

SideCarEgressHTTPServerSpec returns a spec for egress HTTP server

func (*Service) SideCarEgressPipelineSpec

func (s *Service) SideCarEgressPipelineSpec(instanceSpecs []*ServiceInstanceSpec, appCert, rootCert *Certificate) (*supervisor.Spec, error)

SideCarEgressPipelineSpec returns a spec for sidecar egress pipeline

func (*Service) SideCarIngressHTTPServerSpec

func (s *Service) SideCarIngressHTTPServerSpec(cert, rootCert *Certificate) (*supervisor.Spec, error)

SideCarIngressHTTPServerSpec generates a spec for sidecar ingress HTTP server

func (*Service) SideCarIngressPipelineSpec

func (s *Service) SideCarIngressPipelineSpec(applicationPort uint32) (*supervisor.Spec, error)

SideCarIngressPipelineSpec returns a spec for sidecar ingress pipeline

func (*Service) UniqueCanaryHeaders

func (s *Service) UniqueCanaryHeaders() []string

UniqueCanaryHeaders returns the unique headers in canary filter rules.

type ServiceInstanceSpec

type ServiceInstanceSpec struct {
	RegistryName string `yaml:"registryName" jsonschema:"required"`
	// Provide by registry client
	ServiceName  string            `yaml:"serviceName" jsonschema:"required"`
	InstanceID   string            `yaml:"instanceID" jsonschema:"required"`
	IP           string            `yaml:"ip" jsonschema:"required"`
	Port         uint32            `yaml:"port" jsonschema:"required"`
	RegistryTime string            `yaml:"registryTime" jsonschema:"omitempty"`
	Labels       map[string]string `yaml:"labels" jsonschema:"omitempty"`

	// Set by heartbeat timer event or API
	Status string `yaml:"status" jsonschema:"omitempty"`
}

ServiceInstanceSpec is the spec of service instance. FIXME: Use the unified struct: serviceregistry.ServiceInstanceSpec.

func (*ServiceInstanceSpec) Key added in v1.3.0

func (s *ServiceInstanceSpec) Key() string

Key returns the key of ServiceInstanceSpec.

type ServiceInstanceStatus

type ServiceInstanceStatus struct {
	ServiceName string `yaml:"serviceName" jsonschema:"required"`
	InstanceID  string `yaml:"instanceID" jsonschema:"required"`
	// RFC3339 format
	LastHeartbeatTime string `yaml:"lastHeartbeatTime" jsonschema:"required,format=timerfc3339"`
}

ServiceInstanceStatus is the status of service instance.

type Sidecar

type Sidecar struct {
	DiscoveryType   string `yaml:"discoveryType" jsonschema:"required"`
	Address         string `yaml:"address" jsonschema:"required"`
	IngressPort     int    `yaml:"ingressPort" jsonschema:"required"`
	IngressProtocol string `yaml:"ingressProtocol" jsonschema:"required"`
	EgressPort      int    `yaml:"egressPort" jsonschema:"required"`
	EgressProtocol  string `yaml:"egressProtocol" jsonschema:"required"`
}

Sidecar is the spec of service sidecar.

type Tenant

type Tenant struct {
	Name string `yaml:"name"`

	Services []string `yaml:"services" jsonschema:"omitempty"`
	// Format: RFC3339
	CreatedAt   string `yaml:"createdAt" jsonschema:"omitempty"`
	Description string `yaml:"description"`
}

Tenant contains the information of tenant.

Jump to

Keyboard shortcuts

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