-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(idpool): idpool feature for generating id's #400
base: main
Are you sure you want to change the base?
Conversation
pkg/utils/Idpool.go
Outdated
_unusedIDs []uint32 // Yet unused IDs in pool Available ids | ||
_idsInUse map[interface{}]uint32 // Mapping key: id for currently assigned ids | ||
_idsForReuse map[interface{}]uint32 // Mapping key: id for previously assigned ids | ||
_refs map[uint32][]interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refs sounds like a counter tracking how many times we requested the same id, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, its reference to the same id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then why do we need a slice of slices then? Can we have a slice of counters? map[uint32]uint32
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually we need golang type equivalent of 'list' type in python.
we have replaced with "ref map[uint32]map[interface{}]bool"
here the scenario is for same key we can have different references of interface type as reference can be of any type like int, string, alphanumeric etc. that's why we cannot use counter here.
eb45583
to
45ace4d
Compare
ed77db5
to
f0058be
Compare
4d23274
to
63ec07e
Compare
Signed-off-by: Vemula Venkatesh <[email protected]>
Signed-off-by: Vemula Venkatesh <[email protected]>
type changed to list(python) equivalent Signed-off-by: Vemula Venkatesh <[email protected]>
63ec07e
to
a5b9763
Compare
pkg/LinuxGeneralModule/lgm.go
Outdated
@@ -363,7 +361,12 @@ func Initialize() { | |||
brTenant = "br-tenant" | |||
ipMtu = config.GlobalConfig.LinuxFrr.IPMtu | |||
ctx = context.Background() | |||
nlink = utils.NewNetlinkWrapperWithArgs(config.GlobalConfig.Tracer) | |||
RouteTableGen = utils.IDPoolInit("RTtable", routingTableMin, routingTableMax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDPoolInit
can just return error
if failed to initialize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added bool return for the initialization status
pkg/LinuxGeneralModule/lgm.go
Outdated
for { | ||
routingTable = GenerateRouteTable() | ||
// var key interface{} | ||
routingTable, _ = RouteTableGen.GetID(Name, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then maybe we could have 2 functions GetID
and GetIDWithRef
?
3c0dfe3
to
835ccf9
Compare
Signed-off-by: Vemula Venkatesh <[email protected]>
835ccf9
to
64597cf
Compare
idpool feature for generating id's for mod pointer, routing table id , trie pointer.