mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
fix: optimize ServerInfo() handler to avoid reading config (#10626)
fixes #10620
This commit is contained in:
@@ -37,6 +37,15 @@ func (c *Target) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Endpoint returns the backend endpoint
|
||||
func (c *Target) Endpoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *Target) String() string {
|
||||
return "console"
|
||||
}
|
||||
|
||||
// Send log message 'e' to console
|
||||
func (c *Target) Send(e interface{}, logKind string) error {
|
||||
entry, ok := e.(log.Entry)
|
||||
|
||||
@@ -39,6 +39,7 @@ type Target struct {
|
||||
// Channel of log entries
|
||||
logCh chan interface{}
|
||||
|
||||
name string
|
||||
// HTTP(s) endpoint
|
||||
endpoint string
|
||||
// Authorization token for `endpoint`
|
||||
@@ -49,6 +50,15 @@ type Target struct {
|
||||
client http.Client
|
||||
}
|
||||
|
||||
// Endpoint returns the backend endpoint
|
||||
func (h *Target) Endpoint() string {
|
||||
return h.endpoint
|
||||
}
|
||||
|
||||
func (h *Target) String() string {
|
||||
return h.name
|
||||
}
|
||||
|
||||
// Validate validate the http target
|
||||
func (h *Target) Validate() error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
@@ -145,6 +155,13 @@ func (h *Target) startHTTPLogger() {
|
||||
// Option is a function type that accepts a pointer Target
|
||||
type Option func(*Target)
|
||||
|
||||
// WithTargetName target name
|
||||
func WithTargetName(name string) Option {
|
||||
return func(t *Target) {
|
||||
t.name = name
|
||||
}
|
||||
}
|
||||
|
||||
// WithEndpoint adds a new endpoint
|
||||
func WithEndpoint(endpoint string) Option {
|
||||
return func(t *Target) {
|
||||
|
||||
Reference in New Issue
Block a user