-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate and generalize object-to-number allocator
In pillar we now have 3 number allocators with persistence built on top of pubsub publication: - appnumallocator.go - bridgenumallocator.go - appnumonunet.go Most of the code of these allocators is in zedrouter, but some underlying functions are separated to pillar/uuidtonum and pillar/uuidpairtonum and partially also used from other microservices. The main logic of these allocators is the same, only target objects for which the numbers are allocated differ. The main problems with the current implementation are: - hard to understand, not easy to read, type names like UUIDPairAndIfIdxToNum are quite clumsy - same logic replicated 3 times - difficult/impossible to re-use elsewhere (a concept of number allocator could be useful outside of zedrouter) - some hard-coded limits (e.g. allocation limited to 256 numbers max) - difficult/impossible to customize or extend - most of the code is tightly-coupled with the zedrouter In this commit we generalize all these allocators into one implementation, separated from the zedrouter and put into pillar/objtonum package. The allocator itself was split into 3 types: - object-to-number map: allows to store number assignments (e.g. using pubsub for persistence) - number allocator: allows to allocate number from some integer set (could be a range of numbers <0-255> or something else) - object-to-number allocator: allocates number for an object and stores the allocation. Uses an object-to-number map and a number allocator (of the caller choice). All changes were done in a backward-compatible way - nothing changed in how these number allocations are persisted (neither content nor topic names changed, but note that Go alias was used, learn about it here: https://yourbasic.org/golang/type-alias/), This ensures that EVE upgrade will not be broken. This commit is first in a series of the zedrouter refactoring. Signed-off-by: Milan Lenco <milan@zededa.com>
- Loading branch information
1 parent
98b679a
commit 2dab434
Showing
23 changed files
with
1,911 additions
and
1,280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.