Skip to content

Commit

Permalink
remove duplicate logic
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpertsov committed Oct 18, 2022
1 parent addd1d4 commit 684db1a
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions operation/opid.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,7 @@ func (m *Manager) FindString(id string) *Operation {

// Create puts an operation on this context.
func (m *Manager) Create(ctx context.Context, method string, args interface{}) (context.Context, func()) {
if ctx.Value(opidKey) != nil {
panic("operations cannot be nested")
}

for _, val := range methodPrefixesToFilter {
if strings.HasPrefix(method, val) {
return ctx, func() {}
}
}

op := &Operation{
ID: uuid.New(),
Method: method,
Arguments: args,
Started: time.Now(),
myManager: m,
}
ctx = context.WithValue(ctx, opidKey, op)
ctx, op.cancel = context.WithCancel(ctx)
m.add(op)

return ctx, func() { op.cleanup() }
return m.createWithID(ctx, uuid.New(), method, args)
}

func (m *Manager) createWithID(ctx context.Context, id uuid.UUID, method string, args interface{}) (context.Context, func()) {
Expand Down

0 comments on commit 684db1a

Please sign in to comment.