{"action":"created","issue":{"url":"https://api.github.com/repos/spicavigo/kafka-rust/issues/34","labels_url":"https://api.github.com/repos/spicavigo/kafka-rust/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/spicavigo/kafka-rust/issues/34/comments","events_url":"https://api.github.com/repos/spicavigo/kafka-rust/issues/34/events","html_url":"https://github.com/spicavigo/kafka-rust/pull/34","id":114495991,"number":34,"title":"Allocation friendly fetch-offset-api","user":{"login":"xitep","id":8274125,"avatar_url":"https://avatars.githubusercontent.com/u/8274125?v=3","gravatar_id":"","url":"https://api.github.com/users/xitep","html_url":"https://github.com/xitep","followers_url":"https://api.github.com/users/xitep/followers","following_url":"https://api.github.com/users/xitep/following{/other_user}","gists_url":"https://api.github.com/users/xitep/gists{/gist_id}","starred_url":"https://api.github.com/users/xitep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitep/subscriptions","organizations_url":"https://api.github.com/users/xitep/orgs","repos_url":"https://api.github.com/users/xitep/repos","events_url":"https://api.github.com/users/xitep/events{/privacy}","received_events_url":"https://api.github.com/users/xitep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-01T22:03:12Z","updated_at":"2015-11-03T01:58:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/spicavigo/kafka-rust/pulls/34","html_url":"https://github.com/spicavigo/kafka-rust/pull/34","diff_url":"https://github.com/spicavigo/kafka-rust/pull/34.diff","patch_url":"https://github.com/spicavigo/kafka-rust/pull/34.patch"},"body":"This changeset builds up on #32. This time, it's a public API change though. It ...\r\n\r\n* ... avoids magic constants (inherited from kafka) by introducing an explicit enum.\r\n* ... proposes an API to `KafkaClient::fetch_offsets` and `KafkaClient::fetch_topic_offset` such that clients are not forced to re-allocated the specified topics over and over again (if the concept is fine, we can apply it to the rest of `KafkaClient`.)\r\n* ... makes the two mentioned methods return the error if kafka delivers one for the fetched offsets (here `PartitionOffset#offset` changes to a `Result<i64>` to force clients to evaluate the error if any; also here I'd favor if we applied this to the rest of `KafkaClient`.)\r\n* ... during the execution of the two mentioned methods topic names are not cloned needlessly anymore.\r\n\r\nHowever, there's still one annonying fact: The following will produce an error:\r\n\r\n```\r\n    let topics: Vec<&String> = client.topic_partitions.keys()/*.cloned()*/.collect();\r\n    let offs = try!(client.fetch_offsets(&topics, FetchOffset::Latest));\r\n\r\n... compiler goes mad:\r\n\r\n    main.rs:131:21: 131:27 error: cannot borrow `client` as mutable because `client.topic_partitions` is also borrowed as immutable [E0502]\r\n    main.rs:131     let offs = try!(client.fetch_offsets(&topics, FetchOffset::Latest));\r\n                                    ^~~~~~\r\n    ...\r\n```\r\n\r\nRight now, a `.clone()` is still necessary once in the program (to work around the borrowck). The final solution will very likely be to return the metadata from `load_metadata()` to clients and fully drop the public `KafkaClient#topic_partitions`. I would consider this step only after all of `KafkaClient`'s methods are reworked similarly to the proposed `fetch_offsets`.\r\n\r\n@spicavigo, I would really greatly appreciate if you could find some time and have a critical look on the proposed changes. I want to be more confident I'm going into the right direction before making further changes.\r\n"},"comment":{"url":"https://api.github.com/repos/spicavigo/kafka-rust/issues/comments/153216237","html_url":"https://github.com/spicavigo/kafka-rust/pull/34#issuecomment-153216237","issue_url":"https://api.github.com/repos/spicavigo/kafka-rust/issues/34","id":153216237,"user":{"login":"spicavigo","id":169825,"avatar_url":"https://avatars.githubusercontent.com/u/169825?v=3","gravatar_id":"","url":"https://api.github.com/users/spicavigo","html_url":"https://github.com/spicavigo","followers_url":"https://api.github.com/users/spicavigo/followers","following_url":"https://api.github.com/users/spicavigo/following{/other_user}","gists_url":"https://api.github.com/users/spicavigo/gists{/gist_id}","starred_url":"https://api.github.com/users/spicavigo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spicavigo/subscriptions","organizations_url":"https://api.github.com/users/spicavigo/orgs","repos_url":"https://api.github.com/users/spicavigo/repos","events_url":"https://api.github.com/users/spicavigo/events{/privacy}","received_events_url":"https://api.github.com/users/spicavigo/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T01:58:13Z","updated_at":"2015-11-03T01:58:13Z","body":"@xitep I am in the middle of a move from one city to another. Will look at it thoroughly in a day or two."}}