{"action":"created","issue":{"url":"https://api.github.com/repos/google/dagger/issues/409","repository_url":"https://api.github.com/repos/google/dagger","labels_url":"https://api.github.com/repos/google/dagger/issues/409/labels{/name}","comments_url":"https://api.github.com/repos/google/dagger/issues/409/comments","events_url":"https://api.github.com/repos/google/dagger/issues/409/events","html_url":"https://github.com/google/dagger/pull/409","id":166013869,"number":409,"title":"[Feature Proposal] Adding support for @Internal annotation.","user":{"login":"tonycosentini","id":23467,"avatar_url":"https://avatars.githubusercontent.com/u/23467?v=3","gravatar_id":"","url":"https://api.github.com/users/tonycosentini","html_url":"https://github.com/tonycosentini","followers_url":"https://api.github.com/users/tonycosentini/followers","following_url":"https://api.github.com/users/tonycosentini/following{/other_user}","gists_url":"https://api.github.com/users/tonycosentini/gists{/gist_id}","starred_url":"https://api.github.com/users/tonycosentini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonycosentini/subscriptions","organizations_url":"https://api.github.com/users/tonycosentini/orgs","repos_url":"https://api.github.com/users/tonycosentini/repos","events_url":"https://api.github.com/users/tonycosentini/events{/privacy}","received_events_url":"https://api.github.com/users/tonycosentini/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/dagger/labels/cla:%20yes","name":"cla: yes","color":"bfe5bf"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-18T03:32:48Z","updated_at":"2016-07-18T18:01:53Z","closed_at":"2016-07-18T18:01:53Z","pull_request":{"url":"https://api.github.com/repos/google/dagger/pulls/409","html_url":"https://github.com/google/dagger/pull/409","diff_url":"https://github.com/google/dagger/pull/409.diff","patch_url":"https://github.com/google/dagger/pull/409.patch"},"body":"This PR adds a new `@Internal` annotation that will prevent `@Provides` methods that are marked with `@Internal` from being exposed via component getters.\r\n\r\n#### Why This Might Be Useful\r\nOften times there are provides methods in a module to build other types of objects, but these are things you don’t want to provide in the public component API. \r\n\r\nFor example - say you have an OkHttpClient, a GSON instance, and a higher level abstraction around the two that you want everyone in the application to use. You can mark the OkHttpClient and GSON providers with `@Internal `to ensure they never accidentally end up in the component public API.\r\n\r\nThis might seem like a weird thing to guard against, but in a larger codebase with many developers - it’s very easy to expose something that’s not meant to be exposed on a component.\r\n\r\nIn addition, it’s also possible if you have child scopes define a parent dependency interface (which lists all of the dependencies they need from a parent scope). This is very convenient (since Dagger can implicitly implement the interface), but can also lead to things being exposed on that component that shouldn’t be.\r\n\r\n(Alternatively, this can be solved by just not providing these internal dependencies via `@Provides` and instead keeping them as fields in the module. However, this tends to lead to larger modules.)\r\n\r\n#### Open Questions\r\n* Is this something that makes sense to do?\r\n* Should this also happen with `inject` methods?  (So having an `@Inject` field for a type that is internal fails the build.)\r\n* I created a new annotation for this, but would it make more sense to add this to @Provides (it would have to be a new field I think - it’s not really appropriate for the existing `Type` enum)? \r\n* Is the validation happening in the right place?\r\n* What element should the error point to? The component or the provider?\r\n\r\n#### TODO (if this is something that would be useful)\r\n* [ ] Documentation\r\n* [ ] Update relevant tests\r\n* [ ] Add support with `@Producer`?\r\n\r\nSorry for leaving this in an unfinished state - I wanted to gauge if it seems like it’s worth having. If so, I’ll follow up with the todos.\r\n"},"comment":{"url":"https://api.github.com/repos/google/dagger/issues/comments/233408037","html_url":"https://github.com/google/dagger/pull/409#issuecomment-233408037","issue_url":"https://api.github.com/repos/google/dagger/issues/409","id":233408037,"user":{"login":"tonycosentini","id":23467,"avatar_url":"https://avatars.githubusercontent.com/u/23467?v=3","gravatar_id":"","url":"https://api.github.com/users/tonycosentini","html_url":"https://github.com/tonycosentini","followers_url":"https://api.github.com/users/tonycosentini/followers","following_url":"https://api.github.com/users/tonycosentini/following{/other_user}","gists_url":"https://api.github.com/users/tonycosentini/gists{/gist_id}","starred_url":"https://api.github.com/users/tonycosentini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonycosentini/subscriptions","organizations_url":"https://api.github.com/users/tonycosentini/orgs","repos_url":"https://api.github.com/users/tonycosentini/repos","events_url":"https://api.github.com/users/tonycosentini/events{/privacy}","received_events_url":"https://api.github.com/users/tonycosentini/received_events","type":"User","site_admin":false},"created_at":"2016-07-18T18:01:53Z","updated_at":"2016-07-18T18:01:53Z","body":"Turns out this is way easier with package-private qualifiers:\r\n\r\n```java\r\n@Provides @Singleton @Private Relay<Integer> provideIntRelay() {\r\n  return PublishRelay.create();\r\n}\r\n\r\n@Qualifier\r\nprivate @interface Private {}\r\n\r\n@Provides @Singleton Observable<Integer> provideIntObv(@Private Relay<Integer> relay) {\r\n  return relay.asObservable();\r\n}\r\n\r\n@Provides @Singleton Action1<Integer> provideIntAction(@Private Relay<Integer> relay) {\r\n  return relay.asAction();\r\n}\r\n```"}}
{"actor":{"display_login":"tonycosentini"}}