Documentation
¶
Index ¶
- Constants
- type Proxy
- func (p *Proxy) Address() string
- func (p *Proxy) ArmFailures(method 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) Port() int
- 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" )
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 Proxy ¶
type Proxy struct {
schedulerv1pb.UnimplementedSchedulerServer
// contains filtered or unexported fields
}
func New ¶
New returns a proxy that wraps the given scheduler. The proxy waits for the upstream to be reachable on Run, so framework process ordering relative to the scheduler is not required. 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) 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) 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.