chore: refactor structure
This commit is contained in:
@@ -24,7 +24,7 @@ type Repo interface {
|
||||
LoadState() (game.Game, error)
|
||||
}
|
||||
|
||||
type Ctrl struct {
|
||||
type Controller struct {
|
||||
param Param
|
||||
Repo Repo
|
||||
}
|
||||
@@ -33,7 +33,7 @@ type Param struct {
|
||||
StoragePath string
|
||||
}
|
||||
|
||||
func NewController(configure func(*Param)) (*Ctrl, error) {
|
||||
func NewController(configure func(*Param)) (*Controller, error) {
|
||||
c := &Param{
|
||||
StoragePath: ".",
|
||||
}
|
||||
@@ -44,13 +44,13 @@ func NewController(configure func(*Param)) (*Ctrl, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Ctrl{
|
||||
return &Controller{
|
||||
param: *c,
|
||||
Repo: r,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Ctrl) ExecuteInit(consumer func(Repo)) error {
|
||||
func (c *Controller) ExecuteInit(consumer func(Repo)) error {
|
||||
if err := c.Repo.Lock(); err != nil {
|
||||
return fmt.Errorf("execute: lock failed: %s", err)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (c *Ctrl) ExecuteInit(consumer func(Repo)) error {
|
||||
return c.Repo.Release()
|
||||
}
|
||||
|
||||
func (c *Ctrl) Execute(consumer func(Repo, game.Game)) error {
|
||||
func (c *Controller) Execute(consumer func(Repo, game.Game)) error {
|
||||
if err := c.Repo.Lock(); err != nil {
|
||||
return fmt.Errorf("execute: lock failed: %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user