ID Client


License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.hubrick.client
ArtifactId

ArtifactId

id-client
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

ID Client
ID Client
Source Code Management

Source Code Management

http://github.com/hubrick/id-client.git

Download id-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.hubrick.client/id-client/ -->
<dependency>
    <groupId>com.hubrick.client</groupId>
    <artifactId>id-client</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.hubrick.client/id-client/
implementation 'com.hubrick.client:id-client:1.0.0'
// https://jarcasting.com/artifacts/com.hubrick.client/id-client/
implementation ("com.hubrick.client:id-client:1.0.0")
'com.hubrick.client:id-client:jar:1.0.0'
<dependency org="com.hubrick.client" name="id-client" rev="1.0.0">
  <artifact name="id-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.hubrick.client', module='id-client', version='1.0.0')
)
libraryDependencies += "com.hubrick.client" % "id-client" % "1.0.0"
[com.hubrick.client/id-client "1.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.thrift : libthrift jar 0.9.2
com.google.guava : guava jar 18.0
org.slf4j : slf4j-api jar 1.7.7
org.hamcrest : hamcrest-all jar 1.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Async ID client

Async ID client implementation for id services such as Flurry Unique id generation service. It's based on a producer-consumer pattern. A thread pool constantly fetches new ids and keeps them in a local queue.

Compatibility

  • Java 6+
  • Supported clients
    • Flurry v0.2.0-beta

Dependency

<dependency>
    <groupId>com.hubrick.client</groupId>
    <artifactId>id-client</artifactId>
    <version>1.0.0</version>
</dependency>

Features

  • Flurry
    • Id collision protection (If the servers are misconfiguration and have the same workerId a collision can occur. The client checks the configuration on startup.)
    • Automated reconnection to servers (If a server was down and shows up again the client will automatically reconnect and start to consume the ids again)

How to use

###Create an instance

public IdClient createClient() {
	return new FlurryIdClient.Builder()
		.addServiceEndpoint("localhost", 9090)
		.addServiceEndpoint("localhost", 9091)
		.addServiceEndpoint("localhost", 9092)
		.withQueueSize(1000)
		.withThreadPoolSize(10)
		.withWaitOnFailMillis(1000)
		.build();
    }

###Consume ids

public void someMethod(IdClient idClient) {
	try {
		System.out.println("Retrieved id in a blocking way. ID: " + idClient.getId());	
		System.out.println("Retrieved id in a blocking way wit timeout. ID: " + idClient.getId(100));	
	} catch (InterruptedException e) {
		// Should not happen
	}
	
	System.out.println("Retrieved id in a non blocking way. ID: " + idClient.getIdNonBlocking());	
}

Exceptions

Name Description
IdClientException Base exception
ConnectionException When the client is unable to connect to the id server

License

Apache License, Version 2.0

com.hubrick.client

Hubrick

Versions

Version
1.0.0