aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-05-17 08:48:12 -0600
committerMatthew Holt <[email protected]>2019-05-17 08:48:12 -0600
commit1a20fe330ecc39e8b98b5669b836f3b1b185f622 (patch)
treea728bbf310d112d7b54b14111717fea04b96d528 /modules.go
parent1f0c061ce30f218e63fcc17e0fdfc8b90d754ba5 (diff)
downloadcaddy-1a20fe330ecc39e8b98b5669b836f3b1b185f622.tar.gz
caddy-1a20fe330ecc39e8b98b5669b836f3b1b185f622.zip
Improve godoc for contexts
Diffstat (limited to 'modules.go')
-rw-r--r--modules.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/modules.go b/modules.go
index bba6b93a4..afe4b385a 100644
--- a/modules.go
+++ b/modules.go
@@ -136,23 +136,32 @@ func getModuleNameInline(moduleNameKey string, raw json.RawMessage) (string, err
return moduleName, nil
}
-// Validator is implemented by modules which can verify that their
-// configurations are valid. This method will be called after New()
-// instantiations of modules (if implemented). Validation should
-// always be fast (imperceptible running time) and an error should
-// be returned only if the value's configuration is invalid.
-type Validator interface {
- Validate(Context) error
-}
-
// Provisioner is implemented by modules which may need to perform
// some additional "setup" steps immediately after being loaded.
-// This method will be called after Validate() (if implemented).
+// Provisioning should be fast (imperceptible running time). If
+// any side-effects result in the execution of this function (e.g.
+// creating global state, any other allocations which require
+// garbage collection, opening files, starting goroutines etc.),
+// be sure to clean up properly by implementing the CleanerUpper
+// interface to avoid leaking resources.
type Provisioner interface {
Provision(Context) error
}
-// TODO: different name...
+// Validator is implemented by modules which can verify that their
+// configurations are valid. This method will be called after
+// Provision() (if implemented). Validation should always be fast
+// (imperceptible running time) and an error should be returned only
+// if the value's configuration is invalid.
+type Validator interface {
+ Validate() error
+}
+
+// CleanerUpper is implemented by modules which may have side-effects
+// such as opened files, spawned goroutines, or allocated some sort
+// of non-local state when they were provisioned. This method should
+// deallocate/cleanup those resources to prevent memory leaks. Cleanup
+// should be fast and efficient.
type CleanerUpper interface {
Cleanup() error
}