Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-bee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-bee
Commits
e1b22454
Verified
Commit
e1b22454
authored
Jan 16, 2025
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[demo] some fixes, README added
parent
d2931dc6
Pipeline
#7225
failed with stages
in 14 minutes and 34 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
9 deletions
+67
-9
README.md
demo/README.md
+53
-0
Types.hs
demo/app/App/Types.hs
+10
-7
cabal.project
demo/cabal.project
+3
-2
haskell-bee-demo.cabal
demo/haskell-bee-demo.cabal
+1
-0
No files found.
demo/README.md
0 → 100644
View file @
e1b22454
# haskell-bee demo
## DB setup
This is a simple demo of pgmq-based workers.
First, you need a postgresql database:
```
shell
podman run
--rm
-p
5432:5432
-e
POSTGRES_PASSWORD
=
postgres
-e
POSTGRES_DB
=
postgres postgres
```
Next, you can configure postgres access via an env variable:
```
shell
export
POSTGRES_CONN
=
"host=localhost port=5432 dbname=postgres user=postgres password=postgres"
```
## Command-line
To run the command-line and see available options:
```
shell
cabal v2-run demo
--
-h
```
You need to spawn the worker first:
```
shell
cabal v2-run demo
--
worker
```
Now you can send tasks to the worker (from another terminal):
```
shell
cabal v2-run demo
--
echo
"hello"
cabal v2-run demo
--
error
"oops!"
cabal v2-run demo
--
wait
10
cabal v2-run demo
--
quit
```
## About killing with `Ctrl-C`
`haskell-bee`
implements possibility of a graceful shutdown of the worker.
Depending on the
`resendWhenWorkerKilled`
property in the task
metadata, the currently running task will be either killed and
discarded or killed and resent to the broker.
One often kills command-line programs with
`Ctrl-C`
. Hence, a small
wrapper is needed around
`initWorker`
to support such graceful
shutdown:
```
haskell
initWorker
"default"
_ga_queue
$
\
a
_state
->
do
let
tid
=
asyncThreadId
a
_
<-
installHandler
keyboardSignal
(
Catch
(
throwTo
tid
W
.
KillWorkerSafely
))
Nothing
wait
a
```
demo/app/App/Types.hs
View file @
e1b22454
...
...
@@ -20,7 +20,10 @@ data Program =
programParser
::
ParserInfo
Program
programParser
=
info
(
(
Program
<$>
global
<*>
commandParser
)
<**>
helper
)
mempty
(
(
Program
<$>
global
<*>
commandParser
)
<**>
helper
)
(
fullDesc
<>
header
"haskell-bee demo"
<>
progDesc
"Simple demonstration of worker capabilities"
)
data
GlobalArgs
=
GlobalArgs
{
_ga_queue
::
B
.
Queue
}
...
...
@@ -45,14 +48,14 @@ data Command
commandParser
::
Parser
Command
commandParser
=
subparser
(
command
"worker"
(
info
(
worker
<**>
helper
)
mempty
)
<>
command
"queue-size"
(
info
(
queueSize
<**>
helper
)
mempty
)
(
command
"worker"
(
info
(
worker
<**>
helper
)
(
progDesc
"run worker"
)
)
<>
command
"queue-size"
(
info
(
queueSize
<**>
helper
)
(
progDesc
"show queue size"
)
)
-- tasks
<>
command
"echo"
(
info
(
echo
<**>
helper
)
mempty
)
<>
command
"error"
(
info
(
error'
<**>
helper
)
mempty
)
<>
command
"quit"
(
info
(
quit
<**>
helper
)
mempty
)
<>
command
"wait"
(
info
(
wait
<**>
helper
)
mempty
)
<>
command
"echo"
(
info
(
echo
<**>
helper
)
(
progDesc
"echo task"
)
)
<>
command
"error"
(
info
(
error'
<**>
helper
)
(
progDesc
"error task"
)
)
<>
command
"quit"
(
info
(
quit
<**>
helper
)
(
progDesc
"quit task"
)
)
<>
command
"wait"
(
info
(
wait
<**>
helper
)
(
progDesc
"wait task"
)
)
)
data
WorkerArgs
=
...
...
demo/cabal.project
View file @
e1b22454
...
...
@@ -2,9 +2,10 @@ with-compiler: ghc-9.4.8
packages:
./
../
../haskell-bee
../haskell-bee-pgmq
source-repository-package
type: git
location: https://gitlab.iscpif.fr/gargantext/haskell-pgmq
tag:
0591a643d8ba1776af4fac56c1e4ff5fc3e98bb
3
tag:
1dd92f0aa8e9f8096064e5656c336e562680f4e
3
demo/haskell-bee-demo.cabal
View file @
e1b22454
...
...
@@ -65,6 +65,7 @@ library
, aeson >= 2.1 && < 2.3
, async >= 2.2 && < 2.3
, haskell-bee
, haskell-bee-pgmq
, postgresql-simple >= 0.7.0 && < 0.8
, safe-exceptions >= 0.1.7 && < 0.2
, text >= 2.0 && < 2.2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment