provide a way to run app
This commit is contained in:
@ -37,6 +37,13 @@ type repository struct {
|
||||
client *mongo.Client
|
||||
}
|
||||
|
||||
func (r *repository) Close() error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
|
||||
return r.client.Disconnect(ctx)
|
||||
}
|
||||
|
||||
func (r *repository) StatsRepository() statsRepository {
|
||||
return statsRepository{
|
||||
collection: r.client.Database("bench").Collection("device_stats"),
|
||||
|
||||
@ -34,18 +34,23 @@ func (r *repository) StatsRepository() statsRepository {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *repository) Close() error {
|
||||
r.db.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
type statsRepository struct {
|
||||
db *pgxpool.Pool
|
||||
}
|
||||
|
||||
type deviceStatsDB struct {
|
||||
UpdatedAt time.Time
|
||||
DeviceID string
|
||||
IncomingTraffic int
|
||||
OutgoingTraffic int
|
||||
IncomingRPS int
|
||||
ReadRPS int
|
||||
WriteRPS int
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (s deviceStatsDB) asDomain() entities.DeviceStatistics {
|
||||
|
||||
Reference in New Issue
Block a user