-
Notifications
You must be signed in to change notification settings - Fork 12
/
utils.go
32 lines (25 loc) · 1.19 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package reminder
import (
"context"
"github.com/openline-ai/openline-customer-os/packages/server/events-processing-platform/domain/common/aggregate"
"github.com/openline-ai/openline-customer-os/packages/server/events-processing-platform/eventstore"
"github.com/openline-ai/openline-customer-os/packages/server/events-processing-platform/tracing"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/log"
)
func GetReminderObjectID(aggregateID string, tenant string) string {
return aggregate.GetAggregateObjectID(aggregateID, tenant, ReminderAggregateType)
}
func LoadReminderAggregate(ctx context.Context, eventStore eventstore.AggregateStore, tenant, objectID string, opts eventstore.LoadAggregateOptions) (*ReminderAggregate, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "LoadReminderAggregate")
defer span.Finish()
span.SetTag(tracing.SpanTagTenant, tenant)
span.LogFields(log.String("ObjectID", objectID))
reminderAggregate := NewReminderAggregateWithTenantAndID(tenant, objectID)
err := aggregate.LoadAggregate(ctx, eventStore, reminderAggregate, opts)
if err != nil {
tracing.TraceErr(span, err)
return nil, err
}
return reminderAggregate, nil
}