Skip to content

Commit

Permalink
update fieldalignment
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed Apr 21, 2024
1 parent ff45883 commit c11726c
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 186 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ issues:
- dupl
- gosec
- scopelint
- govet
- path: internal/app/di
linters:
- govet
Expand Down
4 changes: 2 additions & 2 deletions internal/app/components/extendable_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type CommandsHandlers map[string]CommandHandler

type ExtendableExecutor struct {
innerExecutor contracts.Executor
handlers CommandsHandlers

mu sync.RWMutex
handlers CommandsHandlers
mu sync.RWMutex
}

func NewDefaultExtendableExecutor(executor contracts.Executor) *ExtendableExecutor {
Expand Down
4 changes: 2 additions & 2 deletions internal/app/components/safebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
// SafeBuffer is a goroutine safe bytes.Buffer.
type SafeBuffer struct {
buffer bytes.Buffer
mu *sync.Mutex
mu sync.Mutex
}

func NewSafeBuffer() *SafeBuffer {
return &SafeBuffer{bytes.Buffer{}, &sync.Mutex{}}
return &SafeBuffer{buffer: bytes.Buffer{}}
}

// Write appends the contents of p to the buffer, growing the buffer as needed. It returns
Expand Down
1 change: 1 addition & 0 deletions internal/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type SteamConfig struct {
Password string `yaml:"password"`
}

//nolint:govet
type Config struct {
NodeID uint `yaml:"ds_id"`

Expand Down
2 changes: 1 addition & 1 deletion internal/app/contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ type DomainPrimitiveValidator interface {
}

type ExecutorOptions struct {
Env map[string]string
WorkDir string
FallbackWorkDir string
UID string
GID string
Env map[string]string
}
2 changes: 1 addition & 1 deletion internal/app/domain/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
)

type ErrInvalidResponseFromAPI struct {
code int
body []byte
code int
}

func NewErrInvalidResponseFromAPI(code int, response []byte) ErrInvalidResponseFromAPI {
Expand Down
18 changes: 8 additions & 10 deletions internal/app/domain/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type Game struct {
Name string `json:"name"`
Engine string `json:"engine"`
EngineVersion string `json:"engine_version"`
SteamAppID SteamAppID `json:"steam_app_id"`
SteamAppSetConfig string `json:"steam_app_set_config"`
RemoteRepository string `json:"remote_repository"`
LocalRepository string `json:"local_repository"`
SteamAppID SteamAppID `json:"steam_app_id"`
}

type SteamSettings struct {
Expand Down Expand Up @@ -92,13 +92,11 @@ func (g *GameModVarTemplate) UnmarshalJSON(bytes []byte) error {
}

type GameMod struct {
ID int `json:"id"`
Name string `json:"name"`
RemoteRepository string `json:"remote_repository"`
LocalRepository string `json:"local_repository"`

Vars []GameModVarTemplate `json:"vars"`

DefaultStartCMDLinux string `json:"default_start_cmd_linux"`
DefaultStartCMDWindows string `json:"default_start_cmd_windows"`
Name string `json:"name"`
RemoteRepository string `json:"remote_repository"`
LocalRepository string `json:"local_repository"`
DefaultStartCMDLinux string `json:"default_start_cmd_linux"`
DefaultStartCMDWindows string `json:"default_start_cmd_windows"`
Vars []GameModVarTemplate `json:"vars"`
ID int `json:"id"`
}
25 changes: 12 additions & 13 deletions internal/app/domain/gdaemon_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ type GDTaskRepository interface {
}

type GDTask struct {
id int
runAfterID int
server *Server
task GDTaskCommand
cmd string

server *Server
statusMutex *sync.Mutex
status GDTaskStatus
task GDTaskCommand
cmd string
id int
runAfterID int
}

func NewGDTask(
Expand All @@ -66,13 +65,13 @@ func NewGDTask(
status GDTaskStatus,
) *GDTask {
return &GDTask{
id,
runAfterID,
server,
task,
cmd,
&sync.Mutex{},
status,
id: id,
runAfterID: runAfterID,
server: server,
task: task,
cmd: cmd,
statusMutex: &sync.Mutex{},
status: status,
}
}

Expand Down
65 changes: 27 additions & 38 deletions internal/app/domain/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,45 +53,34 @@ type Settings map[string]string

//nolint:maligned
type Server struct {
id int
enabled bool
installStatus InstallationStatus
blocked bool

name string
uuid string
uuidShort string

game Game
gameMod GameMod

ip string
connectPort int
queryPort int
rconPort int
rconPassword string

dir string
user string

startCommand string
stopCommand string
forceStopCommand string
restartCommand string

processActive bool
lastProcessCheck time.Time

vars map[string]string

settings Settings

updatedAt time.Time
lastProcessCheck time.Time
lastTaskCompletedAt time.Time

changeset *hashset.Set

mu *sync.RWMutex
updatedAt time.Time
mu *sync.RWMutex
changeset *hashset.Set
settings Settings
vars map[string]string
restartCommand string
uuid string
forceStopCommand string
uuidShort string
stopCommand string
ip string
rconPassword string
dir string
user string
startCommand string
name string
game Game
gameMod GameMod
id int
connectPort int
queryPort int
installStatus InstallationStatus
rconPort int
processActive bool
enabled bool
blocked bool
}

func NewServer(
Expand Down
30 changes: 15 additions & 15 deletions internal/app/domain/server_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ type ServerTaskRepository interface {
}

type ServerTask struct {
executeDate time.Time
server *Server
mutex *sync.Mutex
command ServerTaskCommand
id int
status ServerTaskStatus
command ServerTaskCommand
server *Server
repeat int
repeatPeriod time.Duration
counter int
executeDate time.Time
mutex *sync.Mutex
}

func NewServerTask(
Expand All @@ -54,15 +54,15 @@ func NewServerTask(
executeDate time.Time,
) *ServerTask {
return &ServerTask{
id,
ServerTaskStatusWaiting,
command,
server,
repeat,
repeatPeriod,
counter,
executeDate,
&sync.Mutex{},
id: id,
status: ServerTaskStatusWaiting,
command: command,
server: server,
repeat: repeat,
repeatPeriod: repeatPeriod,
counter: counter,
executeDate: executeDate,
mutex: &sync.Mutex{},
}
}

Expand All @@ -71,13 +71,13 @@ func (s ServerTask) MarshalJSON() ([]byte, error) {
defer s.mutex.Unlock()

return json.Marshal(struct {
ExecuteDate string `json:"execute_date"`
Repeat int `json:"repeat"`
RepeatPeriodInSeconds int `json:"repeat_period"`
ExecuteDate string `json:"execute_date"`
}{
ExecuteDate: s.executeDate.Format("2006-01-02 15:04:05"),
Repeat: s.repeat,
RepeatPeriodInSeconds: int(s.repeatPeriod.Seconds()),
ExecuteDate: s.executeDate.Format("2006-01-02 15:04:05"),
})
}

Expand Down
5 changes: 2 additions & 3 deletions internal/app/game_server_commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ func (c *commandList) Execute(ctx context.Context, server *domain.Server) error
}

type nilCommand struct {
baseCommand
bufCommand

message string
message string
baseCommand
resultCode int
}

Expand Down
2 changes: 1 addition & 1 deletion internal/app/game_server_commands/delete_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
var errForbiddenWorkDirectoryPath = errors.New("forbidden game server work directory path")

type defaultDeleteServer struct {
baseCommand
bufCommand
baseCommand
}

func newDefaultDeleteServer(
Expand Down
16 changes: 7 additions & 9 deletions internal/app/game_server_commands/install_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,15 @@ type installationRule struct {
}

type installServer struct {
serverRepo domain.ServerRepository
installOutput io.ReadWriter
statusCommand contracts.GameServerCommand
stopCommand contracts.GameServerCommand
startCommand contracts.GameServerCommand
installator *installator
baseCommand

installator *installator
serverRepo domain.ServerRepository
kind installatorKind

installOutput io.ReadWriter
kind installatorKind
serverWasActiveBeforeInstallation bool
statusCommand contracts.GameServerCommand
stopCommand contracts.GameServerCommand
startCommand contracts.GameServerCommand
}

func newUpdateServer(
Expand Down
3 changes: 1 addition & 2 deletions internal/app/game_server_commands/restart_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import (
)

type defaultRestartServer struct {
baseCommand
bufCommand

statusServer contracts.GameServerCommand
stopServer contracts.GameServerCommand
startServer contracts.GameServerCommand
baseCommand
}

func newDefaultRestartServer(
Expand Down
9 changes: 3 additions & 6 deletions internal/app/game_server_commands/start_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ import (
)

type defaultStartServer struct {
baseCommand

startOutput io.ReadWriter

startOutput io.ReadWriter
updateCommand contracts.GameServerCommand
loadServerCommand LoadServerCommandFunc

updateCommand contracts.GameServerCommand
baseCommand
enableUpdatingBefore bool
}

Expand Down
2 changes: 1 addition & 1 deletion internal/app/game_server_commands/status_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

type statusDefaultServer struct {
baseCommand
bufCommand
baseCommand
}

func newDefaultStatusServer(
Expand Down
2 changes: 1 addition & 1 deletion internal/app/game_server_commands/stop_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

type defaultStopServer struct {
baseCommand
bufCommand
baseCommand
}

func newDefaultStopServer(
Expand Down
Loading

0 comments on commit c11726c

Please sign in to comment.