distributor

package
v0.24.4 Latest Latest
Warning

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

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

Documentation

Overview

Package distributor handles the distribution of new application versions in a particular deployment location (e.g., a cloud region).

In particular, this package handles the starting of application versions, as well as gradual traffic shifting across multiple versions of the same application in that location.

Index

Constants

This section is empty.

Variables

View Source
var (
	AppVersionState_Status_name = map[int32]string{
		0: "STARTING",
		1: "STARTED",
		2: "STOPPING",
		3: "STOPPED",
	}
	AppVersionState_Status_value = map[string]int32{
		"STARTING": 0,
		"STARTED":  1,
		"STOPPING": 2,
		"STOPPED":  3,
	}
)

Enum value maps for AppVersionState_Status.

View Source
var File_internal_nanny_distributor_distributor_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AppState

type AppState struct {

	// Application versions, sorted by submission time.
	Versions []*AppVersionState `protobuf:"bytes,1,rep,name=versions,proto3" json:"versions,omitempty"`
	// Deployment ids of deleted versions.
	DeletedVersions []string `protobuf:"bytes,3,rep,name=deleted_versions,json=deletedVersions,proto3" json:"deleted_versions,omitempty"`
	// contains filtered or unexported fields
}

AppState contains the state managed for an application by the distributor.

func (*AppState) Descriptor deprecated

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

Deprecated: Use AppState.ProtoReflect.Descriptor instead.

func (*AppState) GetDeletedVersions

func (x *AppState) GetDeletedVersions() []string

func (*AppState) GetVersions

func (x *AppState) GetVersions() []*AppVersionState

func (*AppState) ProtoMessage

func (*AppState) ProtoMessage()

func (*AppState) ProtoReflect

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

func (*AppState) Reset

func (x *AppState) Reset()

func (*AppState) String

func (x *AppState) String() string

type AppVersionState

type AppVersionState struct {

	// Deployment information.
	Config *config.GKEConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
	// Rollout information.
	Schedule *nanny.Schedule `protobuf:"bytes,2,opt,name=schedule,proto3" json:"schedule,omitempty"`
	// Unique identifier that captures the order in which the application version
	// was submitted for rollout.
	Order int64 `protobuf:"varint,3,opt,name=order,proto3" json:"order,omitempty"`
	// All known Kubernetes ReplicaSets for this application version.
	ReplicaSets []*nanny.ReplicaSet `protobuf:"bytes,4,rep,name=replica_sets,json=replicaSets,proto3" json:"replica_sets,omitempty"`
	// All known listeners for this application version.
	Listeners   []*nanny.Listener      `protobuf:"bytes,7,rep,name=listeners,proto3" json:"listeners,omitempty"`
	Status      AppVersionState_Status `protobuf:"varint,5,opt,name=status,proto3,enum=distributor.AppVersionState_Status" json:"status,omitempty"`
	StoppedTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=stopped_time,json=stoppedTime,proto3" json:"stopped_time,omitempty"` // when the version was stopped
	// contains filtered or unexported fields
}

AppVersionState contains the state managed for an application version by the distributor.

func (*AppVersionState) Descriptor deprecated

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

Deprecated: Use AppVersionState.ProtoReflect.Descriptor instead.

func (*AppVersionState) GetConfig

func (x *AppVersionState) GetConfig() *config.GKEConfig

func (*AppVersionState) GetListeners

func (x *AppVersionState) GetListeners() []*nanny.Listener

func (*AppVersionState) GetOrder

func (x *AppVersionState) GetOrder() int64

func (*AppVersionState) GetReplicaSets added in v0.2.0

func (x *AppVersionState) GetReplicaSets() []*nanny.ReplicaSet

func (*AppVersionState) GetSchedule

func (x *AppVersionState) GetSchedule() *nanny.Schedule

func (*AppVersionState) GetStatus

func (x *AppVersionState) GetStatus() AppVersionState_Status

func (*AppVersionState) GetStoppedTime

func (x *AppVersionState) GetStoppedTime() *timestamppb.Timestamp

func (*AppVersionState) ProtoMessage

func (*AppVersionState) ProtoMessage()

func (*AppVersionState) ProtoReflect

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

func (*AppVersionState) Reset

func (x *AppVersionState) Reset()

func (*AppVersionState) String

func (x *AppVersionState) String() string

type AppVersionState_Status

type AppVersionState_Status int32
const (
	AppVersionState_STARTING AppVersionState_Status = 0 // should be started
	AppVersionState_STARTED  AppVersionState_Status = 1 // has started
	AppVersionState_STOPPING AppVersionState_Status = 2 // should be stopped
	AppVersionState_STOPPED  AppVersionState_Status = 3 // has been stopped; should be deleted after a delay
)

func (AppVersionState_Status) Descriptor

func (AppVersionState_Status) Enum

func (AppVersionState_Status) EnumDescriptor deprecated

