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:
hudeng
2022-02-08 11:16:16 +08:00
committed by André Roth
parent f42ff697d4
commit 78172d11d7
14 changed files with 497 additions and 6 deletions
+34
View File
@@ -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{}
)