2021-04-17 17:13:29 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/reputation"
|
|
|
|
apireputation "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/reputation"
|
2021-04-17 17:13:29 +00:00
|
|
|
)
|
|
|
|
|
2023-04-05 07:44:40 +00:00
|
|
|
type EpochProvider interface {
|
2021-04-17 17:13:29 +00:00
|
|
|
// Must return epoch number to select the values.
|
|
|
|
Epoch() uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
// Writer describes the interface for storing reputation.Trust values.
|
|
|
|
//
|
|
|
|
// This interface is provided by both local storage
|
|
|
|
// of values and remote (wrappers over the RPC).
|
|
|
|
type Writer interface {
|
|
|
|
// Write performs a write operation of reputation.Trust value
|
|
|
|
// and returns any error encountered.
|
|
|
|
//
|
|
|
|
// All values after the Close call must be flushed to the
|
|
|
|
// physical target. Implementations can cache values before
|
|
|
|
// Close operation.
|
|
|
|
//
|
|
|
|
// Write must not be called after Close.
|
2023-04-05 07:44:40 +00:00
|
|
|
Write(context.Context, reputation.Trust) error
|
2021-04-17 17:13:29 +00:00
|
|
|
|
|
|
|
// Close exits with method-providing Writer.
|
|
|
|
//
|
|
|
|
// All cached values must be flushed before
|
|
|
|
// the Close's return.
|
|
|
|
//
|
|
|
|
// Methods must not be called after Close.
|
2023-04-05 07:44:40 +00:00
|
|
|
Close(context.Context) error
|
2021-04-17 17:13:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WriterProvider is a group of methods provided
|
|
|
|
// by entity which generates keepers of
|
|
|
|
// reputation.Trust values.
|
|
|
|
type WriterProvider interface {
|
|
|
|
// InitWriter should return an initialized Writer.
|
|
|
|
//
|
|
|
|
// Initialization problems are reported via error.
|
|
|
|
// If no error was returned, then the Writer must not be nil.
|
|
|
|
//
|
|
|
|
// Implementations can have different logic for different
|
|
|
|
// contexts, so specific ones may document their own behavior.
|
2023-04-05 07:44:40 +00:00
|
|
|
InitWriter(EpochProvider) (Writer, error)
|
2021-04-17 17:13:29 +00:00
|
|
|
}
|
2021-04-22 14:56:25 +00:00
|
|
|
|
|
|
|
// ManagerBuilder defines an interface for providing a list
|
|
|
|
// of Managers for specific epoch. Implementation depends on trust value.
|
|
|
|
type ManagerBuilder interface {
|
|
|
|
// BuildManagers must compose list of managers. It depends on
|
|
|
|
// particular epoch and PeerID of the current route point.
|
2022-07-04 13:24:51 +00:00
|
|
|
BuildManagers(epoch uint64, p apireputation.PeerID) ([]ServerInfo, error)
|
2021-04-23 14:54:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ServerInfo describes a set of
|
|
|
|
// characteristics of a point in a route.
|
|
|
|
type ServerInfo interface {
|
|
|
|
// PublicKey returns public key of the node
|
|
|
|
// from the route in a binary representation.
|
|
|
|
PublicKey() []byte
|
|
|
|
|
2021-06-22 16:00:00 +00:00
|
|
|
// Iterates over network addresses of the node
|
|
|
|
// in the route. Breaks iterating on true return
|
|
|
|
// of the handler.
|
|
|
|
IterateAddresses(func(string) bool)
|
|
|
|
|
|
|
|
// Returns number of server's network addresses.
|
|
|
|
NumberOfAddresses() int
|
2022-09-26 12:34:01 +00:00
|
|
|
|
|
|
|
// ExternalAddresses returns external addresses of a node.
|
|
|
|
ExternalAddresses() []string
|
2021-04-22 14:56:25 +00:00
|
|
|
}
|