As part of the work to fully achieve #46, pcache's handling of soft and hard limits needs to be re-designed to be per-service.
Right now it institutes a universal soft and hard limit, assuming all services are homogenous. In reality, services have different requirements. The pcache should compare against a service's custom requirements when doing its periodic updates. With PhysarumSM/service-registry#8 we now store a service's requirements in the registry.
General plan:
[x] Remove ReqPerf from PeerCache struct
[x] Add a service name variable to PeerInfo from common repo
The pcache-local RPeerInfo struct contains a PeerInfo
[x] Use a service-to-requirements map (can perhaps even use the new rcache?) to find the service's requirements
Can maybe add this as a member variable within PeerCache struct, or have it separate?
For maximum flexibility, can maybe pass an existing rcache into the constructor for pcache. If none was passed, it dynamically creates a new lookup structure.
Update loop should use this for comparison of latency
Some other minor clean-up and refactoring for clarity:
[x] Maybe rename ReqPerf to be LatPerf to be more specific
[x] With recent changes, the Address field of PeerRequest and PeerInfo are longer needed
[x] Rename comparison functions (e.g. RPeerInfoCompare, PerfIndCompare (from p2putil), and Compare (from p2putil)) to be indicitive of "less than"
[x] Centralize peer service name and hash into p2putil's PeerInfo struct
Can get rid of PeerRequest struct, as it's really only used in AddPeer()
It does muddy the PeerInfo struct a bit, it's more specifically tied to this project, but that should be fine
As part of the work to fully achieve #46,
pcache
's handling of soft and hard limits needs to be re-designed to be per-service.Right now it institutes a universal soft and hard limit, assuming all services are homogenous. In reality, services have different requirements. The
pcache
should compare against a service's custom requirements when doing its periodic updates. With PhysarumSM/service-registry#8 we now store a service's requirements in the registry.General plan:
ReqPerf
fromPeerCache
structPeerInfo
fromcommon
repoRPeerInfo
struct contains aPeerInfo
rcache
?) to find the service's requirementsPeerCache
struct, or have it separate?rcache
into the constructor forpcache
. If none was passed, it dynamically creates a new lookup structure.Some other minor clean-up and refactoring for clarity:
ReqPerf
to beLatPerf
to be more specificAddress
field ofPeerRequest
andPeerInfo
are longer neededRPeerInfoCompare
,PerfIndCompare
(from p2putil), andCompare
(from p2putil)) to be indicitive of "less than"p2putil
'sPeerInfo
structPeerRequest
struct, as it's really only used inAddPeer()
PeerInfo
struct a bit, it's more specifically tied to this project, but that should be fine