MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / Get

Method Get

api/pkg/services/user_service.go:135–150  ·  view source on GitHub ↗

Get fetches or creates an entities.User

(ctx context.Context, source string, authUser entities.AuthContext)

Source from the content-addressed store, hash-verified

133
134// Get fetches or creates an entities.User
135func (service *UserService) Get(ctx context.Context, source string, authUser entities.AuthContext) (*entities.User, error) {
136 ctx, span := service.tracer.Start(ctx)
137 defer span.End()
138
139 user, isNew, err := service.repository.LoadOrStore(ctx, authUser)
140 if err != nil {
141 msg := fmt.Sprintf("could not get [%T] with from [%+#v]", user, authUser)
142 return nil, service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
143 }
144
145 if isNew {
146 service.dispatchUserCreatedEvent(ctx, source, user)
147 }
148
149 return user, nil
150}
151
152func (service *UserService) dispatchUserCreatedEvent(ctx context.Context, source string, user *entities.User) {
153 ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)

Callers

nothing calls this directly

Calls 4

StartMethod · 0.65
LoadOrStoreMethod · 0.65
WrapErrorSpanMethod · 0.65

Tested by

no test coverage detected