1
- # NATS.js - A [ NATS] ( http://nats.io ) client for JavaScript
1
+ # NATS.js - The JavaScript clients for [ NATS] ( http://nats.io )
2
2
3
3
[ ![ License] ( https://img.shields.io/badge/Licence-Apache%202.0-blue.svg )] ( ./LICENSE )
4
4
![ Test NATS.deno] ( https://github.com/nats-io/nats.deno/workflows/NATS.deno/badge.svg )
5
5
[ ![ Coverage Status] ( https://coveralls.io/repos/github/nats-io/nats.deno/badge.svg?branch=main )] ( https://coveralls.io/github/nats-io/nats.deno?branch=main )
6
6
7
- This repository hosts NATS clients for JavaScript runtimes, including:
7
+ Welcome to the new NATS.js repository! Beginning with the v3 release of the
8
+ JavaScript clients, the NATS.js repository reorganizes the NATS JavaScript
9
+ client libraries into a formal mono-repo.
10
+
11
+ This repository hosts native runtime support ("transports") for:
8
12
9
13
- Deno
10
14
- Node/Bun
11
15
- Browsers (W3C websocket)
12
16
13
- The repository is a mono-repo which the various runtime transports and a set of
14
- common modules (libraries) that shape the transports into a NATS client.
15
-
16
- Previous versions of the NATS clients merged the specific transport
17
- functionality (runtime) with the "NATS Base Client", the library providing the
18
- APIs to interact with the NATS server.
17
+ A big change with the v3 clients is that the "nats-base-client" which implements
18
+ all the runtime agnostic functionality of the clients, is now split into several
19
+ modules. This split simplify the initial user experience as well as the
20
+ development and evolution of the current functionality.
19
21
20
- In order to be more flexible and allow the ecosystem to more easily grow the
21
- basic functionality has been split into 5 modules:
22
+ The new modules are:
22
23
23
24
- [ Core] ( core/README.md ) which implements basic NATS core functionality
24
25
- [ JetStream] ( jetstream/README.md ) which implements JetStream functionality
@@ -28,37 +29,36 @@ basic functionality has been split into 5 modules:
28
29
- [ Services] ( obj/README.md ) which implements a framework for building NATS
29
30
services
30
31
31
- The above modules provide a different way for working with NATS. If you are
32
- getting started, perhaps you heard about the NATS KV and would incorporate it
33
- into your app. The KV module may be all that you need to get started. You will
34
- of course need a transport, but once you know how to make a connection to NATS,
35
- you can bypass much of the APIs and simply focus on the one that grabbed your
36
- attention. From there feel free to explore the different aspects of NATS. At
37
- some point, we are certain that your use most, if not all, of the modules.
38
-
39
- This allows basic clients to be smaller as features such as JetStream or KV are
40
- opt-in components, and also allowing each module to be versioned separately.
41
- This provides some additional developer comfort as it allows each module to
42
- specify its own [ semantic version] ( https://semver.org/ ) , and thus prevent
32
+ If you are getting started with NATS for the first time, we now have the
33
+ opportunity to have a simplified on-boarding experience that allows you to go
34
+ into one of our NATS technologies. Perhaps you heard about the NATS KV and would
35
+ like to incorporate it into your app. The KV module will shortcut a lot of
36
+ things for you. You will of course need a transport which will connect you to a
37
+ NATS server, but once you know how to create a connection you will be focusing
38
+ on a smaller subset of the APIs. From there, we are certain that you will
39
+ broaden your use of NATS into other areas.
40
+
41
+ Another reason for the change is that it has the potential to make your client a
42
+ bit smaller, and if versions change on a submodule that you don't use, you won't
43
+ be confronted with an upgrade choice. It also allows us to version more
44
+ strictly, and thus telegraph to you the effort or scope of changes and prevent
43
45
surprises when upgrading.
44
46
45
- The decoupling of the NATS client functionality from the actual runtime, also
46
- enables developers to write modules that can run on different runtimes provided
47
- they follow a pattern where a ` NatsConnection ` is used regardless of the actual
48
- runtime. For example, the JetStream module exposes a ` jetstream() ` function that
49
- will return a JetStream API that you use to interact with JetStream. The actual
50
- connection type is not important, and the library will work regardless of the
51
- runtime provided the runtime has the minimum support required by the library.
52
-
53
- [ // ] : # ( - [Node Transport]( ;) ; which implements a TCP transport for Node.js )
54
- [ // ] : # ( - [WebSocket Transport]( ;) ; which implements a W3C compatible websocket transport )
55
- [ // ] : # ( that can run in Deno, Node.js ( ; 22) ; , and Browsers. )
47
+ The decoupling of the NATS client functionality from a transport, also enables
48
+ developers to create new modules that can run all runtimes so long as they
49
+ follow a pattern where a ` NatsConnection ` (or some other standard interface) is
50
+ used as the basis of the module. For example, the JetStream module exposes a
51
+ ` jetstream() ` and ` jetstreamManager() ` functions that will return a JetStream
52
+ API that you use to interact with JetStream for creating resources or consuming
53
+ streams. The actual connection type is not important, and the library will work
54
+ regardless of the runtime provided the runtime has the minimum support required
55
+ by the library.
56
56
57
57
# Getting Started
58
58
59
59
If you are migrating from the legacy nats.deno or nats.js or nats.ws clients
60
- don't despair. Changes are very easy to on-board, and are all
61
- [ described here] ( migration.md ) .
60
+ don't despair. Changes are well documented and should be easy to locate and
61
+ implement, and are all [ described here] ( migration.md ) .
62
62
63
63
If you want to get started with NATS the best starting point is the transport
64
64
that matches the runtime you want to use:
@@ -69,7 +69,8 @@ that matches the runtime you want to use:
69
69
The module for the transport will tell you how to install it, and how to use it.
70
70
71
71
If you want to write a library that uses NATS under the cover, your starting
72
- point is likely [ Core] ( core/README.md ) . If data oriented it may be JetStream.
72
+ point is likely [ Core] ( core/README.md ) . If data oriented, it may be
73
+ [ JetStream] ( jetstream/README.md ) .
73
74
74
75
## Documentation
75
76
0 commit comments