LicenseDB Listener
Purpose
Depending on the package manager, this container may be called as a scheduled task, or an asynchronous event (such as a webhook) that will determine when it is called.
Project
Design
For each package manager, the interfacer must be designed to:
- Handle asynchronous webhook events
- Handle being called in a scheduled manner (this may require storing/retrieving state somewhere)
- Allow a package manager type to register the above events
- Push data over Pub/Sub to the license interfacer
The listener should be modular, in that it is easy to add a new package manager simply by registering various functions with a dispatcher like service, such as http functions to handle incoming messages.
Something like:
dispatcher := NewDispatcher(opts FunctionalOpts)
dispatcher.Register(
package.NewPypi(
WithHandlers("endpoint", func1(w, r http)),
WithHandlers("endpoint2", func2(w, r http)),
),
package.NewRubygems(
WithHandlers("endpoint3", func1(w, r http)),
WithHandlers("endpoint4", func2(w, r http)),
),
)