{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/orleans/issues/626","labels_url":"https://api.github.com/repos/dotnet/orleans/issues/626/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/orleans/issues/626/comments","events_url":"https://api.github.com/repos/dotnet/orleans/issues/626/events","html_url":"https://github.com/dotnet/orleans/issues/626","id":96109820,"number":626,"title":"Common way to obtain grain factory","user":{"login":"yevhen","id":107726,"avatar_url":"https://avatars.githubusercontent.com/u/107726?v=3","gravatar_id":"","url":"https://api.github.com/users/yevhen","html_url":"https://github.com/yevhen","followers_url":"https://api.github.com/users/yevhen/followers","following_url":"https://api.github.com/users/yevhen/following{/other_user}","gists_url":"https://api.github.com/users/yevhen/gists{/gist_id}","starred_url":"https://api.github.com/users/yevhen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yevhen/subscriptions","organizations_url":"https://api.github.com/users/yevhen/orgs","repos_url":"https://api.github.com/users/yevhen/repos","events_url":"https://api.github.com/users/yevhen/events{/privacy}","received_events_url":"https://api.github.com/users/yevhen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/orleans/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2015-07-20T17:00:14Z","updated_at":"2015-07-30T18:16:38Z","closed_at":null,"body":"As of 1.0.9 `IGrainFactory` interface was introduced as way to obtain grain references in common way. Unfortunately, obtaining `IGrainFactory` itself is not uniform between client (outside-silo) and cluster (inside-silo) environments. That breaks code which deals with obtaining grain references in a generic way (think shared utils), since getting a reference to `IGrainFactory` inside silo is only possible from inside of a grain and that utility code in question, doesn't have any traces to a grain.\r\n\r\nPlease consider adding the following static property to `GrainFactory` class which will return default implementation of `IGrainFactory`:\r\n\r\n```cs\r\nGrainFactory.Current.GetGrain<IA>(id)\r\n```\r\nWhen invoked inside client environment it will use the `IGrainFactory` from `GrainClient`, and when invoked inside cluster it will return the reference to `IGrainFactory` singleton, which it returns via `Grain.GrainFactory` by default.\r\n\r\nNOTE: that doesn't require any changes to current design. Grains will still have a way to mock out `IGrainFactory` by mocking `IGrainRuntime`. The static `GrainFactory.Current` property will be readonly and not mockable (and it should not, by design). That should satisfy all use cases."},"comment":{"url":"https://api.github.com/repos/dotnet/orleans/issues/comments/126422922","html_url":"https://github.com/dotnet/orleans/issues/626#issuecomment-126422922","issue_url":"https://api.github.com/repos/dotnet/orleans/issues/626","id":126422922,"user":{"login":"sergeybykov","id":8248806,"avatar_url":"https://avatars.githubusercontent.com/u/8248806?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeybykov","html_url":"https://github.com/sergeybykov","followers_url":"https://api.github.com/users/sergeybykov/followers","following_url":"https://api.github.com/users/sergeybykov/following{/other_user}","gists_url":"https://api.github.com/users/sergeybykov/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeybykov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeybykov/subscriptions","organizations_url":"https://api.github.com/users/sergeybykov/orgs","repos_url":"https://api.github.com/users/sergeybykov/repos","events_url":"https://api.github.com/users/sergeybykov/events{/privacy}","received_events_url":"https://api.github.com/users/sergeybykov/received_events","type":"User","site_admin":false},"created_at":"2015-07-30T18:16:38Z","updated_at":"2015-07-30T18:16:38Z","body":"Cross-cluster communication is part of the geo-distribution project we are collaborating on this summer with MSR. We'll start putting out documentation and code in a few weeks as the PhD interns that have been working on the project approach the end of their internships. A lot of great stuff there."}}