Skip to content

Commit

Permalink
nitpicking (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
jancajthaml authored May 21, 2019
1 parent bc850ec commit 9ce06a4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
4 changes: 1 addition & 3 deletions services/vault-unit/actor/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
money "gopkg.in/inf.v0"
)

var nilCoordinates = system.Coordinates{}

// ProcessLocalMessage processing of local message to this vault
func ProcessLocalMessage(s *ActorSystem) system.ProcessLocalMessage {
return func(message interface{}, to system.Coordinates, from system.Coordinates) {
Expand All @@ -52,7 +50,7 @@ func asEnvelopes(s *ActorSystem, msg string) (system.Coordinates, system.Coordin
parts := strings.Split(msg, " ")

if len(parts) < 5 {
return nilCoordinates, nilCoordinates, nil, fmt.Errorf("invalid message received %+v", parts)
return system.Coordinates{}, system.Coordinates{}, nil, fmt.Errorf("invalid message received %+v", parts)
}

recieverRegion, senderRegion, receiverName, senderName := parts[0], parts[1], parts[2], parts[3]
Expand Down
8 changes: 4 additions & 4 deletions services/vault-unit/boot/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/jancajthaml-openbank/vault-unit/utils"
)

// Application encapsulate initialized application
type Application struct {
// Program encapsulate initialized application
type Program struct {
cfg config.Configuration
interrupt chan os.Signal
metrics metrics.Metrics
Expand All @@ -38,7 +38,7 @@ type Application struct {
}

// Initialize application
func Initialize() Application {
func Initialize() Program {
ctx, cancel := context.WithCancel(context.Background())

cfg := config.GetConfig()
Expand All @@ -51,7 +51,7 @@ func Initialize() Application {
actorSystemDaemon := actor.NewActorSystem(ctx, cfg.Tenant, cfg.LakeHostname, &metricsDaemon, &storage)
snapshotUpdaterDaemon := persistence.NewSnapshotUpdater(ctx, cfg.JournalSaturation, cfg.SnapshotScanInterval, &metricsDaemon, &storage, actor.ProcessLocalMessage(&actorSystemDaemon))

return Application{
return Program{
cfg: cfg,
interrupt: make(chan os.Signal, 1),
metrics: metricsDaemon,
Expand Down
10 changes: 5 additions & 5 deletions services/vault-unit/boot/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (
)

// Stop stops the application
func (app Application) Stop() {
func (app Program) Stop() {
close(app.interrupt)
}

// WaitReady wait for daemons to be ready
func (app Application) WaitReady(deadline time.Duration) error {
func (app Program) WaitReady(deadline time.Duration) error {
errors := make([]error, 0)
mux := new(sync.Mutex)

Expand Down Expand Up @@ -63,19 +63,19 @@ func (app Application) WaitReady(deadline time.Duration) error {
}

// GreenLight daemons
func (app Application) GreenLight() {
func (app Program) GreenLight() {
app.metrics.GreenLight()
app.actorSystem.GreenLight()
app.snapshotUpdater.GreenLight()
}

// WaitInterrupt wait for signal
func (app Application) WaitInterrupt() {
func (app Program) WaitInterrupt() {
<-app.interrupt
}

// Run runs the application
func (app Application) Run() {
func (app Program) Run() {
log.Info(">>> Start <<<")

go app.metrics.Start()
Expand Down
6 changes: 3 additions & 3 deletions services/vault-unit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

func main() {
application := boot.Initialize()
defer application.Stop()
application.Run()
program := boot.Initialize()
defer program.Stop()
program.Run()
}

0 comments on commit 9ce06a4

Please sign in to comment.