GithubHelp home page GithubHelp logo

rschildmeijer / dns-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spotify/dns-java

0.0 2.0 0.0 210 KB

DNS wrapper library that provides SRV lookup functionality

License: Apache License 2.0

Java 100.00%

dns-java's Introduction

Circle CI Coverage Status Maven Central License

spotify-dns-java

This small DNS wrapper library provides some useful pieces of functionality related to SRV lookups.

Resilience

Sometimes it is useful to default to previously returned, retained values, if a dns lookup should fail or return an empty result. This behavior is controlled by the retainingDataOnFailures() and retentionDurationMillis(long) methods in DnsSrvResolvers.DnsSrvResolverBuilder.

Watching for Changes

It's often useful to update where you try to connect based on changes in lookup results, and this library provides functionality that allows you to get notified when things change by implementing this interface (defined in the ChangeNotifier interface):

  interface Listener<T> {

    /**
     * Signal that set of records changed.
     *
     * @param changeNotification An object containing details about the change
     */
    void onChange(ChangeNotification<T> changeNotification);
  }

  /**
   * A change event containing the current and previous set of records.
   */
  interface ChangeNotification<T> {
    Set<T> current();
    Set<T> previous();
  }

Take a look at the PollingUsage example for an example.

Metrics

If you have a statistics system that can be integrated with using the munin protocol, the method metered() in DnsSrvResolvers.DnsSrvResolverBuilder enables this in conjunction with the spotify munin forwarder. Have a look at the BasicUsage example for details on how to set that up.

Usage

The entry point to lookups is through an instance of DnsSrvResolver obtained via the DnsSrvResolvers factory class.

To periodically check a set of records and react to changes, use the DnsSrvWatcher interface obtained via the DnsSrvWatchers factory class.

For example code, have a look at BasicUsage example and PollingUsage example

To include the latest released version in your maven project, do:

  <dependency>
    <groupId>com.spotify</groupId>
    <artifactId>dns</artifactId>
    <version>3.2.2</version>
  </dependency>

NOTE: version 3.1.0 is broken; you cannot use the retention feature in that version.

License

This software is released under the Apache License 2.0. More information in the file LICENSE distributed with this project.

dns-java's People

Contributors

rouzwawi avatar pettermahlen avatar mikaelgoldmann avatar spkrka avatar lburgazzoli avatar rculbertson avatar daenney avatar nabam avatar nresare avatar rschildmeijer avatar

Watchers

James Cloos avatar  avatar

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.