Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
Remove import alias
Browse files Browse the repository at this point in the history
  • Loading branch information
xichen2020 committed Apr 13, 2018
1 parent 3ef5d19 commit a4f3907
Show file tree
Hide file tree
Showing 21 changed files with 443 additions and 444 deletions.
12 changes: 6 additions & 6 deletions matcher/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/m3db/m3cluster/kv"
"github.com/m3db/m3cluster/kv/mem"
"github.com/m3db/m3cluster/kv/util/runtime"
schema "github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/matcher/cache"
"github.com/m3db/m3metrics/rules"
"github.com/m3db/m3x/clock"
Expand Down Expand Up @@ -114,12 +114,12 @@ func testMatcher(t *testing.T, cache cache.Cache) Matcher {
SetRuleSetKeyFn(defaultRuleSetKeyFn).
SetRuleSetOptions(rules.NewOptions()).
SetMatchRangePast(0)
proto = &schema.Namespaces{
Namespaces: []*schema.Namespace{
&schema.Namespace{
proto = &rulepb.Namespaces{
Namespaces: []*rulepb.Namespace{
&rulepb.Namespace{
Name: "fooNs",
Snapshots: []*schema.NamespaceSnapshot{
&schema.NamespaceSnapshot{
Snapshots: []*rulepb.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 1,
Tombstoned: true,
},
Expand Down
6 changes: 3 additions & 3 deletions matcher/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/m3db/m3cluster/kv"
"github.com/m3db/m3cluster/kv/util/runtime"
"github.com/m3db/m3metrics/aggregation"
schema "github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/metric"
"github.com/m3db/m3metrics/rules"
"github.com/m3db/m3x/clock"
Expand Down Expand Up @@ -103,7 +103,7 @@ type namespaces struct {
onNamespaceAddedFn OnNamespaceAddedFn
onNamespaceRemovedFn OnNamespaceRemovedFn

proto *schema.Namespaces
proto *rulepb.Namespaces
rules map[xid.Hash]RuleSet
metrics namespacesMetrics
}
Expand All @@ -121,7 +121,7 @@ func NewNamespaces(key string, opts Options) Namespaces {
matchRangePast: opts.MatchRangePast(),
onNamespaceAddedFn: opts.OnNamespaceAddedFn(),
onNamespaceRemovedFn: opts.OnNamespaceRemovedFn(),
proto: &schema.Namespaces{},
proto: &rulepb.Namespaces{},
rules: make(map[xid.Hash]RuleSet),
metrics: newNamespacesMetrics(instrumentOpts.MetricsScope()),
}
Expand Down
58 changes: 29 additions & 29 deletions matcher/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

"github.com/m3db/m3cluster/kv"
"github.com/m3db/m3cluster/kv/mem"
schema "github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/matcher/cache"
"github.com/m3db/m3metrics/rules"
xid "github.com/m3db/m3x/ident"
Expand All @@ -45,12 +45,12 @@ const (

func TestNamespacesWatchAndClose(t *testing.T) {
store, _, nss, _ := testNamespaces()
proto := &schema.Namespaces{
Namespaces: []*schema.Namespace{
&schema.Namespace{
proto := &rulepb.Namespaces{
Namespaces: []*rulepb.Namespace{
&rulepb.Namespace{
Name: "fooNs",
Snapshots: []*schema.NamespaceSnapshot{
&schema.NamespaceSnapshot{
Snapshots: []*rulepb.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 1,
Tombstoned: true,
},
Expand Down Expand Up @@ -79,12 +79,12 @@ func TestToNamespacesUnmarshalError(t *testing.T) {

func TestToNamespacesSuccess(t *testing.T) {
store, _, nss, _ := testNamespaces()
proto := &schema.Namespaces{
Namespaces: []*schema.Namespace{
&schema.Namespace{
proto := &rulepb.Namespaces{
Namespaces: []*rulepb.Namespace{
&rulepb.Namespace{
Name: "fooNs",
Snapshots: []*schema.NamespaceSnapshot{
&schema.NamespaceSnapshot{
Snapshots: []*rulepb.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 1,
Tombstoned: true,
},
Expand Down Expand Up @@ -127,57 +127,57 @@ func TestNamespacesProcess(t *testing.T) {
c.namespaces[string(input.namespace)] = memResults{source: rs}
}

update := &schema.Namespaces{
Namespaces: []*schema.Namespace{
&schema.Namespace{
update := &rulepb.Namespaces{
Namespaces: []*rulepb.Namespace{
&rulepb.Namespace{
Name: "fooNs",
Snapshots: []*schema.NamespaceSnapshot{
&schema.NamespaceSnapshot{
Snapshots: []*rulepb.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 1,
Tombstoned: false,
},
&schema.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 2,
Tombstoned: false,
},
},
},
&schema.Namespace{
&rulepb.Namespace{
Name: "barNs",
Snapshots: []*schema.NamespaceSnapshot{
&schema.NamespaceSnapshot{
Snapshots: []*rulepb.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 1,
Tombstoned: false,
},
&schema.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 2,
Tombstoned: true,
},
},
},
&schema.Namespace{
&rulepb.Namespace{
Name: "bazNs",
Snapshots: []*schema.NamespaceSnapshot{
&schema.NamespaceSnapshot{
Snapshots: []*rulepb.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 1,
Tombstoned: false,
},
&schema.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 2,
Tombstoned: false,
},
},
},
&schema.Namespace{
&rulepb.Namespace{
Name: "catNs",
Snapshots: []*schema.NamespaceSnapshot{
&schema.NamespaceSnapshot{
Snapshots: []*rulepb.NamespaceSnapshot{
&rulepb.NamespaceSnapshot{
ForRulesetVersion: 3,
Tombstoned: true,
},
},
},
&schema.Namespace{
&rulepb.Namespace{
Name: "mehNs",
Snapshots: nil,
},
Expand Down
6 changes: 3 additions & 3 deletions matcher/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/m3db/m3cluster/kv"
"github.com/m3db/m3cluster/kv/util/runtime"
"github.com/m3db/m3metrics/aggregation"
schema "github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/metric"
"github.com/m3db/m3metrics/rules"
"github.com/m3db/m3x/clock"
Expand Down Expand Up @@ -83,7 +83,7 @@ type ruleSet struct {
ruleSetOpts rules.Options
onRuleSetUpdatedFn OnRuleSetUpdatedFn

proto *schema.RuleSet
proto *rulepb.RuleSet
version int
cutoverNanos int64
tombstoned bool
Expand All @@ -106,7 +106,7 @@ func newRuleSet(
matchRangePast: opts.MatchRangePast(),
ruleSetOpts: opts.RuleSetOptions(),
onRuleSetUpdatedFn: opts.OnRuleSetUpdatedFn(),
proto: &schema.RuleSet{},
proto: &rulepb.RuleSet{},
version: kv.UninitializedVersion,
metrics: newRuleSetMetrics(instrumentOpts.MetricsScope(), instrumentOpts.MetricsSamplingRate()),
}
Expand Down
4 changes: 2 additions & 2 deletions matcher/ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/m3db/m3cluster/kv"
"github.com/m3db/m3cluster/kv/mem"
"github.com/m3db/m3metrics/aggregation"
schema "github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/generated/proto/rulepb"
"github.com/m3db/m3metrics/matcher/cache"
"github.com/m3db/m3metrics/metric"
"github.com/m3db/m3metrics/rules"
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestToRuleSetUnmarshalError(t *testing.T) {

func TestToRuleSetSuccess(t *testing.T) {
store, _, rs := testRuleSet()
proto := &schema.RuleSet{
proto := &rulepb.RuleSet{
Namespace: string(testNamespace),
Tombstoned: false,
CutoverNanos: 123456,
Expand Down
12 changes: 6 additions & 6 deletions policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"

"github.com/m3db/m3metrics/aggregation"
schema "github.com/m3db/m3metrics/generated/proto/policypb"
"github.com/m3db/m3metrics/generated/proto/policypb"
)

const (
Expand All @@ -53,7 +53,7 @@ func NewPolicy(sp StoragePolicy, aggID aggregation.ID) Policy {
}

// NewPolicyFromSchema creates a new policy from a schema policy.
func NewPolicyFromSchema(p *schema.Policy) (Policy, error) {
func NewPolicyFromSchema(p *policypb.Policy) (Policy, error) {
if p == nil {
return DefaultPolicy, errNilPolicySchema
}
Expand All @@ -73,8 +73,8 @@ func NewPolicyFromSchema(p *schema.Policy) (Policy, error) {
}

// Schema returns the schema of the policy.
func (p Policy) Schema() (*schema.Policy, error) {
var storagePolicyProto schema.StoragePolicy
func (p Policy) Schema() (*policypb.Policy, error) {
var storagePolicyProto policypb.StoragePolicy
err := p.StoragePolicy.ToProto(&storagePolicyProto)
if err != nil {
return nil, err
Expand All @@ -90,7 +90,7 @@ func (p Policy) Schema() (*schema.Policy, error) {
return nil, err
}

return &schema.Policy{
return &policypb.Policy{
StoragePolicy: &storagePolicyProto,
AggregationTypes: schemaAggTypes,
}, nil
Expand Down Expand Up @@ -170,7 +170,7 @@ func ParsePolicy(str string) (Policy, error) {
}

// NewPoliciesFromSchema creates multiple new policies from given schema policies.
func NewPoliciesFromSchema(policies []*schema.Policy) ([]Policy, error) {
func NewPoliciesFromSchema(policies []*policypb.Policy) ([]Policy, error) {
res := make([]Policy, 0, len(policies))
for _, p := range policies {
policy, err := NewPolicyFromSchema(p)
Expand Down
6 changes: 3 additions & 3 deletions policy/resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"
"time"

schema "github.com/m3db/m3metrics/generated/proto/policypb"
"github.com/m3db/m3metrics/generated/proto/policypb"
xtime "github.com/m3db/m3x/time"
)

Expand All @@ -49,7 +49,7 @@ type Resolution struct {
}

// ToProto converts the resolution to a protobuf message in place.
func (r Resolution) ToProto(pb *schema.Resolution) error {
func (r Resolution) ToProto(pb *policypb.Resolution) error {
precision, err := r.Precision.Value()
if err != nil {
return err
Expand All @@ -60,7 +60,7 @@ func (r Resolution) ToProto(pb *schema.Resolution) error {
}

// FromProto converts the protobuf message to a resolution in place.
func (r *Resolution) FromProto(pb *schema.Resolution) error {
func (r *Resolution) FromProto(pb *policypb.Resolution) error {
if pb == nil {
return errNilResolutionProto
}
Expand Down
6 changes: 3 additions & 3 deletions policy/retention.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"fmt"
"time"

schema "github.com/m3db/m3metrics/generated/proto/policypb"
"github.com/m3db/m3metrics/generated/proto/policypb"
xtime "github.com/m3db/m3x/time"
)

Expand All @@ -47,12 +47,12 @@ func (r Retention) Duration() time.Duration {
}

// ToProto converts the retention to a protobuf message in place.
func (r Retention) ToProto(pb *schema.Retention) {
func (r Retention) ToProto(pb *policypb.Retention) {
pb.Period = r.Duration().Nanoseconds()
}

// FromProto converts the protobuf message to a retention in place.
func (r *Retention) FromProto(pb *schema.Retention) error {
func (r *Retention) FromProto(pb *policypb.Retention) error {
if pb == nil {
return errNilRetentionProto
}
Expand Down
12 changes: 6 additions & 6 deletions policy/storage_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"
"time"

schema "github.com/m3db/m3metrics/generated/proto/policypb"
"github.com/m3db/m3metrics/generated/proto/policypb"
xtime "github.com/m3db/m3x/time"
)

Expand Down Expand Up @@ -61,7 +61,7 @@ func NewStoragePolicy(window time.Duration, precision xtime.Unit, retention time
}

// NewStoragePolicyFromProto creates a new storage policy from a storage policy protobuf message.
func NewStoragePolicyFromProto(p *schema.StoragePolicy) (StoragePolicy, error) {
func NewStoragePolicyFromProto(p *policypb.StoragePolicy) (StoragePolicy, error) {
if p == nil {
return EmptyStoragePolicy, errNilStoragePolicySchema
}
Expand Down Expand Up @@ -90,22 +90,22 @@ func (p StoragePolicy) Retention() Retention {
}

// ToProto converts the storage policy to a protobuf message in place.
func (p StoragePolicy) ToProto(pb *schema.StoragePolicy) error {
func (p StoragePolicy) ToProto(pb *policypb.StoragePolicy) error {
if pb.Resolution == nil {
pb.Resolution = &schema.Resolution{}
pb.Resolution = &policypb.Resolution{}
}
if err := p.resolution.ToProto(pb.Resolution); err != nil {
return err
}
if pb.Retention == nil {
pb.Retention = &schema.Retention{}
pb.Retention = &policypb.Retention{}
}
p.retention.ToProto(pb.Retention)
return nil
}

// FromProto converts the protobuf message to a storage policy in place.
func (p *StoragePolicy) FromProto(pb schema.StoragePolicy) error {
func (p *StoragePolicy) FromProto(pb policypb.StoragePolicy) error {
if err := p.resolution.FromProto(pb.Resolution); err != nil {
return err
}
Expand Down

0 comments on commit a4f3907

Please sign in to comment.