Reia is the Redis Pubsub client that Manase uses to communicate with other modules or nodes.

Related tags

Kotlin Projects Reia
Overview

Mana

from Mana

Reia is a simple wrapper around Lettuce to enable easy usage of its Redis Pubsub client. This library is only intended to be used for sending messages and then receiving a response, sending a simple message or producing responses to requests.

Usage

Prerequisites

To use Reia, you need to have a Reia instance which can be created by using the method:

val reia = Reia.new(ReidsClient.create(...), {
    it.callbackPrefix = "Recommended-To-Change-This"
})

// producers add here.

reia.listen() // only use this once you have attached all the producers.

Producers

You can then create a producer by creating a new class that implements the ReiaProducer class:

object HelloWorldProducer: ReiaProducer {

    fun onMessage(channel: String, message: ReiaMessage): ReiaGeneralMessage? {
        if (message.json()!!.optString("node") != null && message.json()!!.getString("node") === 0) {
            return ReiaPublisherMessage("Hello World", message.callback())
        }
        
        return null
    }
    
}

And once the class is created, you can then attach it to your Reia instance by using the producer(channel: String, listener: ReiaProducer) method:

reia.producer("hello.world", HelloWorldProducer)

🟡 Reia appends .requests and .consumer to channels depending on what event is being done. For requests to producers, Reia will listen and propogate to producers any messages received on .requests and for responses, Reia will listen and propogate to their specified callbacks any messages received on .consumer that matches the callback.

In this example, Reia will propogate any messages received on hello.world.requests onto our HelloWorldProducer and will send any responses to the hello.world.consumer channel.

Requesting

You can make a simple request with Reia by using the send methods of Reia which expects the following:

  • ReiaGeneralMessage: The message to send to the channel.
  • Duration: The time to live of the message, this is by default 1-minute. It's recommeneded to go by 10 second increments since the cleaner cleans at a fixed rate of every ten seconds.
  • Channel: The channel to send the message towards, this is auto-appended with .requests

A sample of sending a simple hello world request to our HelloWorldProducer would be:

reia.send("hello.world", ReiaGeneralMessage(JSONObject().put("node", 0))).thenAccept {
    println(it.full().get("message"))
}
Hello World

Installation

You can install Reia from Jitpack with the following installation methods for Maven and Gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'pw.mihou:Reia:Tag'
}
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>pw.mihou</groupId>
    <artifactId>Reia</artifactId>
    <version>Tag</version>
</dependency>
You might also like...
KTor-Client---Android - The essence of KTor Client for network calls

KTor Client - Android This project encompasses the essence of KTor Client for ne

📦📦Video downloader for Android - Download videos from Youtube, Facebook, Twitter, Instagram, Dailymotion, Vimeo and more than 1000 other sites
📦📦Video downloader for Android - Download videos from Youtube, Facebook, Twitter, Instagram, Dailymotion, Vimeo and more than 1000 other sites

youtube-dl-android 📦 An Android client for youtube-dl: https://github.com/rg3/youtube-dl Major technologies Language: Kotlin Architecture: MVVM Andro

Climby is designed to put climbers in contact with each other
Climby is designed to put climbers in contact with each other

Climby Con el nuevo 'BOOM' de la escalada, se vio la necesidad de crear un app donde los usuarios puedan publicar o unirse a viajes, sin la necesidad

A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations.
A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations.

kotlin-ktor-rest-api A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations. F

A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted outputs-and displays accurate measurements.
A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted outputs-and displays accurate measurements.

Measure App A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted o

Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API

DogAlbum_Api_CodeThrough Basic application that uses Retrofit, Moshi and Coil libraries to parse data from web API This folder contains the completed

FirestoreCleanArchitectureApp is an app built with Kotlin and Firestore that displays data in real-time using the MVVM Architecture Pattern. For the UI it uses Jetpack Compose,  Android's modern toolkit for building native UI.
FirestoreCleanArchitectureApp is an app built with Kotlin and Firestore that displays data in real-time using the MVVM Architecture Pattern. For the UI it uses Jetpack Compose, Android's modern toolkit for building native UI.

FirestoreCleanArchitectureApp FirestoreCleanArchitectureApp is an app built with Kotlin and Cloud Firestore that displays data in real-time using Andr

This project uses Quarkus, the Supersonic Subatomic Java Framework.

foodhouse Project This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, please visit its websit

This project is to create a system that uses DeFi technology to enforce contracts.
This project is to create a system that uses DeFi technology to enforce contracts.

This project is to create a system that uses DeFi technology to enforce contracts. Users will be able to set up contracts between each other, this includes an escrow service for payments. If users disagree over whether a contract was fulfilled, a jury appointed by the system will make the final decision.

Owner
Mana
I'm a Discord bot that brings fluffy anime pictures into Discord communities!
Mana
A simple, lightweight, non-bloated redis client for kotlin and other JVM languages

rekt is a lightweight, non-bloated redis client, primarily written for the kotlin programming language, while also supporting other JVM-based languages, such as Java, Scala, and obviously way more.

Patrick 8 Nov 2, 2022
Kreds - a thread-safe, idiomatic, coroutine based Redis client written in 100% Kotlin

Kreds Kreds is a thread-safe, idiomatic, coroutine based Redis client written in 100% Kotlin. Why Kreds? Kreds is designed to be EASY to use. Kreds ha

Abhijith Shivaswamy 117 Dec 23, 2022
Simple event library to communicate between Activity/Fragment and ViewModel

Setup dependencies { implementation "com.github.skgmn:viewmodelevent:1.1.0" } If you don't know how to access to GitHub Packges, please refer to

null 4 Apr 6, 2022
Kotlin library to communicate with LinuxCNC using JNI.

Kotlin LinuxCNC Kotlin library to communicate with LinuxCNC using JNI. Setup Assuming you have linuxcnc installed Env variables You need to set some e

Rachieru Dragos 1 May 18, 2022
Extensive Redis Pub-Sub wrapper for lettuce written in Kotlin

aware Extensive annotation-based Redis Pub-Sub wrapper for lettuce written in Kotlin. Aware was written to be a replacement for the very dated Banana

Subham 6 Dec 28, 2022
A spring-boot project that demonstrates data caching using Redis

A spring-boot project that demonstrates data caching using Redis

Sakawa Bob 1 Mar 26, 2022
The Okila server project uses the Spring boot framework and uses the Kotlin language

Okila-Server The Okila server project uses the Spring boot framework and uses the Kotlin language Format Response //The response successfully format

Nankai 1 Oct 25, 2021
This repository contains RabbitMQ Protobuf starters with its usage samples for spring-rabbit and spring-cloud-starter-stream-rabbit modules

This repository contains RabbitMQ Protobuf starters with its usage samples for spring-rabbit and spring-cloud-starter-stream-rabbit modules

Maksim Kostromin 2 Nov 29, 2021
Exktor - Extension modules for Ktor

Extension modules for Ktor ExKtor - it's set of extension libraries for Ktor tha

Simone Stefani 0 Sep 11, 2022
An annotation processor library that automatically creates Hilt's `@Binds` functions and modules.

HiltBinder An annotation processor library that automatically creates Hilt's @Binds functions and modules. If you think this library is useful, please

SangMin Park 5 Sep 19, 2022