mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 08:57:35 +00:00
chore: move the go code into a subfolder
This commit is contained in:
21
apps/api/internal/repository/pseudo/aggregate.go
Normal file
21
apps/api/internal/repository/pseudo/aggregate.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package pseudo
|
||||
|
||||
import "github.com/zitadel/zitadel/internal/eventstore"
|
||||
|
||||
const (
|
||||
AggregateType = "pseudo"
|
||||
AggregateVersion = "v1"
|
||||
)
|
||||
|
||||
type Aggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
func NewAggregate() *Aggregate {
|
||||
return &Aggregate{
|
||||
Aggregate: eventstore.Aggregate{
|
||||
Type: AggregateType,
|
||||
Version: AggregateVersion,
|
||||
},
|
||||
}
|
||||
}
|
40
apps/api/internal/repository/pseudo/events.go
Normal file
40
apps/api/internal/repository/pseudo/events.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Package pseudo contains virtual events, that are not stored in the eventstore.
|
||||
package pseudo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
const (
|
||||
eventTypePrefix = eventstore.EventType("pseudo.")
|
||||
ScheduledEventType = eventTypePrefix + "timestamp"
|
||||
)
|
||||
|
||||
var _ eventstore.Event = (*ScheduledEvent)(nil)
|
||||
|
||||
type ScheduledEvent struct {
|
||||
*eventstore.BaseEvent `json:"-"`
|
||||
Timestamp time.Time `json:"-"`
|
||||
InstanceIDs []string `json:"-"`
|
||||
}
|
||||
|
||||
// NewScheduledEvent returns an event that can be processed by event handlers like any other event.
|
||||
// It receives the current timestamp and an ID list of instances that are active and should be processed.
|
||||
func NewScheduledEvent(
|
||||
ctx context.Context,
|
||||
timestamp time.Time,
|
||||
instanceIDs ...string,
|
||||
) *ScheduledEvent {
|
||||
return &ScheduledEvent{
|
||||
BaseEvent: eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
&NewAggregate().Aggregate,
|
||||
ScheduledEventType,
|
||||
),
|
||||
Timestamp: timestamp,
|
||||
InstanceIDs: instanceIDs,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user