Skip to content

Commit

Permalink
Cleanup counter example types, bring in jackson parameter names, fix …
Browse files Browse the repository at this point in the history
…logging
  • Loading branch information
slinkydeveloper committed Nov 14, 2024
1 parent ccfe207 commit 2b87f7c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {

implementation(platform(jacksonLibs.jackson.bom))
implementation(jacksonLibs.jackson.jsr310)
implementation(jacksonLibs.jackson.parameter.names)

implementation(kotlinLibs.kotlinx.coroutines)
implementation(kotlinLibs.kotlinx.serialization.core)
Expand All @@ -40,3 +41,5 @@ application {
tasks.withType<Jar> { this.enabled = false }

tasks.withType<ShadowJar> { transform(ServiceFileTransformer::class.java) }

tasks.withType<JavaCompile> { options.compilerArgs.add("-parameters") }
16 changes: 8 additions & 8 deletions examples/src/main/java/my/restate/sdk/examples/Counter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ public void reset(ObjectContext ctx) {
}

@Handler
public void add(ObjectContext ctx, Long request) {
public void add(ObjectContext ctx, long request) {
long currentValue = ctx.get(TOTAL).orElse(0L);
long newValue = currentValue + request;
ctx.set(TOTAL, newValue);
}

@Shared
@Handler
public Long get(SharedObjectContext ctx) {
public long get(SharedObjectContext ctx) {
return ctx.get(TOTAL).orElse(0L);
}

@Handler
public CounterUpdateResult getAndAdd(ObjectContext ctx, Long request) {
public CounterUpdateResult getAndAdd(ObjectContext ctx, long request) {
LOG.info("Invoked get and add with {}", request);

long currentValue = ctx.get(TOTAL).orElse(0L);
Expand All @@ -60,19 +60,19 @@ public static void main(String[] args) {
}

public static class CounterUpdateResult {
private final Long newValue;
private final Long oldValue;
private final long newValue;
private final long oldValue;

public CounterUpdateResult(Long newValue, Long oldValue) {
public CounterUpdateResult(long newValue, long oldValue) {
this.newValue = newValue;
this.oldValue = oldValue;
}

public Long getNewValue() {
public long getNewValue() {
return newValue;
}

public Long getOldValue() {
public long getOldValue() {
return oldValue;
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/src/main/resources/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ appender.console.filter.replay.0.type = KeyValuePair
appender.console.filter.replay.0.key = restateInvocationStatus
appender.console.filter.replay.0.value = REPLAYING

# Restate logs to debug level
# Restate logs to info level
logger.app.name = dev.restate
logger.app.level = error
logger.app.level = info
logger.app.additivity = false
logger.app.appenderRef.console.ref = consoleLogger

Expand Down

0 comments on commit 2b87f7c

Please sign in to comment.