add peer state

This commit is contained in:
mr
2024-10-15 16:37:18 +02:00
parent 9f5e6d6018
commit 73602b6c3d
2 changed files with 16 additions and 2 deletions

View File

@@ -10,13 +10,25 @@ import (
"github.com/google/uuid"
)
// now write a go enum for the state partner with self, blacklist, partner
type PeerState int
const (
NONE PeerState = iota
SELF
PARTNER
BLACKLIST
)
// Peer is a struct that represents a peer
type Peer struct {
utils.AbstractObject
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required,base64url"` // Url is the URL of the peer (base64url)
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"` // PublicKey is the public key of the peer
Services map[string]int `json:"services,omitempty" bson:"services,omitempty"` // Services is the services of the peer
FailedExecution []PeerExecution `json:"failed_execution" bson:"failed_execution"` // FailedExecution is the list of failed executions, to be retried
Services map[string]int `json:"services,omitempty" bson:"services,omitempty"`
State PeerState `json:"state" bson:"state" default:"0"`
FailedExecution []PeerExecution `json:"failed_execution" bson:"failed_execution"` // FailedExecution is the list of failed executions, to be retried
}
// AddExecution adds an execution to the list of failed executions