Vladimir, Slava, In general, I like the idea of abstracting the service deployment from its usage, but there are some backward-compatibility considerations that won't let us do so.
Or we can declare usage of services without interfaces incorrect I don't think we can introduce a requirement for all services to have an interface, unfortunately. Such change can potentially break existing code, since such requirement doesn't exist currently. Moreover, I don't see a way of implementing such a check. Are you going to look just for any interface? What about Serializable? Will it do? Usage of a proxy instead of service instances can lead to performance degradation for local instances, which is another argument against such change. I think, it will make sense to make all service invocations work through a proxy in Ignite 3. For now though the best thing we can do is to calculate remote invocations only, since all of them go through a proxy. Another option is to provide a simple way for a user to account the service invocations themselves. What do you guys think? Denis вт, 25 февр. 2020 г. в 16:50, Vyacheslav Daradur <daradu...@gmail.com>: > It is not a change of public API from my point of view. > > Also, there is a check to allow getting proxy only for an interface, not > implementation. > > Denis, what do you think? > > > вт, 25 февр. 2020 г. в 16:28, Vladimir Steshin <vlads...@gmail.com>: > >> Vyacheslav, this is exactly what I found. I'm doing [1] (metrics for >> services) and realized I have to wrap local calls by a proxy. Is it a >> change of public API and should come with major release only? Or we can >> declare usage of services without interfaces incorrect? >> [1] https://issues.apache.org/jira/browse/IGNITE-12464 >> >> вт, 25 февр. 2020 г. в 16:17, Vyacheslav Daradur <daradu...@gmail.com>: >> >>> {IgniteServices#service(String name)} returns direct reference in the >>> current implementation. >>> >>> So, class casting should work for your example: >>> ((MyServiceImpl)ignite.services().service(“myService”)).bar(); >>> >>> It is safer to use an interface instead of an implementation, there is >>> no guarantee that in future releases direct link will be returned, a >>> service instance might be wrapped for monitoring for example. >>> >>> >>> On Tue, Feb 25, 2020 at 4:09 PM Vladimir Steshin <vlads...@gmail.com> >>> wrote: >>> >>>> Vyacheslav, Hi. >>>> >>>> I see. But can we consider 'locally deployed service' is a proxy too, >>>> not direct reference? What if I need to wrap it? This would be local >>>> service working via proxy or null. >>>> >>>> вт, 25 февр. 2020 г. в 16:03, Vyacheslav Daradur <daradu...@gmail.com>: >>>> >>>>> Hi, Vladimir >>>>> >>>>> The answer is in API docs: "Gets *locally deployed service* with >>>>> specified name." [1] >>>>> >>>>> That means {IgniteServices#service(String name)} returns only locally >>>>> deployed instance or null. >>>>> >>>>> {IgniteServices#serviceProxy(…)} returns proxy to call instances >>>>> across the cluster. Might be used for load-balancing. >>>>> >>>>> [1] >>>>> https://github.com/apache/ignite/blob/56975c266e7019f307bb9da42333a6db4e47365e/modules/core/src/main/java/org/apache/ignite/IgniteServices.java#L569 >>>>> >>>>> On Tue, Feb 25, 2020 at 3:51 PM Vladimir Steshin <vlads...@gmail.com> >>>>> wrote: >>>>> >>>>>> Hello, Igniters. >>>>>> >>>>>> Previous e-mail was with wrong topic 'daradu...@gmail.com' :) >>>>>> >>>>>> I got a question what exactly IgniteServices#service(String name) is >>>>>> supposed to return: reference to the object or a proxy for some reason >>>>>> like >>>>>> IgniteServices#serviceProxy(…)? Vyacheslav D., can you tell me your >>>>>> opinion? >>>>>> >>>>>> public interface MyService { >>>>>> >>>>>> public void foo(); >>>>>> >>>>>> } >>>>>> >>>>>> public class MyServiceImpl implements Service, MyService { >>>>>> >>>>>> @Override public void foo(){ … } >>>>>> >>>>>> public void bar(){ … }; >>>>>> >>>>>> } >>>>>> >>>>>> >>>>>> // Is it required to support >>>>>> >>>>>> MyServiceImpl srvc = ignite.services().service(“myService”); >>>>>> >>>>>> srvc.foo(); >>>>>> >>>>>> srvc.bar(); >>>>>> >>>>>> >>>>>> >>>>>> // Or is the only correct way: >>>>>> >>>>>> MyService srvc = ignite.services().service(“myService”); >>>>>> >>>>>> srvc.foo(); >>>>>> >>>>>> >>>>> >>>>> -- >>>>> Best Regards, Vyacheslav D. >>>>> >>>> >>> >>> -- >>> Best Regards, Vyacheslav D. >>> >> -- > Best Regards, Vyacheslav D. >