-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add worker event listener - add worker event handler - start event listener when a worker starts
- Loading branch information
Showing
9 changed files
with
110 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package recording | ||
|
||
// pauseReason type is used by the pause and resume methods of the | ||
// RecordingManager interface to determine when to pause and resume recording. | ||
// The pause() method should be called with a pauseReason type that accurately | ||
// describes the reason why the recording manager is being paused. | ||
// The resume() method should be called with the same pauseReason type only | ||
// when the caller can definitely state that all places that called pause() no | ||
// longer need the recorder manager to be paused. | ||
type pauseReason uint8 | ||
|
||
const ( | ||
// unknown is the default value for PauseReason | ||
// This should not be used as a reason to pause the recording manager. | ||
// This is solely used to for testing purposes. | ||
unknown pauseReason = iota | ||
|
||
// localStorageException is used to pause the recording manager when | ||
// there is an exception with the local storage. | ||
localStorageException pauseReason = iota | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package event | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/eventlogger" | ||
) | ||
|
||
// EventHandlerFunc is a function that handles an event. | ||
type EventHandlerFunc func(ctx context.Context, e *eventlogger.Event) | ||
|
||
// EventListener is an interface for listening to events. | ||
type EventListener interface { | ||
// RegisterEventHandlerFunc registers an event handler function for the given event type. | ||
// A given event type can have multiple event handler functions registered. | ||
RegisterEventHandlerFunc(ctx context.Context, ev Type, ehf EventHandlerFunc) error | ||
// Start starts the event listener. | ||
Start(ctx context.Context) error | ||
// Shutdown stops the event listener. | ||
Shutdown(ctx context.Context) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters