Umstellung auf uuid
All checks were successful
release-tag / release-image (push) Successful in 1m32s
All checks were successful
release-tag / release-image (push) Successful in 1m32s
This commit is contained in:
@@ -41,7 +41,7 @@ type Peer struct {
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
ID int64 `json:"id"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
Deleted bool `json:"deleted"` // <— NEU: Tombstone für Deletes
|
||||
@@ -55,7 +55,7 @@ type Snapshot struct {
|
||||
type Callbacks struct {
|
||||
GetSnapshot func(ctx context.Context) (Snapshot, error)
|
||||
ApplyRemote func(ctx context.Context, s Snapshot) error
|
||||
BlobOpen func(ctx context.Context, id int64) (io.ReadCloser, string, string, int64, error)
|
||||
BlobOpen func(ctx context.Context, id string) (io.ReadCloser, string, string, int64, error)
|
||||
}
|
||||
|
||||
/*** Node ***/
|
||||
@@ -447,11 +447,11 @@ func (n *Node) SyncNow(ctx context.Context) error {
|
||||
/*** Utilities ***/
|
||||
|
||||
// OwnerHint is a simple, optional mapping to distribute responsibility.
|
||||
func OwnerHint(id int64, peers []string) int {
|
||||
func OwnerHint(id string, peers []string) int {
|
||||
if len(peers) == 0 {
|
||||
return 0
|
||||
}
|
||||
h := crc32.ChecksumIEEE([]byte(string(rune(id))))
|
||||
h := crc32.ChecksumIEEE([]byte(id))
|
||||
return int(h % uint32(len(peers)))
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ func (n *Node) blobHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
ID int64 `json:"id"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &req); err != nil {
|
||||
http.Error(w, "bad json", http.StatusBadRequest)
|
||||
@@ -530,9 +530,9 @@ func (n *Node) blobHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// interner Helper: signierter Blob-Request an einen Peer
|
||||
func (n *Node) sendBlobRequest(url string, id int64) (*http.Response, error) {
|
||||
func (n *Node) sendBlobRequest(url string, id string) (*http.Response, error) {
|
||||
b, _ := json.Marshal(struct {
|
||||
ID int64 `json:"id"`
|
||||
ID string `json:"id"`
|
||||
}{ID: id})
|
||||
req, _ := http.NewRequest(http.MethodPost, strings.TrimRight(url, "/")+"/mesh/blob", bytes.NewReader(b))
|
||||
req.Header.Set("X-Mesh-Sig", n.sign(b))
|
||||
@@ -540,7 +540,7 @@ func (n *Node) sendBlobRequest(url string, id int64) (*http.Response, error) {
|
||||
}
|
||||
|
||||
// Öffentliche Methode: versuche Blob bei irgendeinem Peer zu holen
|
||||
func (n *Node) FetchBlobAny(ctx context.Context, id int64) (io.ReadCloser, string, string, int64, error) {
|
||||
func (n *Node) FetchBlobAny(ctx context.Context, id string) (io.ReadCloser, string, string, int64, error) {
|
||||
n.mu.RLock()
|
||||
targets := make([]string, 0, len(n.peers))
|
||||
for url := range n.peers {
|
||||
@@ -574,5 +574,5 @@ func (n *Node) FetchBlobAny(ctx context.Context, id int64) (io.ReadCloser, strin
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
}
|
||||
return nil, "", "", 0, fmt.Errorf("blob %d not found on peers", id)
|
||||
return nil, "", "", 0, fmt.Errorf("blob %s not found on peers", id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user