Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

venkyvsp
Copy link
Contributor

idpool feature for generating id's for mod pointer, routing table id , trie pointer.

@venkyvsp venkyvsp marked this pull request as ready for review September 23, 2024 07:09
@venkyvsp venkyvsp requested a review from a team as a code owner September 23, 2024 07:09
pkg/LinuxGeneralModule/lgm.go Outdated Show resolved Hide resolved
pkg/LinuxGeneralModule/lgm.go Outdated Show resolved Hide resolved
pkg/LinuxGeneralModule/lgm.go Outdated Show resolved Hide resolved
pkg/LinuxGeneralModule/lgm.go Outdated Show resolved Hide resolved
pkg/LinuxGeneralModule/lgm.go Outdated Show resolved Hide resolved
pkg/utils/Idpool.go Outdated Show resolved Hide resolved
pkg/utils/Idpool.go Outdated Show resolved Hide resolved
pkg/utils/Idpool.go Outdated Show resolved Hide resolved
pkg/utils/Idpool.go Outdated Show resolved Hide resolved
_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{}
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@venkyvsp venkyvsp force-pushed the opi_idpool_main_pr branch 3 times, most recently from eb45583 to 45ace4d Compare October 15, 2024 10:47
pkg/utils/idpool.go Outdated Show resolved Hide resolved
pkg/utils/Idpool.go Outdated Show resolved Hide resolved
@venkyvsp venkyvsp force-pushed the opi_idpool_main_pr branch 4 times, most recently from ed77db5 to f0058be Compare October 29, 2024 15:05
@venkyvsp venkyvsp force-pushed the opi_idpool_main_pr branch 3 times, most recently from 4d23274 to 63ec07e Compare November 8, 2024 11:34
@@ -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)
Copy link
Contributor

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

Copy link
Contributor Author

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

for {
routingTable = GenerateRouteTable()
// var key interface{}
routingTable, _ = RouteTableGen.GetID(Name, 0)
Copy link
Contributor

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?

pkg/utils/idpool.go Fixed Show fixed Hide fixed
pkg/utils/idpool.go Fixed Show fixed Hide fixed
Signed-off-by: Vemula Venkatesh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants