Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate progress and status events #338

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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