All Projects → hypercube1024 → Firefly

hypercube1024 / Firefly

Licence: apache-2.0
Firefly is an asynchronous web framework for rapid development of high-performance web application.

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Firefly

Akka Http
The Streaming-first HTTP server/module of Akka
Stars: ✭ 1,163 (+319.86%)
Mutual labels:  reactive, websocket, http-client, http2, http-server
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+2258.48%)
Mutual labels:  web-framework, websocket, http2, high-performance, http-server
Gsnova
Private proxy solution & network troubleshooting tool.
Stars: ✭ 509 (+83.75%)
Mutual labels:  websocket, tcp, http2, tls
Beast
HTTP and WebSocket built on Boost.Asio in C++11
Stars: ✭ 3,241 (+1070.04%)
Mutual labels:  websocket, http-client, tls, http-server
Proteus
Lean, mean, and incredibly fast JVM framework for web and microservice development.
Stars: ✭ 178 (-35.74%)
Mutual labels:  reactive, web-framework, http2, high-performance
Jetty.project
Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
Stars: ✭ 3,260 (+1076.9%)
Mutual labels:  http-client, http2, tls, http-server
Blinksocks
A framework for building composable proxy protocol stack.
Stars: ✭ 587 (+111.91%)
Mutual labels:  websocket, tcp, http2, tls
Gun
HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP.
Stars: ✭ 710 (+156.32%)
Mutual labels:  websocket, http-client, http2, high-performance
Jiny
Lightweight, modern, simple JVM web framework for rapid development in the API era
Stars: ✭ 40 (-85.56%)
Mutual labels:  web-framework, websocket, http-client, http-server
Beetlex
high performance dotnet core socket tcp communication components, support TLS, HTTP, HTTPS, WebSocket, RPC, Redis protocols, custom protocols and 1M connections problem solution
Stars: ✭ 802 (+189.53%)
Mutual labels:  websocket, tcp, tls, http-server
Workerman
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.3.
Stars: ✭ 9,617 (+3371.84%)
Mutual labels:  asynchronous, websocket, tcp, high-performance
Siris
DEPRECATED: The community driven fork of Iris. The fastest web framework for Golang!
Stars: ✭ 146 (-47.29%)
Mutual labels:  web-framework, http2, tls, high-performance
Restbed
Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.
Stars: ✭ 1,551 (+459.93%)
Mutual labels:  asynchronous, websocket, http2, http-server
Reactivemanifesto
The Reactive Manifesto
Stars: ✭ 542 (+95.67%)
Mutual labels:  reactive, asynchronous, reactive-programming
Rocket.jl
Functional reactive programming extensions library for Julia
Stars: ✭ 69 (-75.09%)
Mutual labels:  reactive, asynchronous, reactive-programming
Rapidoid
Rapidoid - Extremely Fast, Simple and Powerful Java Web Framework and HTTP Server!
Stars: ✭ 1,571 (+467.15%)
Mutual labels:  reactive, web-framework, high-performance
Catacumba
Asynchronous web toolkit for clojure built on top of Ratpack / Netty
Stars: ✭ 192 (-30.69%)
Mutual labels:  asynchronous, web-framework, http-server
Swiftlysalesforce
The swiftest way to build iOS apps that connect to Salesforce
Stars: ✭ 115 (-58.48%)
Mutual labels:  reactive, asynchronous, oauth2
Vert.x
Vert.x is a tool-kit for building reactive applications on the JVM
Stars: ✭ 12,544 (+4428.52%)
Mutual labels:  reactive, http2, high-performance
Index.py
An easy-to-use high-performance asynchronous web framework.
Stars: ✭ 158 (-42.96%)
Mutual labels:  asynchronous, web-framework, websocket

What is Firefly?

Build Status Maven Central License

Firefly framework is an asynchronous Java web framework. It helps you create a web application Easy and Quickly. It provides asynchronous HTTP, Websocket, TCP Server/Client, and many other useful components for developing web applications, protocol servers, etc. That means you can easy deploy your web without any other java web containers, in short, it's containerless. Using Kotlin coroutines, Firefly is truly asynchronous and highly scalable. It taps into the fullest potential of hardware. Use the power of non-blocking development without the callback nightmare.

Firefly core provides functionality for things like:

  • HTTP server and client
  • WebSocket server and client
  • HTTP, Socks proxy
  • HTTP Gateway
  • TCP server and client
  • UDP server and client

Event driven

The Firefly APIs are largely event-driven. It means that when things happen in Firefly that you are interested in, Firefly will call you by sending you events.

Some example events are:

  • some data has arrived on a socket
  • an HTTP server has received a request

Firefly handles a lot of concurrencies using just a small number of threads, so don't block Firefly thread, you must manage blocking call in the standalone thread pool.

With a conventional blocking API the calling thread might block when:

  • Thread.sleep()
  • Waiting on a Lock
  • Waiting on a mutex or monitor
  • Doing a long-lived database operation and waiting for a result
  • Call blocking I/O APIs

In all the above cases, when your thread is waiting for a result it can’t do anything else - it’s effectively useless.

It means that if you want a lot of concurrencies using blocking APIs, then you need a lot of threads to prevent your application grinding to a halt.

Threads have overhead regarding the memory they require (e.g. for their stack) and in context switching.

For the levels of concurrency required in many modern applications, a blocking approach just doesn’t scale.

Quick start

Add maven dependency in your pom.xml.

<dependencics>
    <dependency>
        <groupId>com.fireflysource</groupId>
        <artifactId>firefly</artifactId>
        <version>5.0.0-alpha11</version>
    </dependency>

    <dependency>
        <groupId>com.fireflysource</groupId>
        <artifactId>firefly-slf4j</artifactId>
        <version>5.0.0-alpha11</version>
    </dependency>
</dependencics>

Add log configuration file "firefly-log.xml" to the classpath.

<?xml version="1.0" encoding="UTF-8"?>
<loggers xmlns="http://www.fireflysource.com/loggers"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.fireflysource.com/loggers http://www.fireflysource.com/loggers.xsd">
    <logger>
        <name>firefly-system</name>
        <level>INFO</level>
        <path>logs</path>
    </logger>
</loggers>

HTTP server and client example:

fun main() {
    `$`.httpServer()
        .router().get("/").handler { ctx -> ctx.end("Hello http! ") }
        .listen("localhost", 8090)

    `$`.httpClient().get("http://localhost:8090/").submit()
        .thenAccept { response -> println(response.stringBody) }
}

WebSocket server and client example:

fun main() {
    `$`.httpServer().websocket("/websocket/hello")
        .onServerMessageAsync { frame, _ -> onMessage(frame) }
        .onAcceptAsync { connection -> sendMessage("Server", connection) }
        .listen("localhost", 8090)

    val url = "ws://localhost:8090"
    `$`.httpClient().websocket("$url/websocket/hello")
        .onClientMessageAsync { frame, _ -> onMessage(frame) }
        .connectAsync { connection -> sendMessage("Client", connection) }
}

private suspend fun sendMessage(data: String, connection: WebSocketConnection) = connection.useAwait {
    (1..10).forEach {
        connection.sendText("WebSocket ${data}. count: $it, time: ${Date()}")
        delay(1000)
    }
}

private fun onMessage(frame: Frame) {
    if (frame is TextFrame) {
        println(frame.payloadAsUTF8)
    }
}

TCP server and client example:

fun main() {
    `$`.tcpServer().onAcceptAsync { connection ->
        launch { writeLoop("Server", connection) }
        launch { readLoop(connection) }
    }.listen("localhost", 8090)

    `$`.tcpClient().connectAsync("localhost", 8090) { connection ->
        launch { writeLoop("Client", connection) }
        launch { readLoop(connection) }
    }
}

private suspend fun readLoop(connection: TcpConnection) = connection.useAwait {
    while (true) {
        try {
            val buffer = connection.read().await()
            println(BufferUtils.toString(buffer))
        } catch (e: Exception) {
            println("Connection closed.")
            break
        }
    }
}

private suspend fun writeLoop(data: String, connection: TcpConnection) = connection.useAwait {
    (1..10).forEach {
        connection.write(toBuffer("TCP ${data}. count: $it, time: ${Date()}"))
        delay(1000)
    }
}

Contact information

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].