generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: timeline service keeps events in memory (#3618)
closes #3626 Very simple implementation to be begin with. Allows: - creating events - getting events with super simple filters - clearing out old events
- Loading branch information
Showing
10 changed files
with
851 additions
and
77 deletions.
There are no files selected for viewing
431 changes: 367 additions & 64 deletions
431
backend/protos/xyz/block/ftl/timeline/v1/timeline.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
backend/protos/xyz/block/ftl/timeline/v1/timelinev1connect/timeline.connect.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,68 @@ | ||
package timeline | ||
|
||
import ( | ||
"fmt" | ||
"slices" | ||
|
||
timelinepb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/timeline/v1" | ||
) | ||
|
||
func filter(event *timelinepb.Event, depKey string, eventTypes []timelinepb.EventType) bool { | ||
if !slices.Contains(eventTypes, eventType(event)) { | ||
return false | ||
} | ||
if depKey != "" && depKey != deploymentKey(event) { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func eventType(event *timelinepb.Event) timelinepb.EventType { | ||
switch event.Entry.(type) { | ||
case *timelinepb.Event_Log: | ||
return timelinepb.EventType_EVENT_TYPE_LOG | ||
case *timelinepb.Event_Call: | ||
return timelinepb.EventType_EVENT_TYPE_CALL | ||
case *timelinepb.Event_DeploymentCreated: | ||
return timelinepb.EventType_EVENT_TYPE_DEPLOYMENT_CREATED | ||
case *timelinepb.Event_DeploymentUpdated: | ||
return timelinepb.EventType_EVENT_TYPE_DEPLOYMENT_UPDATED | ||
case *timelinepb.Event_Ingress: | ||
return timelinepb.EventType_EVENT_TYPE_INGRESS | ||
case *timelinepb.Event_CronScheduled: | ||
return timelinepb.EventType_EVENT_TYPE_CRON_SCHEDULED | ||
case *timelinepb.Event_AsyncExecute: | ||
return timelinepb.EventType_EVENT_TYPE_ASYNC_EXECUTE | ||
case *timelinepb.Event_PubsubPublish: | ||
return timelinepb.EventType_EVENT_TYPE_PUBSUB_PUBLISH | ||
case *timelinepb.Event_PubsubConsume: | ||
return timelinepb.EventType_EVENT_TYPE_PUBSUB_CONSUME | ||
default: | ||
panic(fmt.Sprintf("unexpected event type: %T", event.Entry)) | ||
} | ||
} | ||
|
||
func deploymentKey(event *timelinepb.Event) string { | ||
switch entry := event.Entry.(type) { | ||
case *timelinepb.Event_Log: | ||
return entry.Log.DeploymentKey | ||
case *timelinepb.Event_Call: | ||
return entry.Call.DeploymentKey | ||
case *timelinepb.Event_DeploymentCreated: | ||
return entry.DeploymentCreated.Key | ||
case *timelinepb.Event_DeploymentUpdated: | ||
return entry.DeploymentUpdated.Key | ||
case *timelinepb.Event_Ingress: | ||
return entry.Ingress.DeploymentKey | ||
case *timelinepb.Event_CronScheduled: | ||
return entry.CronScheduled.DeploymentKey | ||
case *timelinepb.Event_AsyncExecute: | ||
return entry.AsyncExecute.DeploymentKey | ||
case *timelinepb.Event_PubsubPublish: | ||
return entry.PubsubPublish.DeploymentKey | ||
case *timelinepb.Event_PubsubConsume: | ||
return entry.PubsubConsume.DeploymentKey | ||
default: | ||
panic(fmt.Sprintf("unexpected event type: %T", event.Entry)) | ||
} | ||
} |
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
Oops, something went wrong.