Documentation
¶
Index ¶
- Constants
- type Option
- type Proxy
- func (p *Proxy) Address() string
- func (p *Proxy) ArmFailures(method string, n int, code codes.Code, notify chan struct{})
- func (p *Proxy) ArmNamedFailures(method, nameContains string, n int, code codes.Code, notify chan struct{})
- func (p *Proxy) Cleanup(t *testing.T)
- func (p *Proxy) DeleteByMetadata(ctx context.Context, req *schedulerv1pb.DeleteByMetadataRequest) (*schedulerv1pb.DeleteByMetadataResponse, error)
- func (p *Proxy) DeleteByNamePrefix(ctx context.Context, req *schedulerv1pb.DeleteByNamePrefixRequest) (*schedulerv1pb.DeleteByNamePrefixResponse, error)
- func (p *Proxy) DeleteJob(ctx context.Context, req *schedulerv1pb.DeleteJobRequest) (*schedulerv1pb.DeleteJobResponse, error)
- func (p *Proxy) FailedCount() int
- func (p *Proxy) GetJob(ctx context.Context, req *schedulerv1pb.GetJobRequest) (*schedulerv1pb.GetJobResponse, error)
- func (p *Proxy) ListJobs(ctx context.Context, req *schedulerv1pb.ListJobsRequest) (*schedulerv1pb.ListJobsResponse, error)
- func (p *Proxy) Partition(t *testing.T)
- func (p *Proxy) Port() int
- func (p *Proxy) ReportActorTypes(stream schedulerv1pb.Scheduler_ReportActorTypesServer) error
- func (p *Proxy) Run(t *testing.T, ctx context.Context)
- func (p *Proxy) ScheduleJob(ctx context.Context, req *schedulerv1pb.ScheduleJobRequest) (*schedulerv1pb.ScheduleJobResponse, error)
- func (p *Proxy) WatchHosts(req *schedulerv1pb.WatchHostsRequest, ...) error
- func (p *Proxy) WatchJobs(stream schedulerv1pb.Scheduler_WatchJobsServer) error
Constants ¶
const ( MethodScheduleJob = "ScheduleJob" MethodDeleteJob = "DeleteJob" MethodGetJob = "GetJob" MethodListJobs = "ListJobs" MethodDeleteByMetadata = "DeleteByMetadata" MethodDeleteByNamePrefix = "DeleteByNamePrefix" MethodWatchHosts = "WatchHosts" MethodWatchJobs = "WatchJobs" MethodReportActorTypes = "ReportActorTypes" )
Method names used with ArmFailures. Using typed constants keeps tests from drifting if a method is renamed.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Proxy)
Option configures the proxy.
func WithSentry ¶
WithSentry makes the proxy a full mTLS member of the control plane. It serves daprd with a leaf certificate minted from the sentry CA carrying the scheduler control-plane SPIFFE identity, and dials the upstream scheduler presenting the identity of the daprd app whose requests it forwards (the scheduler authorizes each request against the caller's SPIFFE identity, so the proxy must impersonate the app, which therefore must run with the given fixed app ID). The upstream scheduler must be built with scheduler.WithSentry and an ID matching its certificate DNS names.
type Proxy ¶
type Proxy struct {
schedulerv1pb.UnimplementedSchedulerServer
// contains filtered or unexported fields
}
func New ¶
New returns a proxy that wraps the given scheduler. Run blocks until the upstream is reachable, so the scheduler must precede the proxy in framework process ordering. daprd should be configured with daprd.WithSchedulerAddresses(proxy.Address()) instead of pointing at the scheduler directly.
func (*Proxy) ArmFailures ¶
ArmFailures arms the proxy to fail the next n requests to the given method with the supplied gRPC status code. n=0 disarms. If notify is non-nil it is closed the first time a matching call is failed.
Choose the code with care: the daprd-side CreateReminderWithRetry transparently retries codes.Unavailable / codes.DeadlineExceeded with exponential backoff (up to a minute), so injecting those codes only stalls the call instead of surfacing the failure. Use codes.Internal / codes.Aborted or another non-transient code when the test wants the failure to propagate to the orchestrator's error path.
func (*Proxy) ArmNamedFailures ¶ added in v1.18.4
func (p *Proxy) ArmNamedFailures(method, nameContains string, n int, code codes.Code, notify chan struct{})
ArmNamedFailures is ArmFailures restricted to requests whose job name contains nameContains; requests for other jobs pass through untouched.
func (*Proxy) DeleteByMetadata ¶
func (p *Proxy) DeleteByMetadata(ctx context.Context, req *schedulerv1pb.DeleteByMetadataRequest) (*schedulerv1pb.DeleteByMetadataResponse, error)
func (*Proxy) DeleteByNamePrefix ¶
func (p *Proxy) DeleteByNamePrefix(ctx context.Context, req *schedulerv1pb.DeleteByNamePrefixRequest) (*schedulerv1pb.DeleteByNamePrefixResponse, error)
func (*Proxy) DeleteJob ¶
func (p *Proxy) DeleteJob(ctx context.Context, req *schedulerv1pb.DeleteJobRequest) (*schedulerv1pb.DeleteJobResponse, error)
func (*Proxy) FailedCount ¶
func (*Proxy) GetJob ¶
func (p *Proxy) GetJob(ctx context.Context, req *schedulerv1pb.GetJobRequest) (*schedulerv1pb.GetJobResponse, error)
func (*Proxy) ListJobs ¶
func (p *Proxy) ListJobs(ctx context.Context, req *schedulerv1pb.ListJobsRequest) (*schedulerv1pb.ListJobsResponse, error)
func (*Proxy) Partition ¶
Partition blackholes all daprd connections to this proxy and closes the upstream, so the scheduler evicts the hosts. It cannot be undone.
func (*Proxy) ReportActorTypes ¶
func (p *Proxy) ReportActorTypes(stream schedulerv1pb.Scheduler_ReportActorTypesServer) error
func (*Proxy) ScheduleJob ¶
func (p *Proxy) ScheduleJob(ctx context.Context, req *schedulerv1pb.ScheduleJobRequest) (*schedulerv1pb.ScheduleJobResponse, error)
func (*Proxy) WatchHosts ¶
func (p *Proxy) WatchHosts(req *schedulerv1pb.WatchHostsRequest, stream schedulerv1pb.Scheduler_WatchHostsServer) error
WatchHosts forwards host updates from the upstream scheduler, rewriting every Host.Address so daprd reconnects to the proxy rather than to the real scheduler on every refresh. Without this rewrite daprd would bypass the proxy as soon as the first host list arrived.
func (*Proxy) WatchJobs ¶
func (p *Proxy) WatchJobs(stream schedulerv1pb.Scheduler_WatchJobsServer) error
WatchJobs bidirectionally forwards messages between the daprd-side stream and the upstream scheduler stream. When either direction errors we cancel the shared context to unblock the other goroutine and drain its error so no goroutine leaks.