From c38a8eddc898059e2ba948c64b710c6a4bb47c4c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 4 May 2020 14:03:11 +0300 Subject: [PATCH] service: use value container interfaces --- service/meta.go | 33 ++++----------------------------- service/ttl.go | 8 +------- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/service/meta.go b/service/meta.go index 2675b79..2714f08 100644 --- a/service/meta.go +++ b/service/meta.go @@ -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 } ) diff --git a/service/ttl.go b/service/ttl.go index c79cc85..28a5092 100644 --- a/service/ttl.go +++ b/service/ttl.go @@ -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 {