Skip to content

Commit

Permalink
Merge pull request #338 from rstudio/dotnomad/status-events
Browse files Browse the repository at this point in the history
Separate progress and status events
  • Loading branch information
dotNomad authored Nov 3, 2023
2 parents 6feb329 + 669ae7b commit def771c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Phase string
const (
StartPhase Phase = "start"
ProgressPhase Phase = "progress"
StatusPhase Phase = "status"
SuccessPhase Phase = "success"
FailurePhase Phase = "failure"
LogPhase Phase = "log"
Expand Down Expand Up @@ -61,7 +62,7 @@ func (l logger) Success(msg string, args ...any) {
}

func (l logger) Status(msg string, args ...any) {
l.Info(msg, append([]any{LogKeyPhase, ProgressPhase}, args...)...)
l.Info(msg, append([]any{LogKeyPhase, StatusPhase}, args...)...)
}

func (l logger) Progress(msg string, done float32, total float32, args ...any) {
Expand Down
2 changes: 1 addition & 1 deletion internal/logging/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s *LoggingSuite) TestSuccess() {

func (s *LoggingSuite) TestStatus() {
baseLogger := NewMockBaseLogger()
baseLogger.On("Info", "message", LogKeyPhase, ProgressPhase, "arg", "value")
baseLogger.On("Info", "message", LogKeyPhase, StatusPhase, "arg", "value")

log := logger{baseLogger}
log.Status("message", "arg", "value")
Expand Down
14 changes: 14 additions & 0 deletions web/src/api/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface EventSubscriptionTargetCallbackMap {
'publish/restorePythonEnv/start': OnPublishRestorePythonEnvStartCallback
'publish/restorePythonEnv/log': OnPublishRestorePythonEnvLogCallback
'publish/restorePythonEnv/progress': OnPublishRestorePythonEnvProgressCallback
'publish/restorePythonEnv/status': OnPublishRestorePythonEnvStatusCallback
'publish/restorePythonEnv/success': OnPublishRestorePythonEnvSuccessCallback
'publish/restorePythonEnv/failure': OnPublishRestorePythonEnvFailureCallback
// 'publish/restorePythonEnv/failure/serverErr' | // received but temporarily converted
Expand Down Expand Up @@ -463,6 +464,19 @@ export function isPublishRestorePythonEnvProgress(arg: Events):
return arg.type === 'publish/restorePythonEnv/progress';
}

export interface PublishRestorePythonEnvStatus extends EventStreamMessage {
type: 'publish/restorePythonEnv/status',
// structured data not guaranteed, use selective or generic queries
// from data map
}
export type OnPublishRestorePythonEnvStatusCallback = (
msg: PublishRestorePythonEnvStatus
) => void;
export function isPublishRestorePythonEnvStatus(arg: Events):
arg is PublishRestorePythonEnvStatus {
return arg.type === 'publish/restorePythonEnv/status';
}

export interface PublishRestorePythonEnvSuccess extends EventStreamMessage {
type: 'publish/restorePythonEnv/success',
data: {
Expand Down

0 comments on commit def771c

Please sign in to comment.