giggls / osml10n

Localization functions for Openstreetmap
https://tile.openstreetmap.de
GNU General Public License v3.0
14 stars 7 forks source link

Use TCP socket instead of HTTP for communication #5

Closed joto closed 2 years ago

joto commented 2 years ago

This is my current experiment with using a simple TCP socket for communication between client and server instead of HTTP. In my tests this needs onyl about 1/3 of the time overall.

Not something to merge yet. Needs more error checks etc.

giggls commented 2 years ago

I don't know if Unix sockets are still faster in Linux than tcp-sockets to localhost these days but probably neither lua nor python might not have an implementation in their standard library.

giggls commented 2 years ago

Should we add a branch for this?

joto commented 2 years ago

I have pushed a new version of that PR rebased on current master and with more fixes. It probably still could need more error checks and tests. Also I haven't touched the SQL script cc_transcript_via_daemon.sql because I don't have a way to test it.

giggls commented 2 years ago

Testing cc_transcript_via_daemon.sql works as follows:

sven=# select osml10n_cc_translit('東京','jp'); osml10n_cc_translit

Toukyou (1 Zeile)

sven=# select osml10n_cc_translit('東京'); osml10n_cc_translit

dōng jīng (1 Zeile)

joto commented 2 years ago

Okay, I have updated the sql function now, too. And I switched the python server code to a more modern async code which can handle multiple connections at the same time.

I believe this is now ready for review and merge. Probably not perfect, but a solid next step.

giggls commented 2 years ago

OK, I will merge this then.

giggls commented 2 years ago

Found one thing. runtests.lua now produces an exeption if the transcription server is not running.

joto commented 2 years ago

Found one thing. runtests.lua now produces an exeption if the transcription server is not running.

Isn't that good? (Well, the error message could be better). Or what do you prefer would happen?

giggls commented 2 years ago

AFAIR I had an error-message printed to stderr and did return an unaltered string. Don't know if this is a better behaviour but tests just fail this way rather than producing an exception.