-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7ad995
commit 96ad075
Showing
9 changed files
with
144 additions
and
69 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
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,40 @@ | ||
package event | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/kubeshop/tracetest/server/model" | ||
) | ||
|
||
type Emitter interface { | ||
Emit(ctx context.Context, event model.TestRunEvent) error | ||
} | ||
|
||
type publisher interface { | ||
Publish(eventID string, message any) | ||
} | ||
|
||
type internalEmitter struct { | ||
repository model.TestRunEventRepository | ||
publisher publisher | ||
} | ||
|
||
func NewEmitter(repository model.TestRunEventRepository, publisher publisher) Emitter { | ||
return &internalEmitter{ | ||
repository: repository, | ||
publisher: publisher, | ||
} | ||
} | ||
|
||
func (em *internalEmitter) Emit(ctx context.Context, event model.TestRunEvent) error { | ||
err := em.repository.CreateTestRunEvent(ctx, event) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
eventIDAsString := fmt.Sprintf("%d", event.ID) | ||
em.publisher.Publish(eventIDAsString, event) | ||
|
||
return nil | ||
} |
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