0a29b59e14
Endpoints are now created at applications startup time, using notification configuration. The instances are then added to a Broadcaster instance, which becomes the main event sink for the application. At request time, an event bridge is configured to listen to repository method calls. The actor and source of the eventBridge are created from the requeest context and application, respectively. The result is notifications are dispatched with calls to the context's Repository instance and are queued to each endpoint via the broadcaster. This commit also adds the concept of a RequestID and App.InstanceID. The request id uniquely identifies each request and the InstanceID uniquely identifies a run of the registry. These identifiers can be used in the future to correlate log messages with generated events to support rich debugging. The fields of the app were slightly reorganized for clarity and a few horrid util functions have been removed. Signed-off-by: Stephen J Day <stephen.day@docker.com>
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package registry
|
|
|
|
import (
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/docker/distribution/api/v2"
|
|
"github.com/docker/distribution/storage"
|
|
)
|
|
|
|
// Context should contain the request specific context for use in across
|
|
// handlers. Resources that don't need to be shared across handlers should not
|
|
// be on this object.
|
|
type Context struct {
|
|
// App points to the application structure that created this context.
|
|
*App
|
|
|
|
// RequestID is the unique id of the request.
|
|
RequestID string
|
|
|
|
// Repository is the repository for the current request. All requests
|
|
// should be scoped to a single repository. This field may be nil.
|
|
Repository storage.Repository
|
|
|
|
// Errors is a collection of errors encountered during the request to be
|
|
// returned to the client API. If errors are added to the collection, the
|
|
// handler *must not* start the response via http.ResponseWriter.
|
|
Errors v2.Errors
|
|
|
|
// vars contains the extracted gorilla/mux variables that can be used for
|
|
// assignment.
|
|
vars map[string]string
|
|
|
|
// log provides a context specific logger.
|
|
log *logrus.Entry
|
|
|
|
urlBuilder *v2.URLBuilder
|
|
}
|