Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching Statistics from memcached server #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xni
Copy link

@xni xni commented Sep 27, 2015

Hi!

I am very new to Go programming language, but I'd like to implement Statistics (https://cloud.google.com/appengine/docs/go/memcache/reference?csw=1#Statistics) in gomemcache library.

Could you please, take a look on my patch? I will be pleased to fix any problems in it you find.

Thank you in advance.

This is how I use it

func main() {
     ss := new(memcache.ServerList)
     ss.SetServers("127.0.0.1:11211")
     mc := memcache.NewFromSelector(ss)

     srv, _ := ss.PickServer("111")
     stats, err := mc.Stats(srv)
     if err == nil {
         fmt.Println(stats)
     }
}

@xni xni force-pushed the master branch 5 times, most recently from 19603e4 to d2245ca Compare September 27, 2015 22:55
@faabiosr
Copy link

Any news about this PR? When the merge will be made?


func parseStatsLine(s []byte, expectedPrefix []byte) (uint64, error) {
if !bytes.HasPrefix(s, expectedPrefix) {
return 0, errors.New("line does not start with exceptedPrefix")
Copy link
Owner

Choose a reason for hiding this comment

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

errors.New allocates each time. I'd make that a global err variable instead.

@@ -171,6 +177,24 @@ type conn struct {
c *Client
}

// Statistics is a record of memcached usage stats.
type Statistics struct {
// Counter of cache hits.
Copy link
Owner

Choose a reason for hiding this comment

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

Write complete sentences.

See https://github.com/golang/go/wiki/CodeReviewComments#comment-sentences

// Hits is ...

(ending in a period)

}


func (c *Client) Stats(addr net.Addr) (*Statistics, error) {
Copy link
Owner

Choose a reason for hiding this comment

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

This lacks comments.

Also, why does it take an Addr? It seems like most people would want aggregated statistics across all nodes for a method named "Stats".

Maybe this should be called "NodeStats".

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@xni
Copy link
Author

xni commented Feb 19, 2017

@bradfitz , thanks for your comments, it was very useful. Could you please take a look at my changes again.

@xni
Copy link
Author

xni commented Feb 19, 2017

Hi! My commit has a committer email '[email protected]', and I was told that Yandex LLC has a CLA agreement (mostly contributing to the Chromium repository). Could you please check, why I did not pass the CLA check. Thanks!

@bradfitz bradfitz removed the cla: no label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants