{"comment":{"url":"https://api.github.com/repos/nats-io/nats/comments/18681066","html_url":"https://github.com/nats-io/nats/commit/6c7481e082f04a3b4e234e696a2198838318320f#commitcomment-18681066","id":18681066,"user":{"login":"wallyqs","id":26195,"avatar_url":"https://avatars.githubusercontent.com/u/26195?v=3","gravatar_id":"","url":"https://api.github.com/users/wallyqs","html_url":"https://github.com/wallyqs","followers_url":"https://api.github.com/users/wallyqs/followers","following_url":"https://api.github.com/users/wallyqs/following{/other_user}","gists_url":"https://api.github.com/users/wallyqs/gists{/gist_id}","starred_url":"https://api.github.com/users/wallyqs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wallyqs/subscriptions","organizations_url":"https://api.github.com/users/wallyqs/orgs","repos_url":"https://api.github.com/users/wallyqs/repos","events_url":"https://api.github.com/users/wallyqs/events{/privacy}","received_events_url":"https://api.github.com/users/wallyqs/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":null,"commit_id":"6c7481e082f04a3b4e234e696a2198838318320f","created_at":"2016-08-17T21:54:08Z","updated_at":"2016-08-17T21:54:08Z","body":"Maybe to use smaller interfaces there could be something like the following in the `nats` package too...\r\n\r\n```go\r\n// Errors\r\ntype Error interface {\r\n\terror\r\n\tIsNatsTimeout() bool\r\n}\r\n\r\n// timeoutError implements net.Error interface and nats.Error interface\r\ntype timeoutError struct{}\r\n\r\nfunc (e *timeoutError) Error() string   { return \"nats: timeout\" }\r\nfunc (e *timeoutError) Timeout() bool   { return true }\r\nfunc (e *timeoutError) Temporary() bool { return true }\r\nfunc (e *timeoutError) NatsTimeout() bool { return true }\r\n```\r\n\r\nthat way as a library user, the recommended usage would be:\r\n\r\n```go\r\n\ttype timeoutError interface {\r\n\t\tError() string\r\n\t\tTemporary() bool\r\n\t\tTimeout() bool\r\n\t}\r\n\ttype natsError interface {\r\n\t        NatsTimeout() bool\r\n\t}\r\n\tresult, err := actor.Greet()\r\n\tif err != nil {\r\n\t\tif timeoutErr, ok := err.(timeoutError); ok && timeoutErr.Timeout() {\r\n\t\t\tfmt.Printf(\"No one replied back at this moment... retry later: %s\\n\", err)\r\n\t\t}\r\n\t\tif natsErr, ok := err.(natsError); ok && natsErr.NatsTimeout() {\r\n\t\t\tfmt.Printf(\"the timeout was from nats: %s\\n\", err)\r\n\t\t}\r\n```\r\nthat way the interfaces declarations as a library user would be kept small, just focusing in the behavior that we want to assert."}}
{"actor":{"display_login":"wallyqs"}}