Module: NATS

Defined in:
lib/nats.rb,
lib/nats/nuid.rb,
lib/nats/io/kv.rb,
lib/nats/io/msg.rb,
lib/nats/io/client.rb,
lib/nats/io/errors.rb,
lib/nats/io/kv/api.rb,
lib/nats/io/parser.rb,
lib/nats/io/version.rb,
lib/nats/io/jetstream.rb,
lib/nats/io/kv/errors.rb,
lib/nats/io/kv/manager.rb,
lib/nats/io/jetstream/js.rb,
lib/nats/io/subscription.rb,
lib/nats/io/jetstream/api.rb,
lib/nats/io/jetstream/msg.rb,
lib/nats/io/jetstream/errors.rb,
lib/nats/io/jetstream/js/sub.rb,
lib/nats/io/kv/bucket_status.rb,
lib/nats/io/jetstream/manager.rb,
lib/nats/io/jetstream/msg/ack.rb,
lib/nats/io/jetstream/js/config.rb,
lib/nats/io/jetstream/js/header.rb,
lib/nats/io/jetstream/js/status.rb,
lib/nats/io/jetstream/msg/metadata.rb,
lib/nats/io/jetstream/msg/ack_methods.rb,
lib/nats/io/jetstream/pull_subscription.rb,
lib/nats/io/jetstream/push_subscription.rb

Overview

Copyright 2021 The NATS Authors Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: IO, Protocol, Status Classes: Client, JetStream, KeyValue, MonotonicTime, Msg, NUID, Subscription

Constant Summary collapse

NANOSECONDS =
1_000_000_000
Timeout =

Timeout is raised when the client gives up waiting for a response from a service.

::NATS::IO::Timeout
Error =

Error is any error thrown by the client library.

::NATS::IO::Error

Class Method Summary collapse

Class Method Details

.connect(uri = nil, opts = {}) ⇒ NATS::Client

NATS.connect creates a connection to the NATS Server.

Examples:

require 'nats'
nc = NATS.connect("demo.nats.io")
nc.publish("hello", "world")
nc.close

Parameters:

  • uri (String) (defaults to: nil)

    URL endpoint of the NATS Server or cluster.

  • opts (Hash) (defaults to: {})

    Options to customize the NATS connection.

Returns:



48
49
50
51
52
53
# File 'lib/nats/io/client.rb', line 48

def connect(uri=nil, opts={})
  nc = NATS::Client.new
  nc.connect(uri, opts)

  nc
end