refactor: unify Manager, remove globalManager singleton#110
Merged
Conversation
Merge security/manager.go (!libcrust) and manager_libcrust.go (libcrust) into one unified Manager with functional options: - NewManager(interceptor, registry, blockMode, ...opts) - WithStorage, WithAPI, WithRetention, WithBuffering options - SetAPI() for circular deps (API server needs manager reference) Manager uses http.Handler interface (not *APIServer) so gin is never imported in the Manager file. Mobile/GUI builds stay lightweight. Delete manager_libcrust.go stub. Move daemon-only Init() to manager_init.go (!libcrust). Remove globalManager, SetGlobalManager, GetGlobalManager, GetGlobalInterceptor.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Merge the two build-tag-separated Manager implementations into one unified struct with functional options. Delete the libcrust stub. Remove all global manager state.
Before:
manager.go(!libcrust, 296 lines) +manager_libcrust.go(libcrust, 25 lines) — two separate Manager structs behind build tags.After: One
manager.go(no build tag, 235 lines) +manager_init.go(!libcrust, daemon-only Init). Net -63 lines, 1 file deleted, 1 build tag removed.Changes
WithStorage,WithAPI,WithRetention,WithBufferinghttp.Handlerinterface instead of*APIServer— gin never imported in Manager, mobile builds stay lightweightSetAPI()method for circular deps (API server needs manager for plugin stats)manager_libcrust.gostubglobalManager,SetGlobalManager,GetGlobalManager,GetGlobalInterceptorNewManager()directly instead of global stateBuild verification
go build .(CLI) — passCGO_ENABLED=0 go build -tags libcrust ./pkg/libcrust/(mobile) — passgo test -race -short ./...— all 30 packages passTest plan