Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backend interface for dbStats #3267

Merged
merged 6 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename and use parameter for interface func
  • Loading branch information
chilagrow committed Aug 29, 2023
commit 003ca767ccba2ae679e7b8d0a97f135494d64d32
19 changes: 10 additions & 9 deletions internal/backends/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Database interface {
DropCollection(context.Context, *DropCollectionParams) error
RenameCollection(context.Context, *RenameCollectionParams) error

DBStats(context.Context) (*DBStatsResult, error)
Stats(context.Context, *StatsParams) (*StatsResult, error)
}

// databaseContract implements Database interface.
Expand Down Expand Up @@ -186,13 +186,14 @@ func (dbc *databaseContract) RenameCollection(ctx context.Context, params *Renam
return err
}

// DBStatsResult represents the results of Database.DBStats method.
//
// MongoDB returns "numbers" that could be int32 or int64.
// FerretDB always returns int64 for simplicity.
// StatsParams represents the parameters of Database.Stats method.
type StatsParams struct {
}

// StatsResult represents the results of Database.Stats method.
//
// TODO https://github.com/FerretDB/FerretDB/issues/2447
type DBStatsResult struct {
type StatsResult struct {
CountCollections int64
CountObjects int64
CountIndexes int64
Expand All @@ -201,13 +202,13 @@ type DBStatsResult struct {
SizeCollections int64
}

// DBStats returns statistics about the database.
// Stats returns statistics about the database.
//
// Database may not exist; that's not an error.
func (dbc *databaseContract) DBStats(ctx context.Context) (*DBStatsResult, error) {
func (dbc *databaseContract) Stats(ctx context.Context, params *StatsParams) (*StatsResult, error) {
defer observability.FuncCall(ctx)()

res, err := dbc.db.DBStats(ctx)
res, err := dbc.db.Stats(ctx, params)
checkError(err)

return res, err
Expand Down
4 changes: 2 additions & 2 deletions internal/backends/postgresql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (db *database) RenameCollection(ctx context.Context, params *backends.Renam
panic("not implemented")
}

// DBStats implements backends.Database interface.
func (db *database) DBStats(ctx context.Context) (*backends.DBStatsResult, error) {
// Stats implements backends.Database interface.
func (db *database) Stats(ctx context.Context, params *backends.StatsParams) (*backends.StatsResult, error) {
panic("not implemented")
}

Expand Down
4 changes: 2 additions & 2 deletions internal/backends/sqlite/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (db *database) RenameCollection(ctx context.Context, params *backends.Renam
panic("not implemented")
}

// DBStats implements backends.Database interface.
func (db *database) DBStats(ctx context.Context) (*backends.DBStatsResult, error) {
// Stats implements backends.Database interface.
func (db *database) Stats(ctx context.Context, params *backends.StatsParams) (*backends.StatsResult, error) {
panic("not implemented")
}

Expand Down