{"action":"created","issue":{"url":"https://api.github.com/repos/grpc/grpc/issues/14871","repository_url":"https://api.github.com/repos/grpc/grpc","labels_url":"https://api.github.com/repos/grpc/grpc/issues/14871/labels{/name}","comments_url":"https://api.github.com/repos/grpc/grpc/issues/14871/comments","events_url":"https://api.github.com/repos/grpc/grpc/issues/14871/events","html_url":"https://github.com/grpc/grpc/issues/14871","id":309902631,"number":14871,"title":"grpc-objc: Add protocol for generated service classes so they can be instantiated generically","user":{"login":"dcow","id":547926,"avatar_url":"https://avatars2.githubusercontent.com/u/547926?v=4","gravatar_id":"","url":"https://api.github.com/users/dcow","html_url":"https://github.com/dcow","followers_url":"https://api.github.com/users/dcow/followers","following_url":"https://api.github.com/users/dcow/following{/other_user}","gists_url":"https://api.github.com/users/dcow/gists{/gist_id}","starred_url":"https://api.github.com/users/dcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcow/subscriptions","organizations_url":"https://api.github.com/users/dcow/orgs","repos_url":"https://api.github.com/users/dcow/repos","events_url":"https://api.github.com/users/dcow/events{/privacy}","received_events_url":"https://api.github.com/users/dcow/received_events","type":"User","site_admin":false},"labels":[{"id":171080795,"url":"https://api.github.com/repos/grpc/grpc/labels/lang/ObjC","name":"lang/ObjC","color":"fad8c7","default":false}],"state":"open","locked":false,"assignee":{"login":"muxi","id":1054404,"avatar_url":"https://avatars1.githubusercontent.com/u/1054404?v=4","gravatar_id":"","url":"https://api.github.com/users/muxi","html_url":"https://github.com/muxi","followers_url":"https://api.github.com/users/muxi/followers","following_url":"https://api.github.com/users/muxi/following{/other_user}","gists_url":"https://api.github.com/users/muxi/gists{/gist_id}","starred_url":"https://api.github.com/users/muxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muxi/subscriptions","organizations_url":"https://api.github.com/users/muxi/orgs","repos_url":"https://api.github.com/users/muxi/repos","events_url":"https://api.github.com/users/muxi/events{/privacy}","received_events_url":"https://api.github.com/users/muxi/received_events","type":"User","site_admin":false},"assignees":[{"login":"muxi","id":1054404,"avatar_url":"https://avatars1.githubusercontent.com/u/1054404?v=4","gravatar_id":"","url":"https://api.github.com/users/muxi","html_url":"https://github.com/muxi","followers_url":"https://api.github.com/users/muxi/followers","following_url":"https://api.github.com/users/muxi/following{/other_user}","gists_url":"https://api.github.com/users/muxi/gists{/gist_id}","starred_url":"https://api.github.com/users/muxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muxi/subscriptions","organizations_url":"https://api.github.com/users/muxi/orgs","repos_url":"https://api.github.com/users/muxi/repos","events_url":"https://api.github.com/users/muxi/events{/privacy}","received_events_url":"https://api.github.com/users/muxi/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2018-03-29T21:01:55Z","updated_at":"2018-04-06T00:55:49Z","closed_at":null,"author_association":"NONE","body":"In Swift you can instantiate generic types if they conform to a protocol describing their constructor interface. As far as I can tell, all generated services have the same constructors. For example:\r\n\r\n```\r\nfunc grpcServiceFactory<S: GRPCProtobufService>(address: String) -> S\r\n{\r\n    let service = S(host: address) // possible if GRPCProtobufService describes a protocol for init\r\n    // configure service e.g. GrpcCall.setTlsParameters(..., ..., ..., address)\r\n    return service\r\n}\r\n```\r\n\r\nThe call site looks like:\r\n\r\n```\r\nlet service = grpcServiceFactory<HelloWorld>(address: \"my.host:port\")\r\n```\r\n\r\nWithout this, call sites that need to configure services look like:\r\n\r\n```\r\nlet service = HelloWorld(host: \"my.host:port\")\r\nGrpcUtil.configureService(service)\r\n// ...\r\n```\r\n\r\nThe former is definitely nicer. Thoughts?\r\n"},"comment":{"url":"https://api.github.com/repos/grpc/grpc/issues/comments/379118755","html_url":"https://github.com/grpc/grpc/issues/14871#issuecomment-379118755","issue_url":"https://api.github.com/repos/grpc/grpc/issues/14871","id":379118755,"user":{"login":"muxi","id":1054404,"avatar_url":"https://avatars1.githubusercontent.com/u/1054404?v=4","gravatar_id":"","url":"https://api.github.com/users/muxi","html_url":"https://github.com/muxi","followers_url":"https://api.github.com/users/muxi/followers","following_url":"https://api.github.com/users/muxi/following{/other_user}","gists_url":"https://api.github.com/users/muxi/gists{/gist_id}","starred_url":"https://api.github.com/users/muxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muxi/subscriptions","organizations_url":"https://api.github.com/users/muxi/orgs","repos_url":"https://api.github.com/users/muxi/repos","events_url":"https://api.github.com/users/muxi/events{/privacy}","received_events_url":"https://api.github.com/users/muxi/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T00:55:49Z","updated_at":"2018-04-06T00:55:49Z","author_association":"CONTRIBUTOR","body":"OK anyway. Feel free to make a PR any time (@ me if you do). Otherwise I'll find some time for this, likely some day next week."}}
{"actor":{"display_login":"muxi"}}