go.temporal.io/server/common/clock/context.go

74 LOC · 39 covered · 35 uncovered · 9 ranges · 26 concepts · 7 introducers · 16 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileTestPerKeyRateLimit · 0 introduced LOCTestPerKeyRateLimitTestPerKeyRateLimitRecycleWakesBlockedMatch · 0 introduced LOCTestPerKeyRateLimitRecyc…ratelimit_manager.go ×1 · 2 introduced LOCratelimit_manager.go ×1TestPerKeyRateLimitDoesNotBlockOtherKeys · 0 introduced LOCTestPerKeyRateLimitDoesN…TestRateLimitedBacklog · 0 introduced LOCTestRateLimitedBacklogratelimit_manager.go ×4 · 30 introduced LOCratelimit_manager.go ×4matcher_data.go ×1 · 5 introduced LOCmatcher_data.go ×1TestPollForwardFailed · 0 introduced LOCTestPollForwardFailedTestPollForwardSuccess · 0 introduced LOCTestPollForwardSuccessmatcher_data.go ×1 · 3 introduced LOCmatcher_data.go ×1TestQueryForwardResponse · 0 introduced LOCTestQueryForwardResponseTestTaskForward · 0 introduced LOCTestTaskForwardTestQuery · 0 introduced LOCTestQueryTestQueryForwardError · 0 introduced LOCTestQueryForwardErrorTestQueryForwardNil · 0 introduced LOCTestQueryForwardNilTestOrder · 0 introduced LOCTestOrderbatcher.go ×4 · 18 introduced LOCbatcher.go ×4batcher.go ×1 · 3 introduced LOCbatcher.go ×1context.go ×1 · 2 introduced LOCcontext.go ×1context.go ×1 · 5 introduced LOCcontext.go ×1TestContextWithTimeout_Canceled · 0 introduced LOCTestContextWithTimeout_C…context.go ×1 · 3 introduced LOCcontext.go ×1context.go ×1 · 4 introduced LOCcontext.go ×1context.go ×1 · 7 introduced LOCcontext.go ×1context.go ×1 · 3 introduced LOCcontext.go ×1context.go ×3 · 15 introduced LOCcontext.go ×3TestContextWithTimeout_Canceled · introduced test · go.temporal.io/server/common/clock/TestContextWithTimeout_CanceledTestContextWithTimeout_C…TestContextWithTimeout_Fire · introduced test · go.temporal.io/server/common/clock/TestContextWithTimeout_FireTestContextWithTimeout_F…TestStreamBatcher_AddTimeout · introduced test · go.temporal.io/server/common/stream_batcher/TestStreamBatcher_AddTimeoutTestStreamBatcher_AddTim…TestStreamBatcher_Random · introduced test · go.temporal.io/server/common/stream_batcher/TestStreamBatcher_RandomTestStreamBatcher_RandomTestOrder · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestOrderTestOrderTestPerKeyRateLimit · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestPerKeyRateLimitTestPerKeyRateLimitTestPerKeyRateLimitDoesNotBlockOtherKeys · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestPerKeyRateLimitDoesNotBlockOtherKeysTestPerKeyRateLimitDoesN…TestPerKeyRateLimitRecycleWakesBlockedMatch · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestPerKeyRateLimitRecycleWakesBlockedMatchTestPerKeyRateLimitRecyc…TestPollForwardFailed · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestPollForwardFailedTestPollForwardFailedTestPollForwardSuccess · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestPollForwardSuccessTestPollForwardSuccessTestQuery · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestQueryTestQueryTestQueryForwardError · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestQueryForwardErrorTestQueryForwardErrorTestQueryForwardNil · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestQueryForwardNilTestQueryForwardNilTestQueryForwardResponse · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestQueryForwardResponseTestQueryForwardResponseTestRateLimitedBacklog · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestRateLimitedBacklogTestRateLimitedBacklogTestTaskForward · introduced test · go.temporal.io/server/service/matching/TestMatcherDataSuite/TestTaskForwardTestTaskForwardFocused file · go.temporal.io/server/common/clock/context.go · 74 LOCclock/context.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package clock
2
3 import (
4 "context"
5 "sync"
6 "time"
7 )
8
9 type ctxWithDeadline struct {
10 context.Context
11 deadline time.Time
12 timer Timer
13 once sync.Once
14 done chan struct{}
15 err error
16 }
17
18 > func (ctx *ctxWithDeadline) Deadline() (deadline time.Time, ok bool) { context.go ×1
19 > return ctx.deadline, true
20 > }
21
22 > func (ctx *ctxWithDeadline) Done() <-chan struct{} { context.go ×1
23 > return ctx.done
24 > }
25
26 > func (ctx *ctxWithDeadline) Err() error { context.go ×1
27 > select {
28 > case <-ctx.done:
29 > return ctx.err
30 > default: context.go ×1
31 > return nil
32 }
33 }
34
35 > func (ctx *ctxWithDeadline) deadlineExceeded() { context.go ×1
36 > ctx.once.Do(func() {
37 > ctx.err = context.DeadlineExceeded
38 > close(ctx.done)
39 > })
40 }
41
42 > func (ctx *ctxWithDeadline) cancel() { context.go ×3
43 > ctx.once.Do(func() {
44 > // We'd like to call ctx.timer.Stop() here, but we can't: the time source may call context.go ×1
45 > // deadlineExceeded while holding its lock, which acquires the once mutex. Here we have
46 > // the once mutex and want to cancel a timer, which would create a potential lock
47 > // cycle. So just leave the timer as a no-op.
48 > ctx.err = context.Canceled
49 > close(ctx.done)
50 > })
51 }
52
53 func ContextWithDeadline(
54 ctx context.Context,
55 deadline time.Time,
56 timeSource TimeSource,
57 > ) (context.Context, context.CancelFunc) { context.go ×3
58 > ctxd := &ctxWithDeadline{
59 > Context: ctx,
60 > deadline: deadline,
61 > done: make(chan struct{}),
62 > }
63 > timer := timeSource.AfterFunc(deadline.Sub(timeSource.Now()), ctxd.deadlineExceeded)
64 > ctxd.timer = timer
65 > return ctxd, ctxd.cancel
66 > }
67
68 func ContextWithTimeout(
69 ctx context.Context,
70 timeout time.Duration,
71 timeSource TimeSource,
72 > ) (context.Context, context.CancelFunc) { context.go ×3
73 > return ContextWithDeadline(ctx, timeSource.Now().Add(timeout), timeSource)
74 > }