proxy

package
v1.17.7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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

func New(t *testing.T, sched *scheduler.Scheduler) *Proxy

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) Address

func (p *Proxy) Address() string

func (*Proxy) ArmFailures

func (p *Proxy) ArmFailures(method string, n int, code codes.Code, notify chan struct{})

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) Cleanup

func (p *Proxy) Cleanup(t *testing.T)

func (*Proxy) FailedCount

func (p *Proxy) FailedCount() int

func (*Proxy) GetJob

func (*Proxy) Port

func (p *Proxy) Port() int

func (*Proxy) Run

func (p *Proxy) Run(t *testing.T, ctx context.Context)

func (*Proxy) WatchHosts

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.

Jump to

Keyboard shortcuts

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