MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / nodeWrites

Method nodeWrites

tools/cache_perf_tool/processEntry.go:41–116  ·  view source on GitHub ↗
(ctx context.Context, node *sgwNode, delay time.Duration)

Source from the content-addressed store, hash-verified

39}
40
41func (p *processEntryGen) nodeWrites(ctx context.Context, node *sgwNode, delay time.Duration) {
42 docCount := uint64(0)
43 numGoroutines.Add(1)
44 defer numGoroutines.Add(-1)
45 // create map of configured channels, initialised channels are names test-x where x is integer between 0 and total
46 // number of system channels. Thus to assign to channels we can increment through channels initialised
47 chanCountZeroWait := 0
48 chanCountWait := 0
49 var chanMap channels.ChannelMap
50 if delay.Nanoseconds() == 0 {
51 // mutate as fast as possible
52 for {
53 chanMap = make(channels.ChannelMap, p.numChansPerDoc)
54 for range p.numChansPerDoc {
55 if chanCountZeroWait == p.totalChans {
56 // when count gets to total number configured channels we rest index to 0
57 chanCountZeroWait = 0
58 }
59 chanName := "test-" + strconv.Itoa(chanCountZeroWait)
60 chanMap[chanName] = nil
61 chanCountZeroWait++
62 }
63 select {
64 case <-ctx.Done():
65 return
66 default:
67 timeStamp := channels.NewFeedTimestampFromNow()
68 sgwSeqno := node.seqAlloc.nextSeq()
69 docCount++
70 logEntry := &db.LogEntry{
71 Sequence: sgwSeqno,
72 DocID: "key-" + strconv.FormatUint(docCount, 10) + "-" + strconv.FormatUint(sgwSeqno, 10),
73 RevID: "1-abc",
74 Flags: 0,
75 TimeReceived: timeStamp,
76 Channels: chanMap,
77 CollectionID: 0,
78 }
79 p.dbCtx.CallProcessEntry(p.t, ctx, logEntry)
80 }
81 }
82 }
83
84 ticker := time.NewTicker(delay)
85 defer ticker.Stop()
86 for {
87 chanMap = make(channels.ChannelMap, p.numChansPerDoc)
88 for range p.numChansPerDoc {
89 if chanCountWait == p.totalChans {
90 // when count gets to total number configured channels we rest index to 0
91 chanCountWait = 0
92 }
93 chanName := "test-" + strconv.Itoa(chanCountWait)
94 chanMap[chanName] = nil
95 chanCountWait++
96 }
97 select {
98 case <-ctx.Done():

Callers 1

Calls 6

NewFeedTimestampFromNowFunction · 0.92
DoneMethod · 0.80
nextSeqMethod · 0.80
CallProcessEntryMethod · 0.80
StopMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected