fleet/server/service/logging_hosts.go
Zachary Wasserman 715d908613 Update go-kit to 0.4.0 (#1411)
Notable refactoring:
- Use stdlib "context" in place of "golang.org/x/net/context"
- Go-kit no longer wraps errors, so we remove the unwrap in transport_error.go
- Use MakeHandler when setting up endpoint tests (fixes test bug caught during
  this refactoring)

Closes #1411.
2017-03-15 08:55:30 -07:00

80 lines
1.4 KiB
Go

package service
import (
"context"
"time"
"github.com/kolide/kolide/server/kolide"
)
func (mw loggingMiddleware) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) {
var (
hosts []*kolide.Host
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "ListHosts",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
hosts, err = mw.Service.ListHosts(ctx, opt)
return hosts, err
}
func (mw loggingMiddleware) GetHost(ctx context.Context, id uint) (*kolide.Host, error) {
var (
host *kolide.Host
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "GetHost",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
host, err = mw.Service.GetHost(ctx, id)
return host, err
}
func (mw loggingMiddleware) GetHostSummary(ctx context.Context) (*kolide.HostSummary, error) {
var (
summary *kolide.HostSummary
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "GetHostSummary",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
summary, err = mw.Service.GetHostSummary(ctx)
return summary, err
}
func (mw loggingMiddleware) DeleteHost(ctx context.Context, id uint) error {
var (
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "DeleteHost",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
err = mw.Service.DeleteHost(ctx, id)
return err
}