Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
691204ce
Commit
691204ce
authored
Oct 15, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OncePerServerBlock may now return an error
parent
a518049f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
config/config.go
config/config.go
+9
-3
config/setup/controller.go
config/setup/controller.go
+5
-2
config/setup/startupshutdown.go
config/setup/startupshutdown.go
+2
-3
No files found.
config/config.go
View file @
691204ce
...
...
@@ -66,9 +66,15 @@ func Load(filename string, input io.Reader) (Group, error) {
// server config and the dispenser containing only
// this directive's tokens.
controller
:=
&
setup
.
Controller
{
Config
:
&
config
,
Dispenser
:
parse
.
NewDispenserTokens
(
filename
,
tokens
),
OncePerServerBlock
:
func
(
f
func
())
{
onces
[
dir
.
name
]
.
Do
(
f
)
},
Config
:
&
config
,
Dispenser
:
parse
.
NewDispenserTokens
(
filename
,
tokens
),
OncePerServerBlock
:
func
(
f
func
()
error
)
error
{
var
err
error
onces
[
dir
.
name
]
.
Do
(
func
()
{
err
=
f
()
})
return
err
},
}
midware
,
err
:=
dir
.
setup
(
controller
)
...
...
config/setup/controller.go
View file @
691204ce
...
...
@@ -19,8 +19,11 @@ type Controller struct {
// OncePerServerBlock is a function that executes f
// exactly once per server block, no matter how many
// hosts are associated with it.
OncePerServerBlock
func
(
f
func
())
// hosts are associated with it. If it is the first
// time, the function f is executed immediately
// (not deferred) and may return an error which is
// returned by OncePerServerBlock.
OncePerServerBlock
func
(
f
func
()
error
)
error
}
// NewTestController creates a new *Controller for
...
...
config/setup/startupshutdown.go
View file @
691204ce
...
...
@@ -55,9 +55,8 @@ func registerCallback(c *Controller, list *[]func() error) error {
funcs
=
append
(
funcs
,
fn
)
}
c
.
OncePerServerBlock
(
func
()
{
return
c
.
OncePerServerBlock
(
func
()
error
{
*
list
=
append
(
*
list
,
funcs
...
)
return
nil
})
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment