Switched to redis/postgres, major refactoring

- loginMetadata is passed to shards through redis now
- shards announce they're alive via redis.AnnounceShard() which just
  populates a hashset keyed 'shards'
- login servers grab the 'shards' hashset and randomly picks a shard to
  pass the player to (for now)
- ./service shard && ./service login
- Many new environment variables, check config/config.go for more info.
  or for a tl;dr just read the Dockerfile for the required ones
- Shard and login services now run in different processes ! (and
  containers?? wooaaah)
This commit is contained in:
2023-06-22 01:53:38 -05:00
parent 983588b6c9
commit d7445e0f0f
20 changed files with 489 additions and 192 deletions

View File

@@ -2,6 +2,7 @@ package shard
import (
"fmt"
"log"
"time"
"github.com/CPunch/gopenfusion/core"
@@ -12,7 +13,7 @@ func (server *ShardServer) RequestEnter(peer *protocol.CNPeer, pkt protocol.Pack
var enter protocol.SP_CL2FE_REQ_PC_ENTER
pkt.Decode(&enter)
loginData, err := server.CheckLogin(enter.IEnterSerialKey)
loginData, err := server.redisHndlr.GetLogin(enter.IEnterSerialKey)
if err != nil {
// the error codes for P_FE2CL_REP_PC_ENTER_FAIL aren't referenced in the client :(
peer.Send(protocol.P_FE2CL_REP_PC_ENTER_FAIL, protocol.SP_FE2CL_REP_PC_ENTER_FAIL{})
@@ -48,6 +49,7 @@ func (server *ShardServer) RequestEnter(peer *protocol.CNPeer, pkt protocol.Pack
peer.FE_key = loginData.FEKey
peer.SetActiveKey(protocol.USE_FE)
log.Printf("Player %d (AccountID %d) entered\n", resp.IID, loginData.PlayerID)
return peer.Send(protocol.P_FE2CL_REP_PC_ENTER_SUCC, resp)
}