func (AppVersionState_Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use AppVersionState_Status.Descriptor instead.

func (AppVersionState_Status) Number

func (AppVersionState_Status) String

func (x AppVersionState_Status) String() string

func (AppVersionState_Status) Type

type Distributor

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

Distributor manages the distribution of external traffic across application versions inside a single deployment location (e.g., a cluster inside GKE).

func Start

func Start(ctx context.Context,
	mux *http.ServeMux,
	store store.Store,
	logger *slog.Logger,
	manager endpoints.Manager,
	region string,
	babysitterConstructor func(cfg *config.GKEConfig, replicaSet, addr string) (endpoints.Babysitter, error),
	manageAppsInterval time.Duration,
	computeTrafficInterval time.Duration,
	applyTrafficInterval time.Duration,
	detectAppliedTrafficInterval time.Duration,
	applyTraffic func(context.Context, *nanny.TrafficAssignment) error,
	getListeners func(context.Context, *config.GKEConfig) ([]*nanny.Listener, error),
	getMetricCounts func(context.Context, string, ...string) ([]MetricCount, error),
) (*Distributor, error)

Start starts the distributor that manages the distribution of external traffic across applications' versions inside a single deployment location.

func (*Distributor) Cleanup

Cleanup registers the provided versions for Cleanup and also tries to clean them up.

func (*Distributor) ComputeTrafficAssignments

func (d *Distributor) ComputeTrafficAssignments(ctx context.Context, now time.Time) (time.Time, error)

ComputeTrafficAssignments computes traffic assignments across all active versions of the applications and returns the earliest time at which a version's desired traffic fraction will change.

func (*Distributor) Distribute

Distribute registers the provided versions for distribution and also tries to Distribute them.

func (*Distributor) GetApplicationState

GetApplicationState returns the latest application state.

func (*Distributor) GetPrivateTrafficAssignment

func (d *Distributor) GetPrivateTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)

GetPrivateTrafficAssignment collects per-application traffic assignments for private listeners and aggregates them into a single per-distributor traffic assignment for private listeners.

func (*Distributor) GetPublicTrafficAssignment

func (d *Distributor) GetPublicTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)

GetPublicTrafficAssignment collects per-application traffic assignments for public listeners and aggregates them into a single per-distributor traffic assignment for public listeners.

func (*Distributor) ManageAppStates

func (d *Distributor) ManageAppStates(ctx context.Context) error

manageState manages the application states and may trigger local and remote actions (e.g., update local state, send a deployment request to the manager).

func (*Distributor) RunProfiling

RunProfiling profiles a sample of the application version's replicas and computes a representative profile for the application version.

type DistributorState

type DistributorState struct {

	// The set of all applications.
	Applications []string `protobuf:"bytes,1,rep,name=applications,proto3" json:"applications,omitempty"`
	// The latest traffic assignment for public listeners.
	PublicTrafficAssignment *nanny.TrafficAssignment `` /* 132-byte string literal not displayed */
	// The latest traffic assignment for private listeners.
	PrivateTrafficAssignment *nanny.TrafficAssignment `` /* 135-byte string literal not displayed */
	// contains filtered or unexported fields
}

DistributorState contains the state maintained by the distributor.

func (*DistributorState) Descriptor deprecated

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

Deprecated: Use DistributorState.ProtoReflect.Descriptor instead.

func (*DistributorState) GetApplications

func (x *DistributorState) GetApplications() []string

func (*DistributorState) GetPrivateTrafficAssignment

func (x *DistributorState) GetPrivateTrafficAssignment() *nanny.TrafficAssignment

func (*DistributorState) GetPublicTrafficAssignment

func (x *DistributorState) GetPublicTrafficAssignment() *nanny.TrafficAssignment

func (*DistributorState) ProtoMessage

func (*DistributorState) ProtoMessage()

func (*DistributorState) ProtoReflect

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

func (*DistributorState) Reset

func (x *DistributorState) Reset()

func (*DistributorState) String

func (x *DistributorState) String() string

type HttpClient

type HttpClient struct {
	Addr   string       // babysitter address
	Client *http.Client // The HTTP client to use to make requests.
}

HttpClient is a Client that executes requests over HTTP.

func (*HttpClient) Cleanup

Cleanup implements the endpoints.Distributor interface.

func (*HttpClient) Distribute

Distribute implements the endpoints.Distributor interface.

func (*HttpClient) GetApplicationState

GetApplicationState implements the endpoints.Distributor interface.

func (*HttpClient) GetPrivateTrafficAssignment

func (h *HttpClient) GetPrivateTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)

GetPrivateTrafficAssignment implements the endpoints.Distributor interface.

func (*HttpClient) GetPublicTrafficAssignment

func (h *HttpClient) GetPublicTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)

GetPublicTrafficAssignment implements the endpoints.Distributor interface.

func (*HttpClient) RunProfiling

RunProfiling implements the endpoints.Distributor interface.

type MetricCount

type MetricCount struct {
	LabelVals []string
	Count     float64
}

MetricCount stores the count for a Counter metric, along with its label values.

Jump to

Keyboard shortcuts

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