f-21: refactor: add dispatcher layer for MQTT migration
Introduce internal/dispatcher package with a Command interface and typed commands (CreateVPC, DeleteVPC, CreateSubnet, DeleteSubnet). The API handlers now call dispatcher.Dispatch() instead of enqueuing closures directly, decoupling transport (HTTP today, MQTT tomorrow) from execution. Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
7ee8527582
commit
63a288f69e
9 changed files with 114 additions and 39 deletions
|
|
@ -4,6 +4,8 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.g3e.fr/syonad/two/internal/dispatcher"
|
||||
)
|
||||
|
||||
func (s *Server) SubnetByNameHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -31,11 +33,8 @@ func (s *Server) getSubnet(w http.ResponseWriter, r *http.Request, name string)
|
|||
}
|
||||
|
||||
func (s *Server) deleteSubnet(w http.ResponseWriter, r *http.Request, name string) {
|
||||
s.queue.Submit(func() {
|
||||
destroySubnet(name)
|
||||
})
|
||||
s.dispatcher.Dispatch(dispatcher.DeleteSubnetCommand{Name: name})
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
json.NewEncoder(w).Encode(Subnet{Name: name, State: "deleting"})
|
||||
}
|
||||
|
||||
func destroySubnet(name string) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue