Files
tasks/common/persistence/nosql/nosqlplugin/cassandra/gocql/batch.go
Stephan BehnkeandGitHub c9e360a3fb go fix (#9337)
## 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)
2026-02-18 09:12:19 -08:00

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))
}
}