mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-06 05:30:57 +00:00
feat: Add etcd database support
improve concurrent access and high availability of aptly with the help of the characteristics of etcd
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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{}
|
||||
)
|
||||
Reference in New Issue
Block a user