Skip to content

Http tools for Finale Lua #333

Open
Open
@rpatters1

Description

@rpatters1

Requirement

It is becoming apparent that there is a need to be able to download files from the web and manipulate them in various ways. This includes potentially updating script files and the like. One of the challenges is that it is very bad form to download files from the web in synchronous calls. An asynchronous approach would be ideal.

Describe the solution you'd like

I would like to keep the core RGP Lua functions clean from this for a few reasons:

  • I am getting a bit overwhelmed, and this could become a moderately large project.
  • By making it a separate Lua library, I don't have to be the only contributor.
  • We can nevertheless include it in RGP Lua as a library to be built-in much as luasocket currently is (and add an option to load or not load it per script).
  • Nevertheless, it will be possible to build it as an external dll or dylib and require the latest version without dependence on a new version release of RGP Lua.

Therefore I am proposing a new C++ repository, perhaps called lua-httptools to live in the finalelua organization. It will make use of OS-level http calls, or any other tools available to C++ development environments, to process http calls.

Describe alternatives you've considered

I have considered a built-in finenv function to download a file. But this is very problematic because

  • it must be a synchronous call and it is also a one-off function specific to a narrow requirement. A synchronous call can lead to big problems if scripts start trying to download multi-megabyte (or gigabyte) files.
  • it is in the RGP Lua codebase, which means only I can contribute to it. Yet my personal interest in this feature is low.
  • it is dependent on the release cadence of RGP Lua. Given the history of Finale on Lua (think JW Lua and the 5-year gap of no updates), I think it is better to keep this separate.
  • there is no compelling reason that this functionality should be part of finenv. It has nothing to do with Finale and will not be dependent on the PDK Framework.

I also looked for existing open-source projects. There are a fair number of them, but they are all quite heavy and have lots of dependencies. It's more work than I have interest in to figure them out, but it would probably be possible to get one of them to work if someone wants to try. This might be a good first step for an interested party.

Ultimately, I suspect that a C/C++ library that can directly access the OS apis and is more tailored to the needs of Finale lua will be a good compromise. It can be built into RGP Lua (as an automatic load-in to the Lua state) but it can also be loaded externally if needed.

Next Steps

If someone is interested, they can look into a 3rd party library and see if it can be made to work in RGP Lua. That might short-circuit the whole conversation.

I will migrate the code I have put into finenv into a shell library that can be built with RGP Lua but be independent as a code base. It will be very rudimentary and ultimately probably not the final API. But it will at least start the project.

We need to be thinking about how to structure the api. To start with, the library will have a single function, httptools.get_file_synchronous. Then more interested parties than I can start adding to it in ways that seem interesting to them. Initially it will not be included in RGP Lua until we can gauge the interest and utility. Instead, it will be built as an external library that can be required by any script that needs it. In fact, you'll be able to debug it through Finale as described at sample-clib. I intend to use that libary as my starting point.

@Nick-Mazuk could you set things up so that we can tag Jan Angermüller? I suspect he will be quite interested in this as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions