mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-05 05:20:34 +00:00
78172d11d7
improve concurrent access and high availability of aptly with the help of the characteristics of etcd
35 lines
580 B
Go
35 lines
580 B
Go
package etcddb
|
|
|
|
import (
|
|
"github.com/aptly-dev/aptly/database"
|
|
clientv3 "go.etcd.io/etcd/client/v3"
|
|
)
|
|
|
|
type EtcDBatch struct {
|
|
db *clientv3.Client
|
|
}
|
|
|
|
type WriteOptions struct {
|
|
NoWriteMerge bool
|
|
Sync bool
|
|
}
|
|
|
|
func (b *EtcDBatch) Put(key, value []byte) (err error) {
|
|
_, err = b.db.Put(Ctx, string(key), string(value))
|
|
return
|
|
}
|
|
|
|
func (b *EtcDBatch) Delete(key []byte) (err error) {
|
|
_, err = b.db.Delete(Ctx, string(key))
|
|
return
|
|
}
|
|
|
|
func (b *EtcDBatch) Write() (err error) {
|
|
return
|
|
}
|
|
|
|
// batch should implement database.Batch
|
|
var (
|
|
_ database.Batch = &EtcDBatch{}
|
|
)
|