Skip to content
/ messeji Public

Async messaging service for communicating with Sense

Notifications You must be signed in to change notification settings

hello/messeji

Repository files navigation

messeji

Async messaging service for communicating with sense.

Installing/running

Running the server

lein run -m com.hello.messeji.server resources/config/dev.edn

This will use dev.edn as a configuration file.

Using local configuration files

If you want to modify part of the local configuration but not change the repo, use a *.local.edn file.

lein run -m com.hello.messeji.server resources/config/dev.edn dev.local.edn

dev.local.edn might not exist (it's not in the repository), so you'll need to create your own to use this feature. This allows you to merge any changes from your local file over the original (the second argument clobbers any config params in the first arg.)

For example, if dev.edn is

{:a {:x 1, :y 2}
 :b "hello"}

and dev.local.edn is

{:a {:x 5}}

then the resulting config will be

{:a {:x 5, :y 2}
 :b "hello"}

Protocol buffers

The protobuf can be found in our proto repository.

To compile the protobuf files (after they've changed):

protoc -I messeji/  --java_out=/path/to/messeji/src/main/java/ messeji/*.proto

Redis

Messeji uses Redis for message storage and to do pub/sub. You'll need to download and run the redis server locally when testing, and ensure that it matches with your local configuration file.

Client

First, some setup: Require the client and define your sense and its key (to receive messages). Note: Insert actual sense IDs and keys found in your key_store table or this won't work and you'll cry!

(require '[com.hello.messeji.client :as client])

(def sense-id "sense1") ; Replace this with a real sense id

(def aes-key "my-key") ; Again, replace with a real key

We also need to define a host to connect to. For our local server, we can use the handy localhost function.

(def host (client/localhost)) ; Or any string, e.g. "http://myhost:10000"

Now let's start a sense. To do this, we start a new thread, and pass in a callback function to execute whenever we receive new messages. In this example, let's just print out the IDs of messages we receive.

(defn print-message-ids
  [messages]
  (->> messages (map #(.getMessageId %)) prn))

(def sense (client/start-sense host sense-id aes-key print-message-ids))

Now sense is an object that will poll our server for new messages. Let's send a message:

(client/send-message host sense-id)

In addition to seeing the returned message from the server, you should see the message-id printed out to the REPL from our sense thread.

To shut down the sense thread, just close it:

(.close sense)

Because it's Closeable, you could also wrap it in with-open etc.

Releasing

Releasing a new debian package is easy.

./release.sh

This will release the new version to our maven repository, upload the configs, and deploy the debian package. After this step, you can deploy to dev and then prod.

Dev deploy

Run scripts/deploy-dev.sh. This will require you to have a messeji-dev entry in your ssh config.

Prod deploy

For the prod deploy, it's all sanders create/deploy/confirm/sunset and you're golden.

About

Async messaging service for communicating with Sense

Resources

Stars

Watchers

Forks

Packages

No packages published