namespace_replication_queue.go ×6

Frontier kind: Code frontier

unlabeled · c_650f44329b71

7 tests · 4190 LOC · 178 files · introduces 0 tests · 90 LOC · 5 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges90 lines · 5 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
773 ranges4190 lines · 178 files · Browse complete extent
All tests (intent)
7 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

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 native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

5 files ranked by introduced lines: 90 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/persistence-tests/queue_persistence.go 36 introduced LOC · 3 ranges

Open complete file

48
49 // TestNamespaceReplicationQueue tests namespace replication queue operations
50 > func (s *QueuePersistenceSuite) TestNamespaceReplicationQueue() { queue_persistence.go
51 > numMessages := 100
52 > concurrentSenders := 10
53 >
54 > messageChan := make(chan *replicationspb.ReplicationTask)
55 >
56 > taskType := enumsspb.REPLICATION_TASK_TYPE_NAMESPACE_TASK
57 > go func() {
58 > for i := range numMessages {
59 > messageChan <- &replicationspb.ReplicationTask{
60 > TaskType: taskType,
61 > Attributes: &replicationspb.ReplicationTask_NamespaceTaskAttributes{
62 > NamespaceTaskAttributes: &replicationspb.NamespaceTaskAttributes{
63 > Id: fmt.Sprintf("message-%v", i),
64 > },
65 > },
66 > }
67 > }
68 > close(messageChan)
69 }()
70
71 > wg := sync.WaitGroup{} queue_persistence.go
72 > wg.Add(concurrentSenders)
73 >
74 > for i := range concurrentSenders {
75 > go func(senderNum int) {
76 > defer wg.Done()
77 > for message := range messageChan {
78 > err := s.Publish(s.ctx, message)
79 > id := message.Attributes.(*replicationspb.ReplicationTask_NamespaceTaskAttributes).NamespaceTaskAttributes.Id
80 > s.Nil(err, "Enqueue message failed when sender %d tried to send %s", senderNum, id)
81 > }
82 }(i)
83 }
84
85 > wg.Wait() queue_persistence.go
86 >
87 > result, lastRetrievedMessageID, err := s.GetReplicationMessages(s.ctx, persistence.EmptyQueueMessageID, numMessages)
88 > s.Nil(err, "GetReplicationMessages failed.")
89 > s.Len(result, numMessages)
90 > s.Equal(int64(numMessages-1), lastRetrievedMessageID)
91 }
92
go.temporal.io/server/common/persistence/persistence_metric_clients.go 18 introduced LOC · 2 ranges

Open complete file

1062 ctx context.Context,
1063 blob *commonpb.DataBlob,
1064 > ) (retErr error) { persistence_metric_clients.go
1065 > caller := headers.GetCallerInfo(ctx).CallerName
1066 > startTime := time.Now().UTC()
1067 > defer func() {
1068 > p.healthSignals.Record(CallerSegmentMissing, time.Since(startTime), retErr)
1069 > p.recordRequestMetrics(metrics.PersistenceEnqueueMessageScope, caller, time.Since(startTime), retErr)
1070 > p.recordDataLossMetrics(metrics.PersistenceEnqueueMessageScope, caller, retErr, "", "")
1071 > }()
1072 > return p.persistence.EnqueueMessage(ctx, blob)
1073 }
1074
1077 lastMessageID int64,
1078 maxCount int,
1079 > ) (_ []*QueueMessage, retErr error) { persistence_metric_clients.go
1080 > caller := headers.GetCallerInfo(ctx).CallerName
1081 > startTime := time.Now().UTC()
1082 > defer func() {
1083 > p.healthSignals.Record(CallerSegmentMissing, time.Since(startTime), retErr)
1084 > p.recordRequestMetrics(metrics.PersistenceReadQueueMessagesScope, caller, time.Since(startTime), retErr)
1085 > p.recordDataLossMetrics(metrics.PersistenceReadQueueMessagesScope, caller, retErr, "", "")
1086 > }()
1087 > return p.persistence.ReadMessages(ctx, lastMessageID, maxCount)
1088 }
1089
go.temporal.io/server/common/persistence/namespace_replication_queue.go 15 introduced LOC · 6 ranges

Open complete file

93 }
94
95 > func (q *namespaceReplicationQueueImpl) Publish(ctx context.Context, task *replicationspb.ReplicationTask) error { namespace_replication_queue.go
96 > blob, err := q.serializer.ReplicationTaskToBlob(task)
97 > if err != nil {
98 return fmt.Errorf("failed to encode message: %v", err)
99 }
100 > return q.queue.EnqueueMessage(ctx, blob) namespace_replication_queue.go
101 }
102
120 lastMessageID int64,
121 pageSize int,
122 > ) ([]*replicationspb.ReplicationTask, int64, error) { namespace_replication_queue.go
123 >
124 > messages, err := q.queue.ReadMessages(ctx, lastMessageID, pageSize)
125 > if err != nil {
126 return nil, lastMessageID, err
127 }
128
129 > replicationTasks := make([]*replicationspb.ReplicationTask, 0, len(messages)) namespace_replication_queue.go
130 > for _, message := range messages {
131 > replicationTask, err := q.serializer.ReplicationTaskFromBlob(NewDataBlob(message.Data, message.Encoding))
132 > if err != nil {
133 return nil, lastMessageID, fmt.Errorf("failed to decode task: %v", err)
134 }
135
136 > lastMessageID = message.ID namespace_replication_queue.go
137 > replicationTasks = append(replicationTasks, replicationTask)
138 }
139
140 > return replicationTasks, lastMessageID, nil namespace_replication_queue.go
141 }
142
go.temporal.io/server/common/persistence/persistence-tests/persistence_test_base.go 12 introduced LOC · 2 ranges

Open complete file

326
327 // Publish is a utility method to add messages to the queue
328 > func (s *TestBase) Publish(ctx context.Context, task *replicationspb.ReplicationTask) error { persistence_test_base.go
329 > retryPolicy := backoff.NewExponentialRetryPolicy(100 * time.Millisecond).
330 > WithBackoffCoefficient(1.5).
331 > WithMaximumAttempts(20)
332 >
333 > return backoff.ThrottleRetry(
334 > func() error {
335 > return s.NamespaceReplicationQueue.Publish(ctx, task)
336 > },
337 retryPolicy,
338 func(e error) bool {
351 lastMessageID int64,
352 pageSize int,
353 > ) ([]*replicationspb.ReplicationTask, int64, error) { persistence_test_base.go
354 > return s.NamespaceReplicationQueue.GetReplicationMessages(ctx, lastMessageID, pageSize)
355 > }
356
357 // UpdateAckLevel updates replication queue ack level
go.temporal.io/server/common/persistence/persistence_retryable_clients.go 9 introduced LOC · 2 ranges

Open complete file

1069 lastMessageID int64,
1070 maxCount int,
1071 > ) ([]*QueueMessage, error) { persistence_retryable_clients.go
1072 > var response []*QueueMessage
1073 > op := func(ctx context.Context) error {
1074 > var err error
1075 > response, err = p.persistence.ReadMessages(ctx, lastMessageID, maxCount)
1076 > return err
1077 > }
1078
1079 > err := backoff.ThrottleRetryContext(ctx, op, p.policy, p.isRetryable) persistence_retryable_clients.go
1080 > return response, err
1081 }
1082