Documentation ¶
Overview ¶
Adding to the Connector
The Connector is a very large interface that defines how to access the main state of the database and data central to Evergreen's function. All methods of the Connector are contained in the data package in files depending on the main type they allow access to (i.e. all test access is contained in data/test.go).
Extending Connector should only be done when the desired functionality cannot be performed using a combination of the methods it already contains or when such combination would be unseemingly slow or expensive.
To add to the Connector, add the method signature into the interface in data/data.go. Next, add the implementation that interacts with the database to the database backed object. These objects are named by the resource they allow access to. The object that allows access to Hosts is called DBHostConnector. Finally, add a mock implementation to the mock object. For Hosts again, this object would be called MockHostConnector.
Implementing database backed methods requires using methods in Evergreen's model package. As much database specific information as possible should be kept out of the these methods. For example, if a new aggregation pipeline is needed to complete the request, it should be defined in the Evergreen model package and used only to aggregate in the method.
Index ¶
- type Connector
- type DBConnector
- type DBContextConnector
- type DBHostConnector
- type DBTaskConnector
- func (tc *DBTaskConnector) FindTaskById(taskId string) (*task.Task, error)
- func (tc *DBTaskConnector) FindTasksByBuildId(buildId, taskId, status string, limit int, sortDir int) ([]task.Task, error)
- func (tc *DBTaskConnector) FindTasksByIds(ids []string) ([]task.Task, error)
- func (tc *DBTaskConnector) ResetTask(taskId, username string, proj *serviceModel.Project) error
- func (tc *DBTaskConnector) SetTaskActivated(taskId, user string, activated bool) error
- func (tc *DBTaskConnector) SetTaskPriority(t *task.Task, priority int64) error
- type DBTestConnector
- type DBUserConnector
- type MockConnector
- type MockContextConnector
- type MockHostConnector
- type MockTaskConnector
- func (mtc *MockTaskConnector) FindTaskById(taskId string) (*task.Task, error)
- func (mdf *MockTaskConnector) FindTasksByBuildId(buildId, startTaskId, status string, limit, sortDir int) ([]task.Task, error)
- func (mdf *MockTaskConnector) FindTasksByIds(taskIds []string) ([]task.Task, error)
- func (mtc *MockTaskConnector) FindTasksByProjectAndCommit(projectId, commitHash, taskId, status string, limit, sortDir int) ([]task.Task, error)
- func (mdf *MockTaskConnector) ResetTask(taskId, username string, proj *serviceModel.Project) error
- func (mdf *MockTaskConnector) SetTaskActivated(taskId, user string, activated bool) error
- func (mdf *MockTaskConnector) SetTaskPriority(it *task.Task, priority int64) error
- type MockTestConnector
- type MockUserConnector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface { // Get and Set SuperUsers provide access to the list of API super users. GetSuperUsers() []string SetSuperUsers([]string) // Get and Set URL provide access to the main url string of the API. GetURL() string SetURL(string) // Get and Set Prefix provide access to the prefix that prepends all of the // URL paths. GetPrefix() string SetPrefix(string) // FindTaskById is a method to find a specific task given its ID. FindTaskById(string) (*task.Task, error) FindTasksByIds([]string) ([]task.Task, error) SetTaskPriority(*task.Task, int64) error SetTaskActivated(string, string, bool) error ResetTask(string, string, *model.Project) error // FindTasksByBuildId is a method to find a set of tasks which all have the same // BuildId. It takes the buildId being queried for as its first parameter, // as well as a taskId and limit for paginating through the results. // It returns a list of tasks which match. FindTasksByBuildId(string, string, string, int, int) ([]task.Task, error) // FindByProjectAndCommit is a method to find a set of tasks which ran as part of // certain version in a project. It takes the projectId, commit hash, and a taskId // for paginating through the results. FindTasksByProjectAndCommit(string, string, string, string, int, int) ([]task.Task, error) // FindTestsByTaskId is a methodd to find a set of tests that correspond to // a given task. It takes a taskId, testName to start from, test status to filter, // limit, and sort to provide additional control over the results. FindTestsByTaskId(string, string, string, int, int) ([]task.TestResult, error) // FindUserById is a method to find a specific user given its ID. FindUserById(string) (auth.APIUser, error) // FindHostsById is a method to find a sorted list of hosts given an ID to // start from. FindHostsById(string, string, int, int) ([]host.Host, error) // FetchContext is a method to fetch a context given a series of identifiers. FetchContext(string, string, string, string, string) (model.Context, error) }
Connector is an interface that contains all of the methods which connect to the service layer of evergreen. These methods abstract the link between the service and the API layers, allowing for changes in the service architecture without forcing changes to the API.
type DBConnector ¶
type DBConnector struct { URL string Prefix string DBUserConnector DBTaskConnector DBContextConnector DBHostConnector DBTestConnector // contains filtered or unexported fields }
DBConnector is a struct that implements all of the methods which connect to the service layer of evergreen. These methods abstract the link between the service and the API layers, allowing for changes in the service architecture without forcing changes to the API.
func (*DBConnector) GetPrefix ¶
func (ctx *DBConnector) GetPrefix() string
func (*DBConnector) GetSuperUsers ¶
func (ctx *DBConnector) GetSuperUsers() []string
func (*DBConnector) GetURL ¶
func (ctx *DBConnector) GetURL() string
func (*DBConnector) SetPrefix ¶
func (ctx *DBConnector) SetPrefix(prefix string)
func (*DBConnector) SetSuperUsers ¶
func (ctx *DBConnector) SetSuperUsers(su []string)
func (*DBConnector) SetURL ¶
func (ctx *DBConnector) SetURL(url string)
type DBContextConnector ¶
type DBContextConnector struct{}
DBContextConnector is a struct that implements the Context related functions of the ServiceConnector interface through interactions with the backing database.
func (*DBContextConnector) FetchContext ¶
func (dc *DBContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error)
LoadContext fetches the context through a call to the service layer.
type DBHostConnector ¶
type DBHostConnector struct{}
DBHostConnector is a struct that implements the Host related methods from the Connector through interactions with the backing database.
func (*DBHostConnector) FindHostsById ¶
func (hc *DBHostConnector) FindHostsById(id, status string, limit int, sortDir int) ([]host.Host, error)
FindHosts uses the service layer's host type to query the backing database for the hosts.
type DBTaskConnector ¶
type DBTaskConnector struct{}
DBTaskConnector is a struct that implements the Task related methods from the Connector through interactions with he backing database.
func (*DBTaskConnector) FindTaskById ¶
func (tc *DBTaskConnector) FindTaskById(taskId string) (*task.Task, error)
FindTaskById uses the service layer's task type to query the backing database for the task with the given taskId.
func (*DBTaskConnector) FindTasksByBuildId ¶
func (tc *DBTaskConnector) FindTasksByBuildId(buildId, taskId, status string, limit int, sortDir int) ([]task.Task, error)
FindTasksByBuildId uses the service layer's task type to query the backing database for a list of task that matches buildId. It accepts the startTaskId and a limit to allow for pagination of the queries. It returns results sorted by taskId.
func (*DBTaskConnector) FindTasksByIds ¶
func (tc *DBTaskConnector) FindTasksByIds(ids []string) ([]task.Task, error)
func (*DBTaskConnector) ResetTask ¶
func (tc *DBTaskConnector) ResetTask(taskId, username string, proj *serviceModel.Project) error
ResetTask sets the task to be in an unexecuted state and prepares it to be run again.
func (*DBTaskConnector) SetTaskActivated ¶
func (tc *DBTaskConnector) SetTaskActivated(taskId, user string, activated bool) error
SetTaskPriority changes the priority value of a task using a call to the service layer function.
func (*DBTaskConnector) SetTaskPriority ¶
func (tc *DBTaskConnector) SetTaskPriority(t *task.Task, priority int64) error
SetTaskPriority changes the priority value of a task using a call to the service layer function.
type DBTestConnector ¶
type DBTestConnector struct{}
DBTestConnector is a struct that implements the Test related methods from the Connector through interactions with the backing database.
func (*DBTestConnector) FindTasksByProjectAndCommit ¶
func (*DBTestConnector) FindTestsByTaskId ¶
func (tc *DBTestConnector) FindTestsByTaskId(taskId, testFilename, status string, limit, sortDir int) ([]task.TestResult, error)
type DBUserConnector ¶
type DBUserConnector struct{}
DBUserConnector is a struct that implements the User related interface of the Connector interface through interactions with the backing database.
func (*DBUserConnector) FindUserById ¶
func (tc *DBUserConnector) FindUserById(userId string) (auth.APIUser, error)
FindUserById uses the service layer's user type to query the backing database for the user with the given Id.
type MockConnector ¶
type MockConnector struct { URL string Prefix string MockUserConnector MockTaskConnector MockContextConnector MockHostConnector MockTestConnector // contains filtered or unexported fields }
func (*MockConnector) GetPrefix ¶
func (ctx *MockConnector) GetPrefix() string
func (*MockConnector) GetSuperUsers ¶
func (ctx *MockConnector) GetSuperUsers() []string
func (*MockConnector) GetURL ¶
func (ctx *MockConnector) GetURL() string
func (*MockConnector) SetPrefix ¶
func (ctx *MockConnector) SetPrefix(prefix string)
func (*MockConnector) SetSuperUsers ¶
func (ctx *MockConnector) SetSuperUsers(su []string)
func (*MockConnector) SetURL ¶
func (ctx *MockConnector) SetURL(url string)
type MockContextConnector ¶
MockContextConnector is a struct that mocks the context methods by storing context to be fetched by its method.
func (*MockContextConnector) FetchContext ¶
func (mc *MockContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error)
FetchContext returns the context cached within the MockContextConnector.
type MockHostConnector ¶
MockHostConnector is a struct that implements the Host related methods from the Connector through interactions with he backing database.
func (*MockHostConnector) FindHostsById ¶
func (hc *MockHostConnector) FindHostsById(id, status string, limit int, sort int) ([]host.Host, error)
FindHosts uses the service layer's host type to query the backing database for the hosts.
type MockTaskConnector ¶
MockTaskConnector stores a cached set of tasks that are queried against by the implementations of the Connector interface's Task related functions.
func (*MockTaskConnector) FindTaskById ¶
func (mtc *MockTaskConnector) FindTaskById(taskId string) (*task.Task, error)
FindTaskById provides a mock implementation of the functions for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockTaskConnector.
func (*MockTaskConnector) FindTasksByBuildId ¶
func (mdf *MockTaskConnector) FindTasksByBuildId(buildId, startTaskId, status string, limit, sortDir int) ([]task.Task, error)
FindTaskByBuildId provides a mock implementation of the function for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockTaskConnector.
func (*MockTaskConnector) FindTasksByIds ¶
func (mdf *MockTaskConnector) FindTasksByIds(taskIds []string) ([]task.Task, error)
func (*MockTaskConnector) FindTasksByProjectAndCommit ¶
func (mtc *MockTaskConnector) FindTasksByProjectAndCommit(projectId, commitHash, taskId, status string, limit, sortDir int) ([]task.Task, error)
FindTestsBytaskId
func (*MockTaskConnector) ResetTask ¶
func (mdf *MockTaskConnector) ResetTask(taskId, username string, proj *serviceModel.Project) error
func (*MockTaskConnector) SetTaskActivated ¶
func (mdf *MockTaskConnector) SetTaskActivated(taskId, user string, activated bool) error
SetTaskActivated changes the activation value of a task using a call to the service layer function.
func (*MockTaskConnector) SetTaskPriority ¶
func (mdf *MockTaskConnector) SetTaskPriority(it *task.Task, priority int64) error
SetTaskPriority changes the priority value of a task using a call to the service layer function.
type MockTestConnector ¶
type MockTestConnector struct { CachedTests []task.TestResult StoredError error }
MockTaskConnector stores a cached set of tests that are queried against by the implementations of the Connector interface's Test related functions.
func (*MockTestConnector) FindTestsByTaskId ¶
func (mtc *MockTestConnector) FindTestsByTaskId(taskId, testFilename, status string, limit, sortDir int) ([]task.TestResult, error)
FindTestsBytaskId
type MockUserConnector ¶
MockUserConnector stores a cached set of users that are queried against by the implementations of the UserConnector interface's functions.
func (*MockUserConnector) FindUserById ¶
func (muc *MockUserConnector) FindUserById(userId string) (auth.APIUser, error)
FindUserById provides a mock implementation of the User functions from the Connector that does not need to use a database. It returns results based on the cached users in the MockUserConnector.