-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christian Richter <[email protected]>
- Loading branch information
1 parent
f64ccd0
commit 221815c
Showing
52 changed files
with
871 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package debug | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/owncloud/ocis/v2/ocis-pkg/log" | ||
"github.com/owncloud/ocis/v2/services/audit/pkg/config" | ||
) | ||
|
||
// Option defines a single option function. | ||
type Option func(o *Options) | ||
|
||
// Options defines the available options for this package. | ||
type Options struct { | ||
Logger log.Logger | ||
Context context.Context | ||
Config *config.Config | ||
} | ||
|
||
// newOptions initializes the available default options. | ||
func newOptions(opts ...Option) Options { | ||
opt := Options{} | ||
|
||
for _, o := range opts { | ||
o(&opt) | ||
} | ||
|
||
return opt | ||
} | ||
|
||
// Logger provides a function to set the logger option. | ||
func Logger(val log.Logger) Option { | ||
return func(o *Options) { | ||
o.Logger = val | ||
} | ||
} | ||
|
||
// Context provides a function to set the context option. | ||
func Context(val context.Context) Option { | ||
return func(o *Options) { | ||
o.Context = val | ||
} | ||
} | ||
|
||
// Config provides a function to set the config option. | ||
func Config(val *config.Config) Option { | ||
return func(o *Options) { | ||
o.Config = val | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package debug | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/owncloud/ocis/v2/ocis-pkg/handlers" | ||
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug" | ||
"github.com/owncloud/ocis/v2/ocis-pkg/version" | ||
) | ||
|
||
// Server initializes the debug service and server. | ||
func Server(opts ...Option) (*http.Server, error) { | ||
options := newOptions(opts...) | ||
|
||
checkHandler := handlers.NewCheckHandler( | ||
handlers.NewCheckHandlerConfiguration(). | ||
WithLogger(options.Logger), | ||
) | ||
|
||
return debug.NewService( | ||
debug.Logger(options.Logger), | ||
debug.Name(options.Config.Service.Name), | ||
debug.Version(version.GetString()), | ||
debug.Address(options.Config.Debug.Addr), | ||
debug.Token(options.Config.Debug.Token), | ||
debug.Pprof(options.Config.Debug.Pprof), | ||
debug.Zpages(options.Config.Debug.Zpages), | ||
debug.Health(checkHandler), | ||
debug.Ready(checkHandler), | ||
), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package debug | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/owncloud/ocis/v2/ocis-pkg/log" | ||
"github.com/owncloud/ocis/v2/services/clientlog/pkg/config" | ||
) | ||
|
||
// Option defines a single option function. | ||
type Option func(o *Options) | ||
|
||
// Options defines the available options for this package. | ||
type Options struct { | ||
Logger log.Logger | ||
Context context.Context | ||
Config *config.Config | ||
} | ||
|
||
// newOptions initializes the available default options. | ||
func newOptions(opts ...Option) Options { | ||
opt := Options{} | ||
|
||
for _, o := range opts { | ||
o(&opt) | ||
} | ||
|
||
return opt | ||
} | ||
|
||
// Logger provides a function to set the logger option. | ||
func Logger(val log.Logger) Option { | ||
return func(o *Options) { | ||
o.Logger = val | ||
} | ||
} | ||
|
||
// Context provides a function to set the context option. | ||
func Context(val context.Context) Option { | ||
return func(o *Options) { | ||
o.Context = val | ||
} | ||
} | ||
|
||
// Config provides a function to set the config option. | ||
func Config(val *config.Config) Option { | ||
return func(o *Options) { | ||
o.Config = val | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package debug | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/owncloud/ocis/v2/ocis-pkg/handlers" | ||
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug" | ||
"github.com/owncloud/ocis/v2/ocis-pkg/version" | ||
) | ||
|
||
// Server initializes the debug service and server. | ||
func Server(opts ...Option) (*http.Server, error) { | ||
options := newOptions(opts...) | ||
|
||
checkHandler := handlers.NewCheckHandler( | ||
handlers.NewCheckHandlerConfiguration(). | ||
WithLogger(options.Logger), | ||
) | ||
|
||
return debug.NewService( | ||
debug.Logger(options.Logger), | ||
debug.Name(options.Config.Service.Name), | ||
debug.Version(version.GetString()), | ||
debug.Address(options.Config.Debug.Addr), | ||
debug.Token(options.Config.Debug.Token), | ||
debug.Pprof(options.Config.Debug.Pprof), | ||
debug.Zpages(options.Config.Debug.Zpages), | ||
debug.Health(checkHandler), | ||
debug.Ready(checkHandler), | ||
), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.