Hystrix icon indicating copy to clipboard operation
Hystrix copied to clipboard

HystrixObservableCommand.run() Method Name

Open benjchristensen opened this issue 12 years ago • 9 comments

Should this method still be called run(), or something else since it actually does not "run" anything, but just retrieves the Observable<T> that will later be run?

benjchristensen avatar Mar 14 '14 00:03 benjchristensen

This needs to be decided before the final 1.4.0 release.

benjchristensen avatar Mar 14 '14 00:03 benjchristensen

The pattern i've been using for commands which return an Observable (and don't actually run) is to call them, prepareX(). X being the action they are preparing, so in this case, it would be prepareRun()

There may be a better convention for reactive commands though that I am not aware of. :) But I agree it should be renamed to reduce confusion.

alexwen avatar Mar 14 '14 20:03 alexwen

get() or getObservable()?

spencergibb avatar Sep 18 '14 20:09 spencergibb

Either of those would work for me. So it seems options are:

  • get()
  • getObservable()
  • prepare()
  • prepareRun()
  • prepareObservable()
  • create()

benjchristensen avatar Sep 19 '14 16:09 benjchristensen

observe() or create() would be my vote. The class name implies that you're creating an observable, so I don't think you need to include 'observable' in the method name. Unless you think it removes ambiguity when compared to the other Hystrix Commands.

KoltonAndrus avatar Sep 19 '14 17:09 KoltonAndrus

What about construct()? Like a constructor, you pass it arguments, but don't expect anything to run until you call other methods.

mattrjacobs avatar Sep 21 '14 00:09 mattrjacobs

construct() sounds good too.

benjchristensen avatar Sep 22 '14 17:09 benjchristensen

+1 for construct(), I think this best expresses the behavior of the method.

pmotyka avatar Sep 24 '14 16:09 pmotyka

I like construct() as well.

benjchristensen avatar Sep 24 '14 16:09 benjchristensen