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:
@@ -67,6 +67,10 @@ metadata:
|
|||||||
name: cart-ingress
|
name: cart-ingress
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
nginx.ingress.kubernetes.io/affinity: "cookie"
|
||||||
|
nginx.ingress.kubernetes.io/session-cookie-name: "cart-session"
|
||||||
|
nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
|
||||||
|
nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
|
||||||
nginx.ingress.kubernetes.io/proxy-body-size: 16m
|
nginx.ingress.kubernetes.io/proxy-body-size: 16m
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
|
|||||||
16
main.go
16
main.go
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -110,18 +111,21 @@ func main() {
|
|||||||
storage: storage,
|
storage: storage,
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcHandler, err := NewGrainHandler(app.pool, "localhost:1337")
|
syncedPool := NewSyncedPool(app.pool)
|
||||||
|
|
||||||
|
rpcHandler, err := NewGrainHandler(app.pool, ":1337")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error creating handler: %v\n", err)
|
log.Fatalf("Error creating handler: %v\n", err)
|
||||||
}
|
}
|
||||||
go rpcHandler.Serve()
|
go rpcHandler.Serve()
|
||||||
|
|
||||||
remotePool := NewRemoteGrainPool("localhost:1337")
|
syncedServer := NewPoolServer(syncedPool)
|
||||||
remoteServer := NewPoolServer(remotePool)
|
|
||||||
localServer := NewPoolServer(app.pool)
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.Handle("/remote/", http.StripPrefix("/remote", remoteServer.Serve()))
|
mux.Handle("/api/", http.StripPrefix("/api", syncedServer.Serve()))
|
||||||
mux.Handle("/local/", http.StripPrefix("/local", localServer.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)
|
mux.HandleFunc("GET /save", app.HandleSave)
|
||||||
http.ListenAndServe(":8080", mux)
|
http.ListenAndServe(":8080", mux)
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,19 @@ package main
|
|||||||
|
|
||||||
type SyncedPool struct {
|
type SyncedPool struct {
|
||||||
local *GrainLocalPool
|
local *GrainLocalPool
|
||||||
remotes []RemoteGrainPool
|
remotes []*RemoteGrainPool
|
||||||
remoteIndex map[CartId]*RemoteGrainPool
|
remoteIndex map[CartId]*RemoteGrainPool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSyncedPool(local *GrainLocalPool) *SyncedPool {
|
func NewSyncedPool(local *GrainLocalPool) *SyncedPool {
|
||||||
return &SyncedPool{
|
return &SyncedPool{
|
||||||
local: local,
|
local: local,
|
||||||
remotes: make([]RemoteGrainPool, 0),
|
remotes: make([]*RemoteGrainPool, 0),
|
||||||
remoteIndex: make(map[CartId]*RemoteGrainPool),
|
remoteIndex: make(map[CartId]*RemoteGrainPool),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *SyncedPool) AddRemote(remote RemoteGrainPool) {
|
func (p *SyncedPool) AddRemote(remote *RemoteGrainPool) {
|
||||||
p.remotes = append(p.remotes, remote)
|
p.remotes = append(p.remotes, remote)
|
||||||
// get all available grains from remote, and start syncing
|
// get all available grains from remote, and start syncing
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user