mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
## What changed? Integrate Go 1.26's new `go fix` into workflow. NOTE that the changes caused our linter to fire; a [separate commit](https://github.com/temporalio/temporal/pull/9337/commits/1b23f787aef370098b35829c4d17dcc06230b4c1) addresses those. ## Why? Ensure Go code is standardized/modernized. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
60 lines
1.0 KiB
Go
60 lines
1.0 KiB
Go
package gocql
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/gocql/gocql"
|
|
)
|
|
|
|
type (
|
|
Batch struct {
|
|
session *session
|
|
|
|
gocqlBatch *gocql.Batch
|
|
}
|
|
)
|
|
|
|
// Definition of all BatchTypes
|
|
const (
|
|
LoggedBatch BatchType = iota
|
|
UnloggedBatch
|
|
CounterBatch
|
|
)
|
|
|
|
func newBatch(
|
|
session *session,
|
|
gocqlBatch *gocql.Batch,
|
|
) *Batch {
|
|
return &Batch{
|
|
session: session,
|
|
gocqlBatch: gocqlBatch,
|
|
}
|
|
}
|
|
|
|
func (b *Batch) Query(stmt string, args ...any) {
|
|
b.gocqlBatch.Query(stmt, args...)
|
|
}
|
|
|
|
func (b *Batch) WithContext(ctx context.Context) *Batch {
|
|
return newBatch(b.session, b.gocqlBatch.WithContext(ctx))
|
|
}
|
|
|
|
func (b *Batch) WithTimestamp(timestamp int64) *Batch {
|
|
b.gocqlBatch.WithTimestamp(timestamp)
|
|
return newBatch(b.session, b.gocqlBatch)
|
|
}
|
|
|
|
func mustConvertBatchType(batchType BatchType) gocql.BatchType {
|
|
switch batchType {
|
|
case LoggedBatch:
|
|
return gocql.LoggedBatch
|
|
case UnloggedBatch:
|
|
return gocql.UnloggedBatch
|
|
case CounterBatch:
|
|
return gocql.CounterBatch
|
|
default:
|
|
panic(fmt.Sprintf("Unknown gocql BatchType: %v", batchType))
|
|
}
|
|
}
|