424ae36046
We don't need C-style callback functions which accept a void* context parameter: Go has closures. Drop the unnecessary httpHandlerCustom type and refactor the diagnostic server handler functions into closures which capture whatever context they need implicitly. If the node leaves and rejoins a swarm, the cluster agent and its associated NetworkDB are discarded and replaced with new instances. Upon rejoin, the agent registers its NetworkDB instance with the diagnostic server. These handlers would all conflict with the handlers registered by the previous NetworkDB instance. Attempting to register a second handler on a http.ServeMux with the same pattern will panic, which the diagnostic server would historically deal with by ignoring the duplicate handler registration. Consequently, the first NetworkDB instance to be registered would "stick" to the diagnostic server for the lifetime of the process, even after it is replaced with another instance. Improve duplicate-handler registration such that the most recently-registered handler for a pattern is used for all subsequent requests. Signed-off-by: Cory Snider <csnider@mirantis.com> |
||
---|---|---|
.. | ||
dbclient | ||
dbserver | ||
dummyclient | ||
Dockerfile | ||
README | ||
testMain.go |
SERVER cd test/networkdb env GOOS=linux go build -v testMain.go && docker build -t dockereng/e2e-networkdb . (only for testkit case) docker push dockereng/e2e-networkdb Run server: docker service create --name testdb --network net1 --replicas 3 --env TASK_ID="{{.Task.ID}}" -p mode=host,target=8000 dockereng/e2e-networkdb server 8000 CLIENT cd test/networkdb Join cluster: docker run -it --network net1 dockereng/e2e-networkdb client join testdb 8000 Join network: docker run -it --network net1 dockereng/e2e-networkdb client join-network testdb 8000 test Run test: docker run -it --network net1 dockereng/e2e-networkdb client write-delete-unique-keys testdb 8000 test tableBla 3 10 check table: curl "localhost:32768/gettable?nid=test&tname=table_name"