sticky sessions
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 27s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 27s
This commit is contained in:
16
main.go
16
main.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -110,18 +111,21 @@ func main() {
|
||||
storage: storage,
|
||||
}
|
||||
|
||||
rpcHandler, err := NewGrainHandler(app.pool, "localhost:1337")
|
||||
syncedPool := NewSyncedPool(app.pool)
|
||||
|
||||
rpcHandler, err := NewGrainHandler(app.pool, ":1337")
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating handler: %v\n", err)
|
||||
}
|
||||
go rpcHandler.Serve()
|
||||
|
||||
remotePool := NewRemoteGrainPool("localhost:1337")
|
||||
remoteServer := NewPoolServer(remotePool)
|
||||
localServer := NewPoolServer(app.pool)
|
||||
syncedServer := NewPoolServer(syncedPool)
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/remote/", http.StripPrefix("/remote", remoteServer.Serve()))
|
||||
mux.Handle("/local/", http.StripPrefix("/local", localServer.Serve()))
|
||||
mux.Handle("/api/", http.StripPrefix("/api", syncedServer.Serve()))
|
||||
mux.HandleFunc("GET /add/remote/{host}", func(w http.ResponseWriter, r *http.Request) {
|
||||
remotePool := NewRemoteGrainPool(fmt.Sprintf("%s:1337", r.PathValue("host")))
|
||||
syncedPool.AddRemote(remotePool)
|
||||
})
|
||||
mux.HandleFunc("GET /save", app.HandleSave)
|
||||
http.ListenAndServe(":8080", mux)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user