-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from isd-sgcu/gear-be/fdr-66-be-setup-opentelem…
…etry-jeager Gear be/fdr 66 be setup opentelemetry jeager
- Loading branch information
Showing
12 changed files
with
307 additions
and
97 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -17,6 +17,6 @@ COPY --from=builder /app/server ./ | |
|
||
ENV GO_ENV production | ||
|
||
EXPOSE 3000 | ||
EXPOSE 3004 | ||
|
||
CMD ["./server"] |
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
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
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
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
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
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 |
---|---|---|
@@ -1,32 +1,45 @@ | ||
package checkin | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/isd-sgcu/rpkm67-model/model" | ||
"go.opentelemetry.io/otel/trace" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Repository interface { | ||
Create(checkIn *model.CheckIn) error | ||
FindByEmail(email string, checkIns *[]*model.CheckIn) error | ||
FindByUserId(userId string, checkIns *[]*model.CheckIn) error | ||
Create(ctx context.Context, checkIn *model.CheckIn) error | ||
FindByEmail(ctx context.Context, email string, checkIns *[]*model.CheckIn) error | ||
FindByUserId(ctx context.Context, userId string, checkIns *[]*model.CheckIn) error | ||
} | ||
|
||
type repositoryImpl struct { | ||
Db *gorm.DB | ||
Db *gorm.DB | ||
tracer trace.Tracer | ||
} | ||
|
||
func NewRepository(db *gorm.DB) Repository { | ||
return &repositoryImpl{Db: db} | ||
func NewRepository(db *gorm.DB, tracer trace.Tracer) Repository { | ||
return &repositoryImpl{Db: db, tracer: tracer} | ||
} | ||
|
||
func (r *repositoryImpl) Create(checkIn *model.CheckIn) error { | ||
func (r *repositoryImpl) Create(ctx context.Context, checkIn *model.CheckIn) error { | ||
_, span := r.tracer.Start(ctx, "repository.checkin.Create") | ||
defer span.End() | ||
|
||
return r.Db.Create(checkIn).Error | ||
} | ||
|
||
func (r *repositoryImpl) FindByEmail(email string, checkIns *[]*model.CheckIn) error { | ||
func (r *repositoryImpl) FindByEmail(ctx context.Context, email string, checkIns *[]*model.CheckIn) error { | ||
_, span := r.tracer.Start(ctx, "repository.checkin.FindByEmail") | ||
defer span.End() | ||
|
||
return r.Db.Where("email = ?", email).Find(&checkIns).Error | ||
} | ||
|
||
func (r *repositoryImpl) FindByUserId(userId string, checkIns *[]*model.CheckIn) error { | ||
func (r *repositoryImpl) FindByUserId(ctx context.Context, userId string, checkIns *[]*model.CheckIn) error { | ||
_, span := r.tracer.Start(ctx, "repository.checkin.FindByUserId") | ||
defer span.End() | ||
|
||
return r.Db.Where("user_id = ?", userId).Find(&checkIns).Error | ||
} |
Oops, something went wrong.