Open nabeelvalley opened 5 years ago
Does Hangfire work well for F#? I expected some more work is required to bring "native" experience there. Anyway this is an interesting idea, but I'm unsure how multiple languages will look in the docs. I've just found a plugin for Sphinx that allows code examples for multiple languages that may solve some issues.
I've used it very at a very basic level thus far and I can definitely say that it "works" but will try to actually run through some of the examples from the doc and put together some parallels so you can take a look at it
Sounds great, maybe it's better to start first with a small page with several snippets to see how it will look like.
Hey, so I've taken a look at the package and it doesn't seem to really do much - it looks like it just adds two code blocks, and I assume you'd then have to include the CSS and JS, but this installs in my local and I'm not sure what it looks like. This is the output without that enabled
This is with the CSS and JS enabled (I just copied it manually into the build directory), the toggles don't really work correctly either
Also, I'm not too sure if we would need to include the extension in the repo itself, the documentation is not too clear on that, also note the RST and HTML output for the code blocks below
.. example-code::
.. code-block:: csharp
// ...
using Microsoft.Extensions.DependencyInjection;
using Hangfire;
using Hangfire.SqlServer;
.. code-block:: fsharp
// ...
open Microsoft.Extensions.DependencyInjection;
open Hangfire
open Hangfire.SqlServer
<div class="example-code docutils container">
<div class="highlight-csharp notranslate"><div class="highlight"><pre><span></span><span class="c1">// ...</span>
<span class="k">using</span> <span class="nn">Microsoft.Extensions.DependencyInjection</span><span class="p">;</span>
<span class="k">using</span> <span class="nn">Hangfire</span><span class="p">;</span>
<span class="k">using</span> <span class="nn">Hangfire.SqlServer</span><span class="p">;</span>
</pre></div>
</div>
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="c1">// ...</span>
<span class="k">open</span> <span class="nn">Microsoft.Extensions.DependencyInjection</span><span class="o">;</span>
<span class="k">open</span> <span class="nn">Hangfire</span>
<span class="k">open</span> <span class="nn">Hangfire.SqlServer</span>
</pre></div>
</div>
</div>
I couldn't use the emphasize-lines
thing either as this threw an error on the function that generates the blocks maximum 1 argument(s) allowed, 3 supplied.
So it’s 2019 and there are still a lot of things to be done in software for writing docs 😅
So it’s hard to guess what the result would look like, and without the whole picture it’s hard to make decisions.
What do you think about a separate page for using Hangfire in F# instead with some overview of the common usage patterns?
It would be much simpler to start with and doesn’t require to make global choices.
Hey a general F# page could work, I don't think it's very different to the C# patterns other than just a language translation in some ways
At a more general level though do you have any idea if there are any people using F#? I can't believe the uptake is very big at this point
@nabeelvalley it is different, the biggest issue is about the way reflection is achieved with F# functions, what you can see in Dashboard UI can appear rather clunky and misleading.
What is the status of Hangfire + F#? Is it stable? We're looking into using Hangfire (although we might have to write our own extension to add scheduling jobs from the dashboard and allow passing parameters to said job). Our intention is to do all of this from F# but if we can't be certain things work we might have to explore other options as we are restricted in resources.
reflection is achieved with F# functions, what you can see in Dashboard UI can appear rather clunky and misleading.
perhaps an idea is to cast them to Func
, which would reflect better.
reflection is achieved with F# functions, what you can see in Dashboard UI can appear rather clunky and misleading.
perhaps an idea is to cast them to
Func
, which would reflect better.
In-place casting of anonymous F# functions to Func<...>
is what works best in my experience.
The only downside, is that you don't really get to see the implementation preview (unlike with regular C# methods) but at least it's not too much of a clunky display: https://github.com/natalie-o-perret/how-to-experiments/tree/main/fsharp/how-to-add-hangfire-console-logs
This is an aul' repo that I use occasionally to test whether some libs need adjustments and whatnot.
[EDIT] Also, worth mentioning that there is (I believe) new repo available now, https://github.com/HangfireIO/Hangfire.DynamicJobs Which might also help further customizing some use cases relevant to F#.
Hope that helpes.
Would there be an interest in adding code samples for F#?
I wouldn't mind working on it (as far as I can of course)