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

Adding handler functions and tests #65

Merged
merged 3 commits into from
Jun 28, 2017
Merged

Adding handler functions and tests #65

merged 3 commits into from
Jun 28, 2017

Conversation

dgromov
Copy link
Contributor

@dgromov dgromov commented Jun 26, 2017

No description provided.

@dgromov dgromov requested a review from xichen2020 June 26, 2017 22:18
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 87.828% when pulling d2c024c on common_kv_functions into 833a34a on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 88.941% when pulling b7768b2 on common_kv_functions into 833a34a on master.

return 0, nil, err
}
version := value.Version()
services := &schema.Namespaces{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename services to namespaces since this is in OSS world and namespace is more generic than service.

Also, more idiomatic to write

var namespaces schema.Namespaces
if err := value.Unmarshal(&namespaces); err != nil {
  ...
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump

return namespacesVersion, namespaces, ns, nil
}

// Namespace returns the service with a given name, or an error if there are
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns the namespace with a given name

return nil, errMultipleMatches
}
}
return namespace, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps better to return errNotFound if the namespace is nil here?

if ns == nil {
return 0, nil, nil, fmt.Errorf("namespace %s doesn't exist", namespaceName)
}
if ns.Snapshots[len(ns.Snapshots)-1].Tombstoned {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be safer to check if len(ns.Snapshots) is nonzero and return an error if so.

rollupRule *schema.RollupRule
)
for _, mr := range ruleSet.MappingRules {
latestSnapshot := mr.Snapshots[len(mr.Snapshots)-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check len(mr.Snapshots) is nonzero first?

if mappingRule != nil && rollupRule != nil {
return nil, nil, errMultipleMatches
}
return mappingRule, rollupRule, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return errNotFound if both are nil?

return 0, nil, err
}
version := value.Version()
ruleSet := &schema.RuleSet{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: more idiomatic to write var ruleSet schema.RuleSet

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 88.908% when pulling aa02b97 on common_kv_functions into 833a34a on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 88.908% when pulling 5f21d09 on common_kv_functions into 833a34a on master.

Copy link
Contributor

@xichen2020 xichen2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dgromov dgromov merged commit 6cabb14 into master Jun 28, 2017
@dgromov dgromov deleted the common_kv_functions branch July 1, 2017 19:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants