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 ¶
- Variables
- type AppState
- func (*AppState) Descriptor() ([]byte, []int)deprecated
- func (x *AppState) GetDeletedVersions() []string
- func (x *AppState) GetVersions() []*AppVersionState
- func (*AppState) ProtoMessage()
- func (x *AppState) ProtoReflect() protoreflect.Message
- func (x *AppState) Reset()
- func (x *AppState) String() string
- type AppVersionState
- func (*AppVersionState) Descriptor() ([]byte, []int)deprecated
- func (x *AppVersionState) GetConfig() *config.GKEConfig
- func (x *AppVersionState) GetListeners() []*nanny.Listener
- func (x *AppVersionState) GetOrder() int64
- func (x *AppVersionState) GetReplicaSets() []*nanny.ReplicaSet
- func (x *AppVersionState) GetSchedule() *nanny.Schedule
- func (x *AppVersionState) GetStatus() AppVersionState_Status
- func (x *AppVersionState) GetStoppedTime() *timestamppb.Timestamp
- func (*AppVersionState) ProtoMessage()
- func (x *AppVersionState) ProtoReflect() protoreflect.Message
- func (x *AppVersionState) Reset()
- func (x *AppVersionState) String() string
- type AppVersionState_Status
- func (AppVersionState_Status) Descriptor() protoreflect.EnumDescriptor
- func (x AppVersionState_Status) Enum() *AppVersionState_Status
- func (AppVersionState_Status) EnumDescriptor() ([]byte, []int)deprecated
- func (x AppVersionState_Status) Number() protoreflect.EnumNumber
- func (x AppVersionState_Status) String() string
- func (AppVersionState_Status) Type() protoreflect.EnumType
- type Distributor
- func (d *Distributor) Cleanup(ctx context.Context, req *nanny.ApplicationCleanupRequest) error
- func (d *Distributor) ComputeTrafficAssignments(ctx context.Context, now time.Time) (time.Time, error)
- func (d *Distributor) Distribute(ctx context.Context, req *nanny.ApplicationDistributionRequest) error
- func (d *Distributor) GetApplicationState(ctx context.Context, req *nanny.ApplicationStateAtDistributorRequest) (*nanny.ApplicationStateAtDistributor, error)
- func (d *Distributor) GetPrivateTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)
- func (d *Distributor) GetPublicTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)
- func (d *Distributor) ManageAppStates(ctx context.Context) error
- func (d *Distributor) RunProfiling(ctx context.Context, req *nanny.GetProfileRequest) (*protos.GetProfileReply, error)
- type DistributorState
- func (*DistributorState) Descriptor() ([]byte, []int)deprecated
- func (x *DistributorState) GetApplications() []string
- func (x *DistributorState) GetPrivateTrafficAssignment() *nanny.TrafficAssignment
- func (x *DistributorState) GetPublicTrafficAssignment() *nanny.TrafficAssignment
- func (*DistributorState) ProtoMessage()
- func (x *DistributorState) ProtoReflect() protoreflect.Message
- func (x *DistributorState) Reset()
- func (x *DistributorState) String() string
- type HttpClient
- func (h *HttpClient) Cleanup(ctx context.Context, req *nanny.ApplicationCleanupRequest) error
- func (h *HttpClient) Distribute(ctx context.Context, req *nanny.ApplicationDistributionRequest) error
- func (h *HttpClient) GetApplicationState(ctx context.Context, req *nanny.ApplicationStateAtDistributorRequest) (*nanny.ApplicationStateAtDistributor, error)
- func (h *HttpClient) GetPrivateTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)
- func (h *HttpClient) GetPublicTrafficAssignment(ctx context.Context) (*nanny.TrafficAssignment, error)
- func (h *HttpClient) RunProfiling(ctx context.Context, req *nanny.GetProfileRequest) (*protos.GetProfileReply, error)
- type MetricCount
Constants ¶
This section is empty.
Variables ¶
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.
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) GetDeletedVersions ¶
func (*AppState) GetVersions ¶
func (x *AppState) GetVersions() []*AppVersionState
func (*AppState) ProtoMessage ¶
func (*AppState) ProtoMessage()
func (*AppState) ProtoReflect ¶
func (x *AppState) ProtoReflect() protoreflect.Message
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) Descriptor() protoreflect.EnumDescriptor
func (AppVersionState_Status) Enum ¶
func (x AppVersionState_Status) Enum() *AppVersionState_Status
func (AppVersionState_Status) EnumDescriptor
deprecated
func (AppVersionState_Status) EnumDescriptor() ([]byte, []int)
Deprecated: Use AppVersionState_Status.Descriptor instead.
func (AppVersionState_Status) Number ¶
func (x AppVersionState_Status) Number() protoreflect.EnumNumber
func (AppVersionState_Status) String ¶
func (x AppVersionState_Status) String() string
func (AppVersionState_Status) Type ¶
func (AppVersionState_Status) Type() protoreflect.EnumType
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 ¶
func (d *Distributor) Cleanup(ctx context.Context, req *nanny.ApplicationCleanupRequest) error
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 ¶
func (d *Distributor) Distribute(ctx context.Context, req *nanny.ApplicationDistributionRequest) error
Distribute registers the provided versions for distribution and also tries to Distribute them.
func (*Distributor) GetApplicationState ¶
func (d *Distributor) GetApplicationState(ctx context.Context, req *nanny.ApplicationStateAtDistributorRequest) (*nanny.ApplicationStateAtDistributor, error)
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 ¶
func (d *Distributor) RunProfiling(ctx context.Context, req *nanny.GetProfileRequest) (*protos.GetProfileReply, error)
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 ¶
func (h *HttpClient) Cleanup(ctx context.Context, req *nanny.ApplicationCleanupRequest) error
Cleanup implements the endpoints.Distributor interface.
func (*HttpClient) Distribute ¶
func (h *HttpClient) Distribute(ctx context.Context, req *nanny.ApplicationDistributionRequest) error
Distribute implements the endpoints.Distributor interface.
func (*HttpClient) GetApplicationState ¶
func (h *HttpClient) GetApplicationState(ctx context.Context, req *nanny.ApplicationStateAtDistributorRequest) (*nanny.ApplicationStateAtDistributor, error)
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 ¶
func (h *HttpClient) RunProfiling(ctx context.Context, req *nanny.GetProfileRequest) (*protos.GetProfileReply, error)
RunProfiling implements the endpoints.Distributor interface.
type MetricCount ¶
MetricCount stores the count for a Counter metric, along with its label values.