Commit graph

14 commits

Author SHA1 Message Date
Bradley M. Kuhn
d3395dba78
Handle repeat of query into STDOUT via pty interface to bean-query
Part of the SELECT statement that was entered gets repeated in the
output.  It's some sort of timing issue with IPC::Run or the IO::Pty
because it's often not the entire input but only part of it.

It does however appear that there is usually a blank line right
before output, and in text mode, we can also search for the line of
-'s as a backup to assure we get the proper output and don't send the
garbled input back as the output across the named pipe.

This is a bit of a hacky solution and likely error-prone.
2020-08-10 07:46:20 -07:00
Bradley M. Kuhn
9f9b110c1d
Convert to use IPC::Run in effort to make faster.
By using IPC::Run, the bean-query process need not be restarted every
time.  This shows significant speed improvement.

Note that now, the process will not notice when the Beancount files
change underneath it, or when they query format changes.  Additional
code will be needed to support this.
2020-08-10 06:37:08 -07:00
Bradley M. Kuhn
744ad08644
Allow additional characters that often appear in queries. 2020-08-09 21:02:46 -07:00
Bradley M. Kuhn
02a2fcbbc9
Don't try to cleanup data in client when FIFO doesn't appear.
I think it was in error to go for a lock on the data and clear it —
even if it's data the client had set — when we timeout waiting for
the named pipe to appear.  If the named pipe never appeared, then
something is likely really wrong with the server anyway, and as such,
we might as well expect the server to do the cleanup.
2020-06-16 13:37:42 -07:00
Bradley M. Kuhn
90e6da323e
Add timeout to client when server never creates FIFO.
If the server never creates the named pipe, then this loop originally
hung forever.  The count it now waits for is arbitrary, and probably
could be smaller, since the current implementation of the server
creates the pipe within 3-6 seconds under normal conditions.
2020-06-15 21:29:35 -07:00
Bradley M. Kuhn
975cceeaab
Allow additional characters in bean-query queries.
These additional characters often appear in queries.

Allow them.
2020-06-15 21:29:04 -07:00
Bradley M. Kuhn
a21a35d656
Improve recovery scenario on poorly formatted queries.
Because the client defaulted to dying, this left the server in a
strange state as the query question wasn't cleared and the
“fake failure” named pipe was never opened and processed, since it
couldn't be.

The server did eventually recover when the client fully died;
however, the client has enough information to give up its query when
it knows failure has occurred, so that now happens.
2020-06-15 20:40:22 -07:00
Bradley M. Kuhn
6ef1ba0422
Support format option provided by client
The format option on bean-query command-line is now an option that
the client can pass along.  The setting defaults to whatever
`bean-query` was going to default to.
2020-06-15 20:37:49 -07:00
Bradley M. Kuhn
e9d0a8b857
Fix incorrect verbosity.
There was a logic error in the test for this verbose message.
2020-06-15 16:30:46 -07:00
Bradley M. Kuhn
8349b9610b
Only server should control fifo; client should wait for it to clear
On the a classic “concurrency is hard” front, I am slightly proud of
myself that I didn't hit this race condition but anticipated that it
might occur later.  Giving entire control to fifoName to the server
makes more sense here, and the client should not submit its query any
time either fifoName or question is set.

As an extra safeguard, the client will die if it gets the lock and
the state for submitting a query isn't right.

Finally, added some fifoName removal debugging on the server.
2020-06-15 16:29:53 -07:00
Bradley M. Kuhn
42800427f6 bean-query daemon: initial version.
This is a very basic daemon to run bean-query so that other Perl programs
can call it.  The speed savings is not really there yet, as to get that, it
would need to leave bean-query running, perhaps timing out and reloading
files as needed.  That's the long term plan.

Right now, all that this is useful for is to run another Perl process that
wants to submit and receive answers to bean-query.
2020-06-15 14:26:31 -07:00
67c507367a Add copyright information for this repository. 2020-06-15 12:48:05 -07:00
Bradley M. Kuhn
bad50968ae LICENSE of this project is AGPL-3.0-or-later.
GNU Affero General Public License, Version 3.0 or any later version as
published by the FSF
2020-06-15 12:47:50 -07:00
Free Software Foundation
a7bad68d56 GNU Affero General Public License 3.0 as published by the FSF
This was downloaded from https://www.gnu.org/licenses/agpl-3.0.txt ,
a link to which is found on this web page:
     https://www.gnu.org/licenses/agpl-3.0.en.html
2020-06-15 12:06:34 -07:00