<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div></div></div><div><blockquote type="cite" class=""><div class="">On 10 Mar 2017, at 15:09, Dougal Matthews <<a href="mailto:dougal@redhat.com" class="">dougal@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On 10 March 2017 at 04:22, Renat Akhmerov <span dir="ltr" class=""><<a href="mailto:renat.akhmerov@gmail.com" target="_blank" class="">renat.akhmerov@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">I probably like the base class approach better too.</div><div class=""><br class=""></div><div class="">However, I’m trying to understand if we need this variety of classes.</div><div class=""><ul class="m_4542071899119995468MailOutline"><li class="">Do we need a separate class for asynchronous actions? IMO, since is_sync() is just an instance method that can potentially return both True and False based on the instance state shouldn’t be introduced by a special class. Otherwise it’s confusing that a classes declared as AsyncAction can actually be synchronous (if its is_sync() returns True). So maybe we should just leave this method in the base class.</li><li class="">I”m also wondering if we should just always pass “context” into run() method. Those action implementations that don’t need it could just ignore it. Not sure though.</li></ul></div></div></blockquote><div class="">This is a good point. I had originally thought it would be backwards incompatible to make this change - however, users will need to update their actions to inherit from mistral-lib so they will need to opt in. Then in mistral we can do something like...<br class=""><br class=""></div><div class="">if isinstance(action, mistral_lib.Action):<br class=""></div><div class="">    action.run(ctx)<br class=""></div><div class="">else:<br class=""></div><div class="">    # deprecation warning about action now inheriting from mistral_lib and taking a context etc.<br class=""></div><div class="">    action.run()<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""></div></blockquote></div></div></div></div></blockquote><div><br class=""></div><div>Yes, right.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">As far as mixin approach, I’d say I’d be ok with having mixing for context-based actions. Although, like Dougal said, it may be a little harder to read, this approach gives a huge flexibility for long term. Imagine if we want to have a class of actions that some different kind of information. Just making it up… For example, some of my actions need to be aware of some policies (Congress-like) or information about metrics of the current operating system (this is probably a bad example because it’s easy to use standard Python modules but I’m just trying to illustrate the idea). In this case we could have PolicyMixin and OperatingSystemMixin that would set required info into the instance state or provide with handle interfaces for more advanced uses.</div></div></blockquote><div class=""><br class=""></div><div class="">I like the idea of mixins if we can see a future with many small components that can be included in an action class. However, like you I didn't manage to think of any real examples.<br class=""><br class=""></div><div class="">It should be possible to migrate to a mixin approach later if we have the need.<br class=""></div></div></div></div></div></blockquote></div><div class=""><br class=""></div>Well, I didn’t manage to find real use cases probably because I don’t develop lots of actions :) Although the example with policies seems almost real to me. This is something that was raised several times during design sessions in the past. Anyway, I agree with you that seems like we can add mixins later if we want to. I don’t see any reasons now why not.<div class=""><br class=""><div class=""><br class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Renat Akhmerov</div><div class="">@Nokia</div><div class=""><br class=""></div></div></div></div><div class=""><br class=""></div></div></div></body></html>