#dns #ns #env-logger #env-var #reduce-boilerplate #abstract-ns

ns-env-config

An env_logger-inspired one-stop configuration for name resolution based on abstract-ns. Reduces boilerplate and provides standard way to configure DNS for applications via RUST_NS environment variable.

1 unstable release

Uses old Rust 2015

0.1.0 Dec 5, 2017

#17 in #reduce-boilerplate

21 downloads per month
Used in 2 crates

MIT/Apache

12KB
180 lines

NS Env Config

API Docs | Usage | Github | Crate

An env_logger-inspired one-stop configuration for name resolution based on abstract-ns.

Goals:

  1. Make bootstrapping of small to medium size apps easier
  2. Provide a standard way for configuring name resolution in rust ecosystem

Features:

  1. Standard libc-based name resolution by default (using threads)
  2. [TODO] Feature-gated other resolvers (async, consul,...)
  3. If compiled in, resolvers are enabled by RUST_NS=resolver_name
  4. Sane defaults for resolvers
  5. Subscriptions are enabled by default (using polling if not available)
  6. Some options configured from env (RUST_NS=resolver_name:option=value)
  7. [TODO] Suffix-based resolution (RUST_NS=std,consul=consul-resolver)

Non-goals:

  1. Covering every other way to resolve names
  2. Covering all the settings of every resolvers

Usage

Standard Resolver

$ RUST_NS=std ./your-app

Since standard library resolver is not asynchronous we run resolver in a thread pool.

Parameters:

  • poll_ivl -- polling interval for subscriptions in seconds, default 1
  • threads -- number of threads for name resolution, default 4

Biggest declaration is something like this:

$ RUST_NS=std:poll_ivl=10:threads=16 ./your-app

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~7MB
~106K SLoC