Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
  • Loading branch information
JeffMboya committed Dec 15, 2024
1 parent b4f941f commit 5a556e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
11 changes: 5 additions & 6 deletions proplet/api/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ func (r RPCRequest) Validate() error {
}

func (r RPCRequest) ParseParams() (interface{}, error) {
switch r.Method {
case "start":
if r.Method == "start" {
if len(r.Params) < 1 {
return nil, fmt.Errorf("start method: missing required parameters: %w", pkgerrors.ErrInvalidParams)
}
Expand All @@ -69,8 +68,9 @@ func (r RPCRequest) ParseParams() (interface{}, error) {
AppName: appName,
Params: params,
}, nil
}

case "stop":
if r.Method == "stop" {
if len(r.Params) < 1 {
return nil, fmt.Errorf("stop method: missing required parameters: %w", pkgerrors.ErrInvalidParams)
}
Expand All @@ -83,10 +83,9 @@ func (r RPCRequest) ParseParams() (interface{}, error) {
return StopRequest{
AppName: appName,
}, nil

default:
return nil, fmt.Errorf("unknown method '%s': %w", r.Method, pkgerrors.ErrInvalidMethod)
}

return nil, fmt.Errorf("unknown method '%s': %w", r.Method, pkgerrors.ErrInvalidMethod)
}

func parseStringSlice(params []interface{}) ([]string, error) {
Expand Down
20 changes: 10 additions & 10 deletions proplet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (p *PropletService) handleStartCommand(ctx context.Context, _ string, msg m

startReq, ok := parsed.(api.StartRequest)
if !ok {
return fmt.Errorf("unexpected request type for start command")
return errors.New("unexpected request type for start command")
}

logger.Info("Received start command", slog.String("app_name", startReq.AppName))
Expand Down Expand Up @@ -232,16 +232,16 @@ func (p *PropletService) handleStartCommand(ctx context.Context, _ string, msg m
case <-timeout:
return fmt.Errorf("timed out waiting for chunks for app '%s'", startReq.AppName)
default:
p.chunksMutex.Lock()
metadata, exists := p.chunkMetadata[startReq.AppName]
receivedChunks := len(p.chunks[startReq.AppName])
p.chunksMutex.Unlock()
p.chunksMutex.Lock()
metadata, exists := p.chunkMetadata[startReq.AppName]
receivedChunks := len(p.chunks[startReq.AppName])
p.chunksMutex.Unlock()

if exists && receivedChunks == metadata.TotalChunks {
go p.deployAndRunApp(ctx, startReq.AppName)
if exists && receivedChunks == metadata.TotalChunks {
go p.deployAndRunApp(ctx, startReq.AppName)

return nil
}
return nil
}

time.Sleep(pollingInterval)
}
Expand All @@ -266,7 +266,7 @@ func (p *PropletService) handleStopCommand(ctx context.Context, _ string, msg ma

stopReq, ok := parsed.(api.StopRequest)
if !ok {
return fmt.Errorf("unexpected request type for stop command")
return errors.New("unexpected request type for stop command")
}

logger.Info("Received stop command", slog.String("app_name", stopReq.AppName))
Expand Down

0 comments on commit 5a556e6

Please sign in to comment.