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

WPB-4748 create a way to inspect background notifications queue #3589

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repository hackage.haskell.org
url: https://hackage.haskell.org/
index-state: 2023-10-03T15:17:00Z
index-state: 2023-10-03T15:17:00Z
packages:
integration
, libs/bilge/
Expand Down Expand Up @@ -51,6 +51,7 @@ packages:
, tools/db/repair-brig-clients-table/
, tools/db/service-backfill/
, tools/fedcalls/
, tools/rabbitmq-consumer
, tools/rex/
, tools/stern/
, tools/mlsstats/
Expand Down Expand Up @@ -120,6 +121,8 @@ package proxy
ghc-options: -Werror
package mlsstats
ghc-options: -Werror
package rabbitmq-consumer
ghc-options: -Werror
package repair-handles
ghc-options: -Werror
package rex
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5-internal/WPB-4748
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CLI tool to consume messages from a RabbitMQ queue
1 change: 1 addition & 0 deletions nix/local-haskell-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
service-backfill = hself.callPackage ../tools/db/service-backfill/default.nix { inherit gitignoreSource; };
fedcalls = hself.callPackage ../tools/fedcalls/default.nix { inherit gitignoreSource; };
mlsstats = hself.callPackage ../tools/mlsstats/default.nix { inherit gitignoreSource; };
rabbitmq-consumer = hself.callPackage ../tools/rabbitmq-consumer/default.nix { inherit gitignoreSource; };
rex = hself.callPackage ../tools/rex/default.nix { inherit gitignoreSource; };
stern = hself.callPackage ../tools/stern/default.nix { inherit gitignoreSource; };
}
1 change: 1 addition & 0 deletions nix/wire-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ let
zauth = [ "zauth" ];
background-worker = [ "background-worker" ];
integration = [ "integration" ];
rabbitmq-consumer = [ "rabbitmq-consumer" ];
};

attrsets = lib.attrsets;
Expand Down
30 changes: 30 additions & 0 deletions tools/rabbitmq-consumer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# RabbitMQ Consumer

```txt
rabbitmq-consumer

Usage: rabbitmq-consumer [-s|--host HOST] [-p|--port PORT]
[-u|--username USERNAME] [-w|--password PASSWORD]
[-v|--vhost VHOST] [-q|--queue QUEUE]
[-t|--timeout TIMEOUT] COMMAND

CLI tool to consume messages from a RabbitMQ queue

Available options:
-h,--help Show this help text
-s,--host HOST RabbitMQ host (default: "localhost")
-p,--port PORT RabbitMQ Port (default: 5672)
-u,--username USERNAME RabbitMQ Username (default: "guest")
-w,--password PASSWORD RabbitMQ Password (default: "alpaca-grapefruit")
-v,--vhost VHOST RabbitMQ VHost (default: "/")
-q,--queue QUEUE RabbitMQ Queue (default: "test")
-t,--timeout TIMEOUT Timeout in seconds. The command will timeout if no
messages are received within this time. This can
happen when the queue is empty, or when we lose the
single active consumer race. (default: 10)

Available commands:
head Print the first message in the queue
drop-head Drop the first message in the queue
interactive Interactively drop the first message from the queue
```
23 changes: 23 additions & 0 deletions tools/rabbitmq-consumer/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2023 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Main where

import qualified RabbitMQConsumer.Lib as Lib

main :: IO ()
main = Lib.main
45 changes: 45 additions & 0 deletions tools/rabbitmq-consumer/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# WARNING: GENERATED FILE, DO NOT EDIT.
# This file is generated by running hack/bin/generate-local-nix-packages.sh and
# must be regenerated whenever local packages are added or removed, or
# dependencies are added or removed.
{ mkDerivation
, aeson
, aeson-pretty
, amqp
, base
, bytestring
, gitignoreSource
, imports
, lib
, network
, optparse-applicative
, text
, types-common
, wire-api
, wire-api-federation
}:
mkDerivation {
pname = "rabbitmq-consumer";
version = "1.0.0";
src = gitignoreSource ./.;
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson
aeson-pretty
amqp
base
bytestring
imports
network
optparse-applicative
text
types-common
wire-api
wire-api-federation
];
executableHaskellDepends = [ base ];
description = "CLI tool to consume messages from a RabbitMQ queue";
license = lib.licenses.agpl3Only;
mainProgram = "rabbitmq-consumer";
}
84 changes: 84 additions & 0 deletions tools/rabbitmq-consumer/rabbitmq-consumer.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
cabal-version: 3.0
name: rabbitmq-consumer
version: 1.0.0
synopsis: CLI tool to consume messages from a RabbitMQ queue
category: Network
author: Wire Swiss GmbH
maintainer: Wire Swiss GmbH <backend@wire.com>
copyright: (c) 2023 Wire Swiss GmbH
license: AGPL-3.0-only
build-type: Simple

executable rabbitmq-consumer
main-is: Main.hs
build-depends:
, base
, rabbitmq-consumer

hs-source-dirs: app

library
hs-source-dirs: src
exposed-modules: RabbitMQConsumer.Lib
default-language: GHC2021
ghc-options:
-Wall -Wpartial-fields -fwarn-tabs
-optP-Wno-nonportable-include-path

build-depends:
, aeson
, aeson-pretty
, amqp
, base
, bytestring
, imports
, network
, optparse-applicative
, text
, types-common
, wire-api
, wire-api-federation

default-extensions:
Copy link
Contributor

Choose a reason for hiding this comment

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

At some point we should go around cleaning up these extensions since a lot of them are on by default with GHC2021, right?

NoImplicitPrelude
AllowAmbiguousTypes
BangPatterns
ConstraintKinds
DataKinds
DefaultSignatures
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
DerivingStrategies
DerivingVia
DuplicateRecordFields
EmptyCase
FlexibleContexts
FlexibleInstances
FunctionalDependencies
GADTs
GeneralizedNewtypeDeriving
InstanceSigs
KindSignatures
LambdaCase
MultiParamTypeClasses
MultiWayIf
NamedFieldPuns
OverloadedLabels
OverloadedRecordDot
PackageImports
PatternSynonyms
PolyKinds
QuasiQuotes
RankNTypes
RecordWildCards
ScopedTypeVariables
StandaloneDeriving
TupleSections
TypeApplications
TypeFamilies
TypeFamilyDependencies
TypeOperators
UndecidableInstances
ViewPatterns
Loading
Loading