-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: integrated database services into task data insert
- Loading branch information
Showing
12 changed files
with
161 additions
and
264 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
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package interfaces | ||
|
||
import ( | ||
"go.mongodb.org/mongo-driver/bson/primitive" | ||
) | ||
|
||
type DatabaseRegistryService interface { | ||
Start() | ||
CheckStatus() | ||
GetDatabaseService(id primitive.ObjectID) (res DatabaseService, err error) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package interfaces | ||
|
||
import ( | ||
"github.com/crawlab-team/crawlab/core/database/entity" | ||
"github.com/crawlab-team/crawlab/core/models/models/v2" | ||
"go.mongodb.org/mongo-driver/bson/primitive" | ||
) | ||
|
||
type DatabaseService interface { | ||
TestConnection(id primitive.ObjectID) (err error) | ||
GetMetadata(id primitive.ObjectID) (m *entity.DatabaseMetadata, err error) | ||
GetMetadataAllDb(id primitive.ObjectID) (m *entity.DatabaseMetadata, err error) | ||
CreateDatabase(id primitive.ObjectID, databaseName string) (err error) | ||
DropDatabase(id primitive.ObjectID, databaseName string) (err error) | ||
GetTableMetadata(id primitive.ObjectID, databaseName, tableName string) (table *entity.DatabaseTable, err error) | ||
CreateTable(id primitive.ObjectID, databaseName string, table *entity.DatabaseTable) (err error) | ||
ModifyTable(id primitive.ObjectID, databaseName string, table *entity.DatabaseTable) (err error) | ||
DropTable(id primitive.ObjectID, databaseName, tableName string) (err error) | ||
RenameTable(id primitive.ObjectID, databaseName, oldTableName, newTableName string) (err error) | ||
GetColumnTypes(query string) (types []string) | ||
ReadRows(id primitive.ObjectID, databaseName, tableName string, filter map[string]interface{}, skip, limit int) ([]map[string]interface{}, int64, error) | ||
CreateRow(id primitive.ObjectID, databaseName, tableName string, row map[string]interface{}) error | ||
UpdateRow(id primitive.ObjectID, databaseName, tableName string, filter map[string]interface{}, update map[string]interface{}) error | ||
DeleteRow(id primitive.ObjectID, databaseName, tableName string, filter map[string]interface{}) error | ||
Query(id primitive.ObjectID, databaseName, query string) (results *entity.DatabaseQueryResults, err error) | ||
GetCurrentMetric(id primitive.ObjectID) (m *models.DatabaseMetricV2, err error) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package database | ||
|
||
import ( | ||
"github.com/crawlab-team/crawlab/core/database/interfaces" | ||
) | ||
|
||
var serviceInstance interfaces.DatabaseRegistryService | ||
|
||
func SetDatabaseRegistryService(svc interfaces.DatabaseRegistryService) { | ||
serviceInstance = svc | ||
} | ||
|
||
func GetDatabaseRegistryService() interfaces.DatabaseRegistryService { | ||
return serviceInstance | ||
} |
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
Oops, something went wrong.