Skip to content
This repository has been archived by the owner on Feb 28, 2019. It is now read-only.

Commit

Permalink
remove prop delay from server object
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Skelcy committed Apr 16, 2018
1 parent d0d12d8 commit 1f190ca
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 31 deletions.
29 changes: 12 additions & 17 deletions service/r2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ import (
"errors"
"fmt"
"net/http"
"time"

"github.com/m3db/m3ctl/auth"
mservice "github.com/m3db/m3ctl/service"
"github.com/m3db/m3ctl/service/r2/store"
"github.com/m3db/m3metrics/rules"
"github.com/m3db/m3x/clock"
"github.com/m3db/m3x/instrument"
"github.com/m3db/m3x/log"
Expand Down Expand Up @@ -134,13 +132,12 @@ func registerRoute(router *mux.Router, path, method string, h r2Handler, hf r2Ha

// service handles all of the endpoints for r2.
type service struct {
rootPrefix string
store store.Store
authService auth.HTTPAuthService
logger log.Logger
nowFn clock.NowFn
metrics serviceMetrics
updateHelper rules.RuleSetUpdateHelper
rootPrefix string
store store.Store
authService auth.HTTPAuthService
logger log.Logger
nowFn clock.NowFn
metrics serviceMetrics
}

// NewService creates a new r2 service using a given store.
Expand All @@ -150,16 +147,14 @@ func NewService(
store store.Store,
iOpts instrument.Options,
clockOpts clock.Options,
rulePropagationDelay time.Duration,
) mservice.Service {
return &service{
rootPrefix: rootPrefix,
store: store,
authService: authService,
logger: iOpts.Logger(),
nowFn: clockOpts.NowFn(),
metrics: newServiceMetrics(iOpts.MetricsScope(), iOpts.MetricsSamplingRate()),
updateHelper: rules.NewRuleSetUpdateHelper(rulePropagationDelay),
rootPrefix: rootPrefix,
store: store,
authService: authService,
logger: iOpts.Logger(),
nowFn: clockOpts.NowFn(),
metrics: newServiceMetrics(iOpts.MetricsScope(), iOpts.MetricsSamplingRate()),
}
}

Expand Down
3 changes: 2 additions & 1 deletion service/r2/store/stub/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import (
"fmt"
"time"

"github.com/pborman/uuid"

"github.com/m3db/m3ctl/service/r2"
r2store "github.com/m3db/m3ctl/service/r2/store"
"github.com/m3db/m3metrics/policy"
"github.com/m3db/m3metrics/rules"
"github.com/m3db/m3metrics/rules/models"
"github.com/m3db/m3metrics/rules/models/changes"
"github.com/m3db/m3x/instrument"
"github.com/pborman/uuid"
)

type mappingRuleHistories map[string][]*models.MappingRuleView
Expand Down
8 changes: 4 additions & 4 deletions services/r2ctl/config/r2ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ type Configuration struct {
Metrics instrument.MetricsConfiguration `yaml:"metrics"`

// Store configuration.
Store R2StoreConfiguration `yaml:"store"`
Store r2StoreConfiguration `yaml:"store"`

// Simple Auth Config.
Auth *auth.SimpleAuthConfig `yaml:"auth"`
}

// R2StoreConfiguration has all the fields necessary for an R2 store.
type R2StoreConfiguration struct {
// r2StoreConfiguration has all the fields necessary for an R2 store.
type r2StoreConfiguration struct {
// Stub means use the stub store.
Stub bool `yaml:"stub"`

Expand All @@ -69,7 +69,7 @@ type R2StoreConfiguration struct {
}

// NewR2Store creates a new R2 store.
func (c R2StoreConfiguration) NewR2Store(instrumentOpts instrument.Options) (r2store.Store, error) {
func (c r2StoreConfiguration) NewR2Store(instrumentOpts instrument.Options) (r2store.Store, error) {
if c.Stub {
return stub.NewStore(instrumentOpts), nil
}
Expand Down
9 changes: 0 additions & 9 deletions services/r2ctl/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const (
portEnvVar = "R2CTL_PORT"
r2apiPrefix = "/r2/v1/"
gracefulShutdownTimeout = 15 * time.Second
defaultPropagationDelay = time.Minute
)

func main() {
Expand Down Expand Up @@ -109,20 +108,12 @@ func main() {
"service-name": "r2",
})
r2ServiceInstrumentOpts := instrumentOpts.SetMetricsScope(r2ServiceScope)
var propagationDelay time.Duration
if cfg.Store.KV != nil {
propagationDelay = cfg.Store.KV.PropagationDelay
} else {
propagationDelay = defaultPropagationDelay
}

r2Service := r2.NewService(
r2apiPrefix,
authService,
store,
r2ServiceInstrumentOpts,
clock.NewOptions(),
propagationDelay,
)

// Create health service.
Expand Down

0 comments on commit 1f190ca

Please sign in to comment.