mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-07 06:25:24 -04:00
Add clustering plugin types; use latest certmagic.Storage interface
This commit is contained in:
+28
@@ -22,6 +22,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/mholt/caddy/caddyfile"
|
||||
"github.com/mholt/certmagic"
|
||||
)
|
||||
|
||||
// These are all the registered plugins.
|
||||
@@ -73,6 +74,13 @@ func DescribePlugins() string {
|
||||
}
|
||||
}
|
||||
|
||||
if len(pl["clustering"]) > 0 {
|
||||
str += "\nClustering plugins:\n"
|
||||
for _, name := range pl["clustering"] {
|
||||
str += " " + name + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
str += "\nOther plugins:\n"
|
||||
for _, name := range pl["others"] {
|
||||
str += " " + name + "\n"
|
||||
@@ -99,6 +107,11 @@ func ListPlugins() map[string][]string {
|
||||
p["caddyfile_loaders"] = append(p["caddyfile_loaders"], defaultCaddyfileLoader.name)
|
||||
}
|
||||
|
||||
// cluster plugins in registration order
|
||||
for name := range clusterProviders {
|
||||
p["clustering"] = append(p["clsutering"], name)
|
||||
}
|
||||
|
||||
// List the event hook plugins
|
||||
eventHooks.Range(func(k, _ interface{}) bool {
|
||||
p["event_hooks"] = append(p["event_hooks"], k.(string))
|
||||
@@ -443,6 +456,21 @@ func loadCaddyfileInput(serverType string) (Input, error) {
|
||||
return caddyfileToUse, nil
|
||||
}
|
||||
|
||||
// ClusterPluginConstructor is a function type that is used to
|
||||
// instantiate a new implementation of both certmagic.Storage
|
||||
// and certmagic.Locker, which are required for successful
|
||||
// use in cluster environments.
|
||||
type ClusterPluginConstructor func() (certmagic.Storage, error)
|
||||
|
||||
// clusterProviders is the list of storage providers
|
||||
var clusterProviders = make(map[string]ClusterPluginConstructor)
|
||||
|
||||
// RegisterClusterPlugin registers provider by name for facilitating
|
||||
// cluster-wide operations like storage and synchronization.
|
||||
func RegisterClusterPlugin(name string, provider ClusterPluginConstructor) {
|
||||
clusterProviders[name] = provider
|
||||
}
|
||||
|
||||
// OnProcessExit is a list of functions to run when the process
|
||||
// exits -- they are ONLY for cleanup and should not block,
|
||||
// return errors, or do anything fancy. They will be run with
|
||||
|
||||
Reference in New Issue
Block a user