service: use value container interfaces

This commit is contained in:
Leonard Lyubich 2020-05-04 14:03:11 +03:00
parent 8270245455
commit c38a8eddc8
2 changed files with 5 additions and 36 deletions

View file

@ -9,35 +9,10 @@ type (
ResetMeta() RequestMetaHeader
RestoreMeta(RequestMetaHeader)
// TTLHeader allows to get and set TTL value of request.
TTLHeader
// EpochHeader gives possibility to get or set epoch in RPC Requests.
EpochHeader
// VersionHeader allows get or set version of protocol request
VersionHeader
// RawHeader allows to get and set raw option of request
RawHeader
}
// EpochHeader interface gives possibility to get or set epoch in RPC Requests.
EpochHeader interface {
GetEpoch() uint64
SetEpoch(v uint64)
}
// VersionHeader allows get or set version of protocol request
VersionHeader interface {
GetVersion() uint32
SetVersion(uint32)
}
// RawHeader is an interface of the container of a boolean Raw value
RawHeader interface {
GetRaw() bool
SetRaw(bool)
TTLContainer
EpochContainer
VersionContainer
RawContainer
}
)

View file

@ -6,12 +6,6 @@ import (
"google.golang.org/grpc/status"
)
// TTLHeader is an interface of the container of a numerical TTL value.
type TTLHeader interface {
GetTTL() uint32
SetTTL(uint32)
}
// TTL constants.
const (
// ZeroTTL is an upper bound of invalid TTL values.
@ -41,7 +35,7 @@ func IRNonForwarding(role NodeRole) TTLCondition {
}
// ProcessRequestTTL validates and updates requests with TTL.
func ProcessRequestTTL(req TTLHeader, cond ...TTLCondition) error {
func ProcessRequestTTL(req TTLContainer, cond ...TTLCondition) error {
ttl := req.GetTTL()
if ttl == ZeroTTL {