github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/apiv3/servicecontext/doc.go (about) 1 /* 2 Adding to the ServiceContext 3 4 The ServiceContext is a very large interface that defines how to access the main 5 state of the database and data central to Evergreen's function. All methods of the 6 ServiceContext are contained in the servicecontext package in files depending 7 on the main type they allow access to (i.e. all test access is contained in servicecontext/test.go). 8 9 Extending ServiceContext should only be done when the desired functionality cannot be performed 10 using a combination of the methods it already contains or when such combination would 11 be unseemingly slow or expensive. 12 13 To add to the ServiceContext, add the method signature into the interface in 14 servicecontext/servicecontext.go. Next, add the implementation that interacts 15 with the database to the database backed object. These objects are named by the 16 resource they allow access to. The object that allows access to Hosts is called 17 DBHostConnector. Finally, add a mock implementation to the mock object. For 18 Hosts again, this object would be called MockHostConnector. 19 20 Implementing database backed methods requires using methods in Evergreen's model 21 package. As much database specific information as possible should be kept out of 22 the these methods. For example, if a new aggregation pipeline is needed to complete 23 the request, it should be defined in the Evergreen model package and used only 24 to aggregate in the method. 25 */ 26 package servicecontext