Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add Suave hosting for FSAC #74

Merged
merged 17 commits into from
Oct 14, 2015
Merged

[WIP] Add Suave hosting for FSAC #74

merged 17 commits into from
Oct 14, 2015

Conversation

Krzysztof-Cieslak
Copy link
Member

Hey,

So this is my huge PR we've discussed through email. Basically it does 3 things -

  1. Split core functionality of FSAC to its own project and separate it from "presentation / communication" layer which allows to create multiple way of providing FSAC functionality.
  2. Update console application to use this core library.
  3. Create Suave server providing same functionalities as console app.

It's still work in progress - no integration tests for Suave app, hard-coded port for Suave server, one "failing" integration test for console app (however I'm not sure how important it is), some random changes in solution files for integration tests (not sure how I've managed to change it) - but it's pretty much fully usable - console application is working exactly the same as current one, and Suave app is providing exactly same functionalities - I've already have Ionide-fsharp fork (https://github.com/ionide/ionide-fsharp/tree/suave) using it and it's working well.


[<EntryPoint>]
let main argv =
let mutable state = FsAutoComplete.State.Initial
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you use a ref here instead, so that it compiles with F# 3?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@rneatherway
Copy link
Contributor

Wow, this a significant chunk of work, great! I'm very happy to accept such a pull request, with or without tests, hopefully you can find time to add them conveniently at a later date. I have a few comments.

  • The solution files in the integration tests aren't needed, you can just delete them if you like.
  • JSonSerializer.fs seems to be duplicated, should in be in Core?
  • Parser.fs should be deleted from FsAutoComplete
  • Most of CommandReponse.fs is duplicated (with a slightly different API), I think your version in Core should be kept and the one in FsAutoComplete can just use that.
  • The unit tests don't pass anymore, perhaps they just don't reference the correct project now.

@Krzysztof-Cieslak
Copy link
Member Author

OK, so next part of work:

  • I've removed CommandReponse.fs and Parser.fs from FsAutoComplete - I've just missed them when I was moving files around, version from Core was used anyway.
  • I've removed .sln files in integration tests
  • Have changed mutable state to ref
  • JsonSerializer.fs is duplicated "on purpose" - I'm planning to investigate different serialization for Suave backend, and also don't think that serialization implementation should be part of Core anyway.
  • I still have problem with unit tests - I've added app.config to test project and it's now working in VS (still failing when I run it from FAKE). But looking on fail messages, I think I've messed something with bindings redirects / FSharp.Core version reference

@Krzysztof-Cieslak
Copy link
Member Author

Looks like last fix, has broken build on windows 🙄

@rneatherway
Copy link
Contributor

Yeah I hate these app.config/versioning issues. FsUnit is sometimes really bad like this, luckily it isn't involved here. New PR sent over.

Use FSharp.Core 4.3.0.0 throughout
@rneatherway
Copy link
Contributor

Looking good! How would you like to handle releases? If you add the necessary logic to the FAKE script then I can release both at once to https://github.com/fsharp/FsAutoComplete/releases easily.

Also, this won't impact me merging it, but won't you lose the ability to send unsolicited messages, like errors? Do you have to poll for them now? Is the main benefit for Atom that it has lots of built in machinery for interfacing with HTTP?

@Krzysztof-Cieslak
Copy link
Member Author

I actually haven't thought about releases... Probably best way would be to release 2 separate zips for that - one with Console App, second with Suave. I don't know if it might be done as part of one GitHub tag/release or will we need 2?

If error / info is result of command it will be send as (part of) response. And to the other potential errors - haven't seen one since update to 0.24.1 ( and I'm using Atom a lot right now ;) ), before it was just StackOverflow which got fixed (and it crashed app anyway)... so don't think it's a big problem.

Change to HTTP makes clearer request -> response cycle, which makes stuff in Atom ... and other node.js based tools ... easier. I also hope web based server will enable other cool stuff - I know @dsyme mentioned some time ago building new, not Silverlight-based TryFsharp. I guess it can be also usable for @tpetricek projects - FsSnippet (if new version would include "richer" F# editor) or TheGamma which already have web based F# editor.

@rneatherway
Copy link
Contributor

I actually haven't thought about releases... Probably best way would be to release 2 separate zips for that - one with Console App, second with Suave. I don't know if it might be done as part of one GitHub tag/release or will we need 2?

For now, yes let's just do two separate zips on the same tag. That makes it really easy to release, and if there are no changes for one or the other of the frontends in a release that's fine, editors don't need to update. Can you see how to adjust the logic in the FAKE script for that?

If error / info is result of command it will be send as (part of) response.

Doesn't this mean the parse command will be blocking? Perhaps Atom is multi-threaded (unlike Emacs!) so this isn't an issue.

@rneatherway
Copy link
Contributor

I agree the other stuff sounds great!

@Krzysztof-Cieslak
Copy link
Member Author

Can you see how to adjust the logic in the FAKE script for that?

Yep, i will take a look at it. It shouldn't be difficult to add second zip to release.

Doesn't this mean the parse command will be blocking?

HTTP request is always non-blocking in JavaScript, I'm sending a request, get promise of result and just define what happens when it's resolved - it makes things much easier than continue listening on stdio and interpreting incoming from there strings.

@rneatherway
Copy link
Contributor

HTTP request is always non-blocking in JavaScript, I'm sending a request, get promise of result and just define what happens when it's resolved - it makes things much easier than continue listening on stdio and interpreting incoming from there strings.

Great, thanks for the explanation. That does sound nice to work with!

@Krzysztof-Cieslak
Copy link
Member Author

Haven't tested whole release cycle (as don't have write rights here) but looks like it should be working.


let buildDir = project + "/bin/Debug/"
let buildReleaseDir = project + "/bin/Release/"
let integrationTestDir = project + "/test/integration/"
let releaseArchive = "fsautocomplete.zip"

let suaveSummary = "A Suave web server for interfacing with FSharp.Compiler.Service over a HTTP."
let suaveProject = "FsAutoComplete.Suave"
let suaveBuildDebugDir = suaveProject + "/bin/Release"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be debug

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@rneatherway
Copy link
Contributor

Thanks, I'm going to merge and release. I found some strange issue though with it rebuilding FsAutoComplete.Suave each time, because the timestamp for Suave.dll downloaded by Paket was in 2017!

rneatherway added a commit that referenced this pull request Oct 14, 2015
[WIP] Add Suave hosting for FSAC
@rneatherway rneatherway merged commit fde76f3 into ionide:master Oct 14, 2015
@Krzysztof-Cieslak
Copy link
Member Author

Hurrah! 😂 ;)

@rneatherway
Copy link
Contributor

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants