{"action":"opened","issue":{"url":"https://api.github.com/repos/carlescere/goback/issues/1","labels_url":"https://api.github.com/repos/carlescere/goback/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/carlescere/goback/issues/1/comments","events_url":"https://api.github.com/repos/carlescere/goback/issues/1/events","html_url":"https://github.com/carlescere/goback/issues/1","id":63958923,"number":1,"title":"JitterBackoff does not implement Reset()","user":{"login":"oryband","id":115387,"avatar_url":"https://avatars.githubusercontent.com/u/115387?v=3","gravatar_id":"","url":"https://api.github.com/users/oryband","html_url":"https://github.com/oryband","followers_url":"https://api.github.com/users/oryband/followers","following_url":"https://api.github.com/users/oryband/following{/other_user}","gists_url":"https://api.github.com/users/oryband/gists{/gist_id}","starred_url":"https://api.github.com/users/oryband/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oryband/subscriptions","organizations_url":"https://api.github.com/users/oryband/orgs","repos_url":"https://api.github.com/users/oryband/repos","events_url":"https://api.github.com/users/oryband/events{/privacy}","received_events_url":"https://api.github.com/users/oryband/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-24T10:18:05Z","updated_at":"2015-03-24T10:18:05Z","closed_at":null,"body":"First of all, great project! It's a much simpler way of doing things compared to https://github.com/eapache/go-resiliency. :+1: \r\n\r\nI'm getting this compilation error when using `JitterBackoff`:\r\n```go\r\ncannot use b (type *goback.JitterBackoff) as type goback.Backoff in argument to goback.Wait: *goback.JitterBackoff does not implement goback.Backoff (missing Reset method)\r\n```\r\nThis is because you didn't subclass `JitterBackoff` from `SimpleBackoff` (i.e. embedded it inside), but just defined it as a type alias. However, this is not really an alias, and go considers this as a new type. Because of this, this does not make the original `Reset()` apply to `JitterBackoff` as well. Thus, go complains that no `Reset()` implementation exists for the new `JitterBackoff` type.\r\n\r\nSince the only difference I see between these two structs is a single line in `NextAttempt()` (the one that adds jitter), my best solution to this is to refactor your code a bit:\r\n\r\n1. Make a single `Backoff` type, no need for two simple and jitter types.\r\n2. Add to it an extra `jitter bool` member.\r\n3. Create a `NewSimpleBackoff()` and `NewJitterBackoff()` functions. Where `NewSimpleBackoff()` returns a new `Backoff` instance with `jitter` set to `false`. `NewJitterBackoff` would set it to `true`.\r\n4. Implement `NextAttempt()` only once, and check for `jitter`'s value to decide whether to add jitter or not.\r\n\r\nPros for this:\r\n1. Using `NewX()` init functions, which is a go idiom for creating instances, and is strict about the arguments it receives, being able to check for valid function arguments. Asking for the user to just init a new struct themselves (e.g. `b := &goback.JitterBackof{..}`) is dangerous. It took me 15 minutes just to scan your source and make sure I'm setting all values right, and understand that I shouldn't touch the *public* `Attempts` member.\r\n2. Cut back on lines of code, and a simple code structure - you only have a single type (`Backoff`) and not two (`Simple`, `Jitter`).\r\n3. You get to fix this bug I've originally opened this issue for. :)"}}