Giter Club home page Giter Club logo

agones4j's Introduction

agones4j

Maven Central Version

How to Use (Developers)

Code

repositories {
  mavenCentral()
}

dependencies {
    // Base module
    implementation "net.infumia:agones4j:VERSION"
    // Required, https://mvnrepository.com/artifact/io.grpc/grpc-stub/
    implementation "io.grpc:grpc-stub:1.64.0"
    implementation "io.grpc:grpc-protobuf:1.64.0"
    // Required, https://github.com/grpc/grpc-java/blob/master/gradle/libs.versions.toml#L46/
    implementation "org.apache.tomcat:annotations-api:6.0.53"
}
  void agones() {
    final ExecutorService gameServerWatcherExecutor =
      Executors.newSingleThreadExecutor();
    final ScheduledExecutorService healthCheckExecutor =
      Executors.newSingleThreadScheduledExecutor();
    final Agones agones = Agones.builder()
      // Address specification.
      // If not specified, localhost:9357 will be used.
      // All the following methods are creating a ManagedChannel with 'usePlaintext'
      // If you need to use SSL, you can use 'withChannel(ManagedChannel)' method.
      .withAddress("localhost", 9357)
      .withAddress("localhost") // 9357 
      .withAddress(9357) // localhost
      .withAddress() // localhost 9357
      .withTarget("localhost:9357")
      .withTarget() // localhost:9357
      .withChannel(ManagedChannelBuilder
        .forAddress("localhost", 9357)
        .usePlaintext()
        .build())
      .withChannel() // localhost:9357
      // Game server watcher executor specification.
      .withGameServerWatcherExecutor(gameServerWatcherExecutor)
      // Health checker executor specification.
      // Check you game server's health check threshold and
      // set the executor's delay and period accordingly.
      .withHealthCheck(
        /* delay */Duration.ofSeconds(1L),
        /* period */Duration.ofSeconds(2L)
      )
      .withHealthCheckerExecutor(healthCheckExecutor)
      .build();
  // Health checking.
  // Checks if the executor, delay and period are specified.
  if (agones.canHealthCheck()) {
    // Automatic health checking.
    // Uses the health checker executor and the specified delay and period.
    agones.startHealthChecking();
  }
  // Manual health checking.
  final StreamObserver<Empty> requester = agones.healthCheck();
  // onNext needs to be called continuously to keep the game server healthy.
  requester.onNext(Empty.getDefaultInstance());
  // Stopping the health checking.
  agones.stopHealthChecking();
  // Game server watching.
  // Checks if the executor is specified.
  if (agones.canWatchGameServer()) {
    agones.addGameServerWatcher(gameServer ->
      // This will be called when the game server is updated.
      System.out.println("Game server updated: " + gameServer));
  }
  agones.allocate();
  agones.shutdown();
}

agones4j's People

Contributors

renovate[bot] avatar portlek avatar

Stargazers

Rafał Chomczyk avatar  avatar John avatar Matz Hilven avatar Tyler Thorin avatar  avatar gamecraft avatar  avatar Asher avatar  avatar Tuan Nguyen avatar Benjamin Derksen avatar LittleGiqnt avatar PDD GitHub Chatbot avatar

Watchers

 avatar

Forkers

codestech1

agones4j's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/build.yml
.github/workflows/changelog.yml
.github/workflows/release.yml
gradle
buildSrc/src/main/kotlin/net/infumia/gradle/common.kt
buildSrc/src/main/kotlin/net/infumia/gradle/protobuf.kt
buildSrc/src/main/kotlin/net/infumia/gradle/publish.kt
buildSrc/src/main/kotlin/net/infumia/gradle/spotless.kt
gradle.properties
settings.gradle.kts
  • org.gradle.toolchains.foojay-resolver-convention 0.8.0
build.gradle.kts
buildSrc/settings.gradle.kts
buildSrc/build.gradle.kts
gradle/libs.versions.toml
  • com.google.protobuf:protobuf-java 4.28.2
  • com.google.protobuf:protoc 4.28.2
  • io.grpc:grpc-stub 1.68.0
  • io.grpc:grpc-protobuf 1.68.0
  • org.apache.tomcat:annotations-api 6.0.53
  • com.vanniktech:gradle-maven-publish-plugin 0.29.0
  • com.diffplug.spotless:spotless-plugin-gradle 6.25.0
  • com.google.protobuf:protobuf-gradle-plugin 0.9.4
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.10.2

  • Check this box to trigger a request for Renovate to run again on this repository

Healthcheck is not working

Hello there,

I was looking around for a java sdk for agones and yours is looking very promissing. I created an instance of Agones as described in the README with private static final Agones agones = Agones.builder().withChannel().build(); and tried to put my gameserver into ready-state with agones.ready(). I implemented my healthcheck for reasons in my own scheduled thread as:

var health = agones.healthCheckStream();
scheduleTask(this, () -> {
        this.logger.info("Sending health ping");
        health.onNext(Sdk.Empty.getDefaultInstance());
}).schedule(Duration.ofSeconds(5), Duration.ofSeconds(1));

The sidecar container dose not seem to get any response of the health ping nor the ready call. The GameServer is changing its state from Scheduled straight to Unhealthy.
Am I doing something wrong?

Greetings

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.