Skip to content

Commit

Permalink
development. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Jun 8, 2024
1 parent a38bb99 commit 88d712c
Show file tree
Hide file tree
Showing 51 changed files with 1,838 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
38 changes: 38 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
prerelease: true
template: |
# What's Changed
$CHANGES
categories:
- title: Breaking
label: breaking
- title: New
label: enhancement
- title: Bug Fixes
label: bug
- title: Maintenance
label: maintenance
- title: Documentation
label: documentation
- title: Dependency Updates
label: dependencies

version-resolver:
major:
labels:
- breaking
minor:
labels:
- enhancement
patch:
labels:
- bug
- maintenance
- documentation
- dependencies
- security

exclude-labels:
- skip-changelog
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build

on:
pull_request:
branches: [ master ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '8'

- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/cache@v4
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradlew-
- run: |
chmod +x gradlew
./gradlew build
16 changes: 16 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Update Changelog

on:
push:
branches: [ master ]

jobs:
changelog:
name: Update Changelog
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'skip-snapshot') }}
steps:
- uses: release-drafter/release-drafter@master
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Update Snapshot
on:
push:
branches:
- master
jobs:
snapshot:
name: Update Snapshot
runs-on: ubuntu-latest
if: "${{ !contains(github.event.head_commit.message, 'skip-snapshot') }}"
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '8'

- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/cache@v4
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradlew-
- uses: crazy-max/[email protected]
with:
gpg_private_key: "${{ secrets.GPG_PRIVATE_KEY }}"
passphrase: "${{ secrets.GPG_PASSPHRASE }}"

- run: |
[[ "${{ steps.release.outputs.tag_name }}" =~ ^[0-9]+(\.[0-9]+)*$ ]] || exit -1
chmod +x gradlew
./gradlew -Psign-required=true publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion="${{ steps.release.outputs.tag_name }}-SNAPSHOT" -PinfumiaSigningKey="${{ secrets.GPG_SECRET_KEY_ID }}" -PinfumiaSigningPassword="${{ secrets.GPG_PASSPHRASE }}" -PsonatypeUsername="${{ secrets.SONATYPE_USERNAME }}" -PsonatypePassword="${{ secrets.SONATYPE_PASSWORD }}"
34 changes: 10 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
.idea/
target/
.gradle/
build/
*.iml
*.project
*.classpath
.settings/
**/bin/
.vscode/
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
# pubsub
Simplified pubsub library for Redis and various databases.
![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/tr.com.infumia/pubsub?label=maven-central&server=https%3A%2F%2Foss.sonatype.org%2F)
![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/tr.com.infumia/pubsub?label=maven-central&server=https%3A%2F%2Foss.sonatype.org)
## How to Use (Developers)
### Code
```groovy
repositories {
maven("https://jitpack.io/")
}
dependencies {
// Base module
implementation "tr.com.infumia:pubsub:VERSION"
// Required, https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine/
implementation "com.github.ben-manes.caffeine:caffeine:2.9.3" // for java-8+
implementation "com.github.ben-manes.caffeine:caffeine:3.1.8" // for java-11+
// Pub/Sub using Redis (Optional)
implementation "tr.com.infumia:pubsub-redis:VERSION"
// Required, https://mvnrepository.com/artifact/io.lettuce/lettuce-core/
implementation "io.lettuce:lettuce-core:6.3.2.RELEASE"
// Kotlin extensions (Optional)
implementation "tr.com.infumia:pubsub-kotlin:VERSION"
// Kotlin protobuf serializer (Optional)
implementation "tr.com.infumia:pubsub-kotlin-protobuf:VERSION"
// Required, https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-reflect/
implementation "org.jetbrains.kotlin:kotlin-reflect:2.0.0"
// Required, https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-core/
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.0"
// Required, https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-protobuf/
implementation "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.7.0"
}
```
```java
void pubsub() {}
```
29 changes: 29 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
java
alias(libs.plugins.indra.publishing.sonatype)
}

repositories.mavenCentral()

subprojects {
apply<JavaPlugin>()

repositories.mavenCentral()

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

tasks {
compileJava {
options.compilerArgs.add("-Xlint:-processing")
options.compilerArgs.add("-Xlint:-options")
}
}
}

indraSonatype {
useAlternateSonatypeOSSHost("s01")
}
13 changes: 13 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
java
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation(libs.indra)
}
9 changes: 9 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "buildSrc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id("net.kyori.indra")
id("net.kyori.indra.publishing")
}

val projectName = project.property("artifact-id") as String

indra {
mitLicense()
github("infumia", "pubsub")
configurePublications {
artifactId = projectName

pom {
name = projectName
inceptionYear = "2024"
description = "Simplified pubsub library for Redis and various databases."
developers {
developer {
name = "Hasan Demirtaş"
url = "https://github.com/portlek/"
}
}
organization {
name = "Infumia"
url = "https://github.com/infumia/"
}
}
}
if (project.hasProperty("sign-required")) {
signWithKeyFromPrefixedProperties("infumia")
}
}
7 changes: 7 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id("tr.com.infumia.pubsub.build.publishing")
}

dependencies {
compileOnly(libs.caffeine)
}
1 change: 1 addition & 0 deletions common/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
artifact-id=pubsub
21 changes: 21 additions & 0 deletions common/src/main/java/tr/com/infumia/pubsub/AwaitingResponder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package tr.com.infumia.pubsub;

import java.time.Duration;
import java.util.concurrent.CompletableFuture;

final class AwaitingResponder<T> {
private final CompletableFuture<T> future = new CompletableFuture<>();
final Class<T> responseType;

AwaitingResponder(final Class<T> responseType) {
this.responseType = responseType;
}

void complete(final T response) {
this.future.complete(response);
}

CompletableFuture<T> await(final Duration timeout) {
return Internal.delay(this.future, timeout);
}
}
Loading

0 comments on commit 88d712c

Please sign in to comment.