| 1 | package control |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | |
| 6 | "reasonix/internal/session" |
| 7 | ) |
| 8 | |
| 9 | func (c *Controller) appendSessionBatch(ctx context.Context, store *session.Session, batch session.Batch) (session.Commit, error) { |
| 10 | if store == nil { |
| 11 | return session.Commit{}, session.ErrSessionNotRunning |
| 12 | } |
| 13 | if ctx == nil { |
| 14 | ctx = context.Background() |
| 15 | } |
| 16 | if err := ctx.Err(); err != nil { |
| 17 | return session.Commit{}, err |
| 18 | } |
| 19 | prepared, err := store.PrepareBatchContext(ctx, batch.OperationID, batch) |
| 20 | if err != nil { |
| 21 | return session.Commit{}, err |
| 22 | } |
| 23 | _, runtime, exclusive := c.v3Binding() |
| 24 | if exclusive && runtime != nil && runtime.Session() == store { |
| 25 | return runtime.CommitPreparedForExecution(c.ExecutionGeneration(), prepared) |
| 26 | } |
| 27 | return store.CommitPrepared(prepared) |
| 28 | } |
| 29 |