schemas / check (push) Skipped
schemas / vulnerabilities (push) Skipped
schemas / check-release (push) Skipped
schemas / build (push) Skipped
pre-commit / pre-commit (push) Skipped
schemas / vulnerabilities (pull_request) Successful in 58s
schemas / check-release (pull_request) Successful in 59s
schemas / check (pull_request) Successful in 1m58s
pre-commit / pre-commit (pull_request) Successful in 2m54s
schemas / build (pull_request) Successful in 6m9s
schemas / deploy-prod (pull_request) Skipped
Move eventsourced modules from gitlab.com/unboundsoftware to codeberg.org/eventsourced. The Codeberg amqp publisher is built on go-messaging-amqp, so the service switches from sparetimecoders/goamqp as well: - routing keys are mapped on the eventsourced publisher (newEventPublisher) - cache consumers are typed handlers; Cache.Update drops the goamqp shape - publishes detach from the request context (uncancelledPublisher) - closeEvents is buffered and the receiver also watches rootCtx - WithPrefetchLimit dropped (no-op, 20 is the default) - amqp091-go v1.15.0 (GO-2026-6372) - renovate groups codeberg.org/messaging with eventsourced Only transient consumer queues are used, so no queue cutover is needed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dpb7Y47dPz246oY9bCzh7k
95 lines
2.5 KiB
Go
95 lines
2.5 KiB
Go
package domain
|
|
|
|
import "codeberg.org/eventsourced/eventsourced"
|
|
|
|
type OrganizationAdded struct {
|
|
eventsourced.BaseEvent
|
|
Name string `json:"name"`
|
|
Initiator string `json:"initiator"`
|
|
}
|
|
|
|
func (a *OrganizationAdded) UpdateOrganization(o *Organization) {
|
|
o.Name = a.Name
|
|
o.Users = []string{a.Initiator}
|
|
o.CreatedBy = a.Initiator
|
|
o.CreatedAt = a.When()
|
|
o.ChangedBy = a.Initiator
|
|
o.ChangedAt = a.When()
|
|
}
|
|
|
|
type UserAddedToOrganization struct {
|
|
eventsourced.BaseEvent
|
|
UserId string `json:"userId"`
|
|
Initiator string `json:"initiator"`
|
|
}
|
|
|
|
func (a *UserAddedToOrganization) UpdateOrganization(o *Organization) {
|
|
// Check if user is already in the organization
|
|
for _, user := range o.Users {
|
|
if user == a.UserId {
|
|
return // User already exists, no need to add
|
|
}
|
|
}
|
|
o.Users = append(o.Users, a.UserId)
|
|
o.ChangedBy = a.Initiator
|
|
o.ChangedAt = a.When()
|
|
}
|
|
|
|
type APIKeyAdded struct {
|
|
eventsourced.BaseEvent
|
|
OrganizationId string `json:"organizationId"`
|
|
Name string `json:"name"`
|
|
Key string `json:"key"`
|
|
Refs []string `json:"refs"`
|
|
Read bool `json:"read"`
|
|
Publish bool `json:"publish"`
|
|
Initiator string `json:"initiator"`
|
|
}
|
|
|
|
func (a *APIKeyAdded) EnrichFromAggregate(aggregate eventsourced.Aggregate) {
|
|
a.OrganizationId = aggregate.Identity().String()
|
|
}
|
|
|
|
var _ eventsourced.EnrichableEvent = &APIKeyAdded{}
|
|
|
|
type APIKeyRemoved struct {
|
|
eventsourced.BaseEvent
|
|
KeyName string `json:"keyName"`
|
|
Initiator string `json:"initiator"`
|
|
}
|
|
|
|
func (a *APIKeyRemoved) UpdateOrganization(o *Organization) {
|
|
// Remove the API key from the organization
|
|
for i, key := range o.APIKeys {
|
|
if key.Name == a.KeyName {
|
|
o.APIKeys = append(o.APIKeys[:i], o.APIKeys[i+1:]...)
|
|
break
|
|
}
|
|
}
|
|
o.ChangedBy = a.Initiator
|
|
o.ChangedAt = a.When()
|
|
}
|
|
|
|
type OrganizationRemoved struct {
|
|
eventsourced.BaseEvent
|
|
Initiator string `json:"initiator"`
|
|
}
|
|
|
|
func (a *OrganizationRemoved) UpdateOrganization(o *Organization) {
|
|
// Mark organization as removed by clearing critical fields
|
|
// The aggregate will still exist in the event store, but it's logically deleted
|
|
o.ChangedBy = a.Initiator
|
|
o.ChangedAt = a.When()
|
|
}
|
|
|
|
type SubGraphUpdated struct {
|
|
eventsourced.BaseEvent
|
|
OrganizationId string `json:"organizationId"`
|
|
Ref string `json:"ref"`
|
|
Service string `json:"service"`
|
|
Url *string `json:"url"`
|
|
WSUrl *string `json:"wsUrl"`
|
|
Sdl string `json:"sdl"`
|
|
Initiator string `json:"initiator"`
|
|
}
|