Twitch Twirp RPC implementation for Java
Перейти к файлу
dependabot[bot] b0df20e2ee
Bump the actions group with 3 updates (#18)
Bumps the actions group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [actions/setup-java](https://github.com/actions/setup-java) and [github/codeql-action](https://github.com/github/codeql-action).


Updates `actions/checkout` from 3 to 4
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

Updates `actions/setup-java` from 3 to 4
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v3...v4)

Updates `github/codeql-action` from 2 to 3
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-21 12:18:49 -07:00
.github Bump the actions group with 3 updates (#18) 2024-06-21 12:18:49 -07:00
docs Moved all docs to plain markdown 2018-06-25 13:25:26 +01:00
gradle/wrapper upgrade gradle to 8.8, add depbot config and wrapper update workflow (#16) 2024-06-21 12:08:05 -07:00
plugin upgrade to spring-framework 6, java 17, and bump version to 2.0.0 (#14) 2023-07-31 11:58:03 -07:00
runtime upgrade to spring-framework 6, java 17, and bump version to 2.0.0 (#14) 2023-07-31 11:58:03 -07:00
.gitignore GH-1: Ensure the gradle wrapper JAR is committed 2018-10-12 14:37:14 +01:00
LICENSE Updated license details 2018-06-13 09:33:55 +01:00
README.md upgrade to spring-framework 6, java 17, and bump version to 2.0.0 (#14) 2023-07-31 11:58:03 -07:00
build.gradle upgrade to spring-framework 6, java 17, and bump version to 2.0.0 (#14) 2023-07-31 11:58:03 -07:00
gradlew upgrade gradle to 8.8, add depbot config and wrapper update workflow (#16) 2024-06-21 12:08:05 -07:00
gradlew.bat upgrade gradle to 8.8, add depbot config and wrapper update workflow (#16) 2024-06-21 12:08:05 -07:00
settings.gradle add jakarta implementation of plugin and runtime jars (#11) 2023-05-02 14:32:36 -07:00

README.md

Flit - Twirp RPC Generator Framework

This project is a generator for the Twitch TV Twirp RPC framework.

It supports the generation of Java based servers with the following flavours supported:

Contents

Using

Runtime libraries

Follow the Working with the Gradle registry docs to set up authentication with GitHub packages.

Published runtime libraries example Gradle setup:

repositories {
    maven {
        name = 'GithubPackages'
        url 'https://maven.pkg.github.com/github/flit'
        credentials {
            username = project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR')
            password = project.findProperty('gpr.key') ?: System.getenv('GITHUB_TOKEN')
        }
        content {
            includeGroup('com.flit')
        }
    }
}

dependencies {
    implementation("com.flit:flit-core-runtime:<version>")
    implementation("com.flit:flit-spring-runtime:<version>")
    implementation("com.flit:flit-jaxrs-runtime:<version>")
    implementation("com.flit:flit-jakarta-runtime:<version>")
    implementation("com.flit:flit-undertow-runtime:<version>")
}

Protoc plugin

Plugin com.flit.flit-plugin shadow jar can be downloaded from here.

The flit plugin accepts the following plugin parameters:

Name Required Type Description
target Y enum[server] The type of target to generate e.g. server, client etc
type Y enum[spring,undertow,boot,jakarta,jaxrs] Type of target to generate
context N string Base context for routing, default is /twirp
request N string If the request parameter should pass to the service

via gradle

The plugin can be called from the Gradle protobuf plugin via additional configuration. For example:

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:$protocVersion"
    }
  
    plugins {
        flit {
            path = "${projectDir}/script/protoc-gen-flit"
        }
    }

    generateProtoTasks {
        ofSourceSet('main')*.plugins {
            flit {
                option 'target=server'
                option 'type=spring'
                option 'request=Service'
            }
        }
    }
}
#!/usr/bin/env bash

DIR=$(dirname "$0")

JAR=$(ls -c ${DIR}/flit-plugin-*.jar | head -1)
java ${FLIT_JAVA_OPTS} -jar $JAR $@

Where the plugin jar is located in the same directly as the script.

via protoc

The plugin is executed as part of a protoc compilation step:

protoc \
    --proto_path=. \
    --java_out=../java \
    --flit_out=target=server,type=undertow:../java \
    ./haberdasher.proto

Development

Requirements

The build has been tested with Zulu's OpenJDK version 17.

The build uses gradle to generate the artifacts. No installation is required as the project uses the gradle wrapper setup.

Optional: to test you will need an installation of the protocol buffers compiler.

Modules

The project is split into the following modules:

Module Description
plugin The protoc plugin
runtime:core Core functionality required by generated code
runtime:jakarta Runtime library for Jakarta servers
runtime:jaxrs Runtime library for JAX-RS servers
runtime:spring Runtime library for Spring MVC/Boot servers
runtime:undertow Runtime library for Undertow servers

Gradle commands

  • clean ./gradlew clean
  • build ./gradlew build
  • test ./gradlew test
  • publish ./gradlew publish

Remote Debug

Use remote JVM debugging by setting:

export FLIT_JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005,quiet=y"

Guides

Platform Document
Undertow undertow.md