Giter Club home page Giter Club logo

kwang's Introduction

Kwang

Kwang is a thin Kotlin/Native wrapper around high-performance, low-overhead web server(s). It is in experimental state, supporting Lwan partially. It may have libh2o backend in the future.

Build Status Build status CodeBeat badge CodeFactor Total alerts

Building

Cloning the repo with submodule(s)

git clone --recurse-submodules https://github.com/KwangIO/kwang
cd kwang

You can import it with IntelliJ IDEA

Building Lwan

cmake, zlib, and libbsd should be installed before building.

  • Arch Linux: pacman -S cmake zlib libbsd
  • Ubuntu: apt-get update && apt-get install git cmake zlib1g-dev pkg-config libbsd-dev
  • I have not tried to build it on other operating systems
./buildLwan.sh

If you want more customization, see lwan#Building.

Sample

Open SampleLinux.kt

class SampleHandler : KwangHandler("/") {
    override fun handleGet(request: RequestContext, response: ResponseContext): StatusCode {
        println("Auth: ${request.authorization}")
        println("Origin:" + request.getHeader("Origin"))
        response withHeaders listOf(
            Header("meaning-of-life", "42"),
            Header("looking-for", "job")
        ) plain ("123")
        return StatusCode(200u)
    }
}

class OtherSample : KwangHandler("/hello") {
    override fun handleGet(request: RequestContext, response: ResponseContext): StatusCode {
        response json ("""{"hello":"${request.getQuery("name")}"}""")
        return StatusCode(200u)
    }
}

fun main(args: Array<String>) {
    ServerLwan(listOf(SampleHandler(), OtherSample()), LwanConfig("localhost:8081"))
}

Running the sample

gradle runProgram (no colorful output) or gradle build (test will fail at the moment, just ignore it and run build/bin/linux/main/release/executable/kwang.kexe)

The server will start on localhost:8081

Building klib

The library is very EXPERIMENTAL and likely to change significantly, using it in production code is NOT RECOMMENDED. But yes, you can build the klib (check gradle linuxKlibrary)

Supported operating system

Linux64

Roadmap

  • Server configuration (port, ..)
  • CORS support (partially)
  • Logging
  • H2O backend (because Lwan does not support HTTP/2)
  • Finish the wrapper
  • Optimize performance
  • EventBus
  • WebSocket
  • Path params / Full-featured router

Benchmark

TODO In case you want benchmarking Kwang, you should consider compile lwan in release mode and pass -opt to konanc With autocannon -c 100 -d 40 -p 10 localhost:8080, Kwang reached around 80k reqs/sec on a MSI GE72VR laptop

Contributing

Feel free to submit issues and enhancement requests. This is a low priority side-project to me, so there is no ETA/promise, but PRs are welcomed.

Why? JVM framework like Vert.X/Ktor/Spring + GraalVM makes more sense

Agree.

Can you change the name, it looks weird

I am not in the mood of choosing bike shed's name. Moreover, it is not that weird you racist people! Kwang in Korean

Known issue

For current Kotlin/Native version (1.3.0), it will not compile due to linker issue (please clone Kotlin/Native from github or wait for the next release)

(Kudos to Kotlin/Native team)

Use latest Kotlin/Native compiler
git clone https://github.com/JetBrains/kotlin-native --depth 1 -b master
cd kotlin-native
./gradlew dependencies:update
./gradlew bundle
cp -R dist/* ~/.konan/kotlin-native-linux-[ver]

or you can set konan.home project property

Donate

kwang's People

Contributors

quangio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kwang's Issues

Steal Pippo's ideas and architecture. Because it's awesome.

http://www.pippo.ro/

Joking, mostly...

But it's nice that pippo stays very light weight and modular (unlike Spring) and yet still caters to websites as well as web services (where Spark is more oriented toward just services).

It's also great that it has the option of DSL like syntax for defining end points as well as a Controller based approach. And it leaves it up to the developer to pick their flavor.

It's a great overall design I think.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.