<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 10 March 2017 at 04:22, Renat Akhmerov <span dir="ltr"><<a href="mailto:renat.akhmerov@gmail.com" target="_blank">renat.akhmerov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi,</div><div><br></div><div>I probably like the base class approach better too.</div><div><br></div><div>However, I’m trying to understand if we need this variety of classes.</div><div><ul class="m_4542071899119995468MailOutline"><li>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>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>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><br></div><div>if isinstance(action, mistral_lib.Action):<br></div><div> action.run(ctx)<br></div><div>else:<br></div><div> # deprecation warning about action now inheriting from mistral_lib and taking a context etc.<br></div><div> action.run()<br><br></div><div>So just having one class would really be the simplest approach.<br><br><br></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"><div>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><br></div><div>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><br></div><div>It should be possible to migrate to a mixin approach later if we have the need.<br><br><br></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"><div>What do you think?</div><span class="HOEnZb"><font color="#888888"><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div>Renat Akhmerov</div><div>@Nokia</div></div>
</div>
<br></font></span><div><blockquote type="cite"><div><div class="h5"><div>On 9 Mar 2017, at 11:35, Ryan Brady <<a href="mailto:rbrady@redhat.com" target="_blank">rbrady@redhat.com</a>> wrote:</div><br class="m_4542071899119995468Apple-interchange-newline"></div></div><div><div><div class="h5"><div dir="ltr">At the PTG and previous discussions in IRC, I mentioned there were two different design ideas I had for the developer experience for custom action development in mistral-lib. The purpose and intent behind the patch[1] was discussed in person at the PTG and that was helpful for me wrt to scope. I feel it would be helpful to discuss and decide together the final piece of this patch. I'd like to get any feedback on either of these two ideas as they will shape how developers integrate with Mistral in the future, impact our OpenStack integration efforts in mistral-extra. Nothing stops a developer from adopting either style in their custom action libraries, but most will likely want to remain consistent with style present in the upstream code.<div><br></div><div>I have created separate declaration and usage examples in hopes of illustrating some of the similarities and differences. To me it seems the base class example is more declarative/explicit, but the mixin example is more extensible and dry. Both examples reflect on backwards compatibility and possible changes to how mistral checks for sync/async actions and how to pass the context (as needed by actions that integrate with OpenStack).<div><br clear="all"><div><br></div><div>base classes declaration: <a href="https://gist.github.com/rbrady/ff86c484e8e6e53ba2dc3dfa17b01b09" target="_blank">https://gist.<wbr>github.com/rbrady/<wbr>ff86c484e8e6e53ba2dc3dfa17b01b<wbr>09</a></div><div><br></div><div>base class usage: <a href="https://gist.github.com/rbrady/716a02fb2bd38d822c6df8bd642d3ea6" target="_blank">https://gist.github.<wbr>com/rbrady/<wbr>716a02fb2bd38d822c6df8bd642d3e<wbr>a6</a></div><div><br></div><div>mixins declaration: <a href="https://gist.github.com/rbrady/d30ae640b19df658a17cd93827125678" target="_blank">https://gist.<wbr>github.com/rbrady/<wbr>d30ae640b19df658a17cd938271256<wbr>78</a></div><div><br></div><div>mixins usage: <a href="https://gist.github.com/rbrady/248cb52d5c5f94854d8c76eee911ce8e" target="_blank">https://gist.github.<wbr>com/rbrady/<wbr>248cb52d5c5f94854d8c76eee911ce<wbr>8e</a></div><div><br></div><div><br></div><div>Thanks,</div><div><br></div><div>Ryan</div><div><br></div>-- <br><div class="m_4542071899119995468gmail_signature"><div dir="ltr">Ryan Brady<div>Cloud Engineering</div><div><a href="mailto:rbrady@redhat.com" target="_blank">rbrady@redhat.com</a> </div><div><a href="tel:(919)%20890-8925" value="+19198908925" target="_blank">919.890.8925</a></div><div><br></div><div><br></div><div>[1] <a href="https://review.openstack.org/#/c/411412/" target="_blank">https://review.openstack.<wbr>org/#/c/411412/</a><br></div></div></div>
</div></div></div></div></div><span class="">
______________________________<wbr>______________________________<wbr>______________<br>OpenStack Development Mailing List (not for usage questions)<br>Unsubscribe: <a href="mailto:OpenStack-dev-request@lists.openstack.org" target="_blank">OpenStack-dev-request@lists.<wbr>openstack.org</a>?subject:<wbr>unsubscribe<br><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/<wbr>cgi-bin/mailman/listinfo/<wbr>openstack-dev</a><br></span></div></blockquote></div><br></div><br>______________________________<wbr>______________________________<wbr>______________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.<wbr>openstack.org?subject:<wbr>unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/<wbr>cgi-bin/mailman/listinfo/<wbr>openstack-dev</a><br>
<br></blockquote></div><br></div></div>