MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / prepare

Method prepare

twopc/twopc.go:80–105  ·  view source on GitHub ↗
(ctx context.Context, workers []Worker, wb WriteBatch)

Source from the content-addressed store, hash-verified

78}
79
80func (c *Coordinator) prepare(ctx context.Context, workers []Worker, wb WriteBatch) (err error) {
81 errs := make([]error, len(workers))
82 wg := sync.WaitGroup{}
83 workerFunc := func(n Worker, e *error, wg *sync.WaitGroup) {
84 defer wg.Done()
85
86 *e = n.Prepare(ctx, wb)
87 }
88
89 for index, worker := range workers {
90 wg.Add(1)
91 go workerFunc(worker, &errs[index], &wg)
92 }
93
94 wg.Wait()
95
96 var index int
97 for index, err = range errs {
98 if err != nil {
99 log.WithField("worker", workers[index]).WithError(err).Debug("prepare failed")
100 return
101 }
102 }
103
104 return
105}
106
107func (c *Coordinator) rollback(ctx context.Context, workers []Worker, wb WriteBatch) (err error) {
108 errs := make([]error, len(workers))

Callers 1

PutMethod · 0.95

Calls 6

WithFieldFunction · 0.92
WaitMethod · 0.80
DebugMethod · 0.80
WithErrorMethod · 0.80
PrepareMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected