All Projects → nats-io → Elixir Nats

nats-io / Elixir Nats

Licence: mit
Elixir NATS client

Programming Languages

elixir
2628 projects

(Deprecated) An Elixir framework for NATS

Build Status Coverage Status

Deprecated

🚫 Do not use this client. It has been deprecated. Use the nats.ex elixir client instead.

Original Content

Elixir style documentation is located here

Getting Started

The framework requires Elixir 1.2.2 or above. To use it in your project, add the following to your mix.exs:

defp deps do
    # for github
    [{:nats, git: "https://github.com/nats-io/elixir-nats.git"}]
    # for hex (forthcoming)
    [{:natsio, "~> 0.1.6"}]
end

To build and/or test from sources

Run the test servers:

./test/run-test-servers.sh

Clone, fork or pull this repository. And then:

$ mix deps.get
$ mix compile
$ mix test

To run the examples:

$ mix run examples/sub.exs
$ mix run examples/pub.exs

The default NATS configuration looks for a gnatsd instance running on the default port of 4222 on 127.0.0.1.

You can override the configuration by passing a map to Client.start_link. For example:

  alias Nats.Client
  
  nats_conf = %{host: "some-host", port: 3222,
                tls_required: true,
                auth: %{ user: "some-user", pass: "some-pass"}}
  {:ok, ref} = Client.start_link(nats_conf)
  Client.pub(ref, "subject", "hello NATS world!")

The framework leverages the standard logger, by default only errors are logged. To view additional logging, update your config/config.exs:

use Mix.Config

# debug will log most everything
# info prints connection lifecycle events
# error prints errors
config :logger, level: :debug

Status

Most NATS related capabilities are in place: publishing, subscribing, tls, authorization.

Elixir Application, supervisor/monitor and environment support needs improved

Documentation is minimal. For now:

$ mix docs
$ open docs/index.html
$ cat examples/*.exs

Release Library

Bump version in mix.exs:

  ...

  @version "0.1.6"

  ...

As an administrator in the natsio hex package:

mix hex.publish

License

License

Copyright 2016 Apcera Inc. All rights reserved.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].