Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v2.11 branch #1698

Merged
merged 66 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
04149cd
[IMPROVED] Performance of respToken (#1575)
piotrpio Feb 29, 2024
f0712b8
[IMPROVED] Bind Object Store bucket stream when getting object. (#1568)
dmitryabramov-f3 Mar 3, 2024
0d49e3f
[IMPROVED] Bind Streams in Object Store Watchers (#1578)
Jarema Mar 4, 2024
dc20b77
[ADDED] StatusChanged for core and js subscriptions (#1570)
piotrpio Mar 11, 2024
e590ddc
[IMPROVED] Fixed typos in comments (#1581)
paoloteti Mar 12, 2024
0b5cfb5
[IMPROVED] Missing section in jetstream readme ToC (#1557)
piotrpio Mar 12, 2024
9daa647
Release v1.33.1 (#1558)
piotrpio Mar 12, 2024
39af9e7
[IMPROVED] Fetch and FetchBatch for draining and closed subscriptions…
piotrpio Mar 18, 2024
d2ec2df
[FIXED] Incorrect stopErr used
ramonberrutti Mar 18, 2024
4df3a8d
[IMPROVED] Add test checking if client reconnects after jwt expires (…
piotrpio Mar 19, 2024
a8e2d7e
Release v1.34.0 (#1587)
piotrpio Mar 20, 2024
cbca19e
[FIXED] Race condition in Fetch and FetchBatch when using heartbeats …
piotrpio Apr 2, 2024
077c377
[FIXED] Async publish error handling on disconnect (#1592)
piotrpio Apr 2, 2024
53dabbb
Release v1.34.1 (#1602)
piotrpio Apr 3, 2024
f0d626a
[IMPROVED] Add note to readme about backwards compatibility (#1604)
piotrpio Apr 5, 2024
7c3cc6b
[IMPROVED] Documentation for AccountInfo and ErrJetStreamNotEnabled (…
piotrpio Apr 5, 2024
ea1af24
[ADDED] API to read Reply subject from `micro.Request` (#1589)
mcosta74 Apr 9, 2024
863a593
Remove unnecessary allocations from `readMIMEHeader` (#1609)
neilalexander Apr 15, 2024
2b7a450
[FIXED] KV discard policy in jetstream pkg (#1616)
piotrpio Apr 17, 2024
0f7ce69
[FIXED] Add discard policy repair logic in CreateKeyValue (#1617)
piotrpio Apr 18, 2024
0e8ddbc
[FIXED] Validation in jetstream and KV (#1613)
piotrpio Apr 22, 2024
b688af2
[IMPROVED] Example code in jetstream/README.md (#1595)
jnmoyne Apr 22, 2024
9405da3
[FIXED] Call ConnectedCB with RetryOnFailedConnect when initial conn …
piotrpio Apr 22, 2024
d1dcce8
[UPDATED] Added json tags to KeyValueConfig struct to behave consiste…
pricelessrabbit May 16, 2024
bbcf3ae
[IMPROVED] Added documentation for StreamConfig in jsm.go (#1625)
kazmerdome May 16, 2024
f2dceaf
[ADDED] Force reconnect (#1624)
piotrpio May 17, 2024
df6d4dd
Release v1.35.0 (#1632)
piotrpio May 17, 2024
e2c927c
[FIXED] Object Store compatibility tests (#1637)
Jarema May 24, 2024
1dbfbf3
[IMPROVED] Fix MaxAckPending default value comment unit typo (#1639)
agcom May 27, 2024
eae4267
[IMPROVED] Fix typo inconnect (#1638)
agcom May 28, 2024
939bb0a
[FIXED] Set OptStartSeq correctly in OrderedConsumerConfig (#1644)
piotrpio Jun 11, 2024
d2c6d3b
[IMPROVED] Ordered consumer creation and initial config settings (#1645)
piotrpio Jun 13, 2024
706367b
[IMPROVED] Handle error and reset ordered consumer in Messages() (#1646)
piotrpio Jun 13, 2024
6a98036
[FIXED] Remove `ConsumerInfo()` calls in `Consume()` and `Messages()`…
piotrpio Jun 13, 2024
6c3be45
Release v1.36.0 (#1647)
piotrpio Jun 14, 2024
8ce6a84
[IMPROVED] Trim trailing slash if set on server address which causes …
josephwoodward Jul 17, 2024
2c8ed8c
[IMPROVED] JetStream package docs visibility (#1675)
Jarema Jul 22, 2024
5cc6e1b
Deprecate encoded connections (#1674)
piotrpio Jul 23, 2024
c4c5dad
[FIXED] Deadlock when accessing subscriptions map on consumer (#1671)
piotrpio Jul 25, 2024
93a6d1b
Update docker for compatibility tests (#1688)
Jarema Jul 29, 2024
ad0b622
[FIXED] Panic in ordered consumer (#1686)
piotrpio Aug 1, 2024
5efa0f8
Correct README.md formatting (#1692)
patrick-othmer Aug 5, 2024
13fcdc6
[FIXED] Setting deliver policy in Fetch() for OrderedConsumer (#1693)
piotrpio Aug 7, 2024
77cc9aa
[FIXED] Change Fetch client timeout to a higher value (#1689)
piotrpio Aug 12, 2024
ecc563c
[ADDED] CleanupPublisher method for removing internal JetStream subsc…
piotrpio Aug 12, 2024
eca36a3
[ADDED] ConsumeContext.Closed() method for waiting for consume to be …
piotrpio Aug 13, 2024
f3b6df9
Release v1.37.0 (#1697)
piotrpio Aug 13, 2024
575c4b4
[IMPROVEMENT] Added client retry for async publish in legacy JetStrea…
pranavmehta94 Aug 14, 2024
52abeab
Revert "[ADDED] Pause and resume jetstream consumer (#1571)"
piotrpio Aug 15, 2024
81adeb0
[IMPROVED] Fix linter issues (#1700)
piotrpio Aug 16, 2024
606529e
[IMPROVED] Move CI to github actions (#1623)
piotrpio Sep 5, 2024
0307cd2
[IMPROVED] Use errors.New instead of fmt.Errorf where possible (#1707)
canack Sep 19, 2024
9c04321
[ADDED] UserInfoHandler for dynamically setting user/password (#1713)
piotrpio Sep 20, 2024
096fa7f
[IMPROVED] Remove travis from ci and fix build badge (#1716)
piotrpio Sep 20, 2024
2c0d38b
[FIXED] Invalid response schema in README for Service API (#1720)
piotrpio Sep 24, 2024
0653a74
[IMPROVED] Correct the description of CreateStream to indicate it is …
jnmoyne Oct 3, 2024
aeb7c7f
[IMPROVED] Automate updating dependencies report (#1660)
Jarema Oct 3, 2024
84dbd44
[IMPROVED] Mention TTL in the Update function (#1727)
fmontorsi-equinix Oct 18, 2024
08ae14b
[FIXED] Closing connection on max subscriptions exceeded (#1709)
piotrpio Oct 18, 2024
a3c413a
[FIXED] Publish async not closing done and stall channels after faile…
piotrpio Nov 18, 2024
0179ee6
[FIXED] Invalid fetch sequence in ordered consumer Fetch and Next aft…
piotrpio Nov 18, 2024
05a0589
[ADDED] WatchFiltered method on KV (#1739)
piotrpio Nov 21, 2024
ee79a84
[FIXED] Do not overwrite ordered consumer deliver policy if start tim…
piotrpio Nov 29, 2024
1a2847d
[IMPROVED] Update installation commands (#1745)
alexbozhenko Dec 5, 2024
cbc8c41
[ADDED] Pause and resume jetstream consumer (#1571)
yordis Mar 15, 2024
84608cc
Update server version for tests
piotrpio Aug 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: ci
on:
push:
branches:
- main
pull_request:
release:
types: [published]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Install deps
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
go get -t ./...
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/client9/misspell/cmd/misspell@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

- name: Run linters
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
$(exit $(go fmt -modfile=go_test.mod ./... | wc -l))
go vet -modfile=go_test.mod ./...
GOFLAGS="-mod=mod -modfile=go_test.mod" staticcheck ./...
find . -type f -name "*.go" | xargs misspell -error -locale US
golangci-lint run --timeout 5m0s ./jetstream/...

test:
runs-on: ubuntu-latest

strategy:
matrix:
go: [ "1.22", "1.23" ]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Install deps
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
go install github.com/mattn/goveralls@latest
go install github.com/wadey/gocovmerge@latest

- name: Test and coverage
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
go test -modfile=go_test.mod -v -run=TestNoRace -p=1 ./... --failfast -vet=off
if [ "${{ matrix.go }}" = "1.23" ]; then
./scripts/cov.sh CI
else
go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing
fi

- name: Coveralls
if: matrix.go == '1.23'
uses: coverallsapp/github-action@v2
with:
file: acc.out
61 changes: 61 additions & 0 deletions .github/workflows/dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: License Check

on:
push:
paths:
- 'go.mod'
branches:
- main

jobs:
license-check:
runs-on: ubuntu-latest

env:
BRANCH_NAME: update-report-branch-${{ github.run_id }}

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Install go-licenses
run: go install github.com/google/go-licenses@latest
# We need this step because of test dependencies and how they are handled in nats.go
- name: Run go mod tidy
run: go mod tidy
- name: Run license check
run: go-licenses report ./... --template dependencies.tpl > dependencies.md

- name: Configure git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'

- name: Check for changes
id: git_diff
run: |
git fetch
git diff --exit-code dependencies.md || echo "has_changes=true" >> $GITHUB_ENV

- name: Commit changes
if: env.has_changes == 'true'
run: |
git checkout -b "$BRANCH_NAME"
git add dependencies.md
git commit -m "Update dependencies.md"
git push -u origin "$BRANCH_NAME"

- name: Create Pull Request
if: env.has_changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --title "Update dependencies.md" --body "This PR updates the dependencies report" --head "$BRANCH_NAME" --base main

27 changes: 27 additions & 0 deletions .github/workflows/latest-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test nats-server@main
on:
schedule:
- cron: "30 8 * * *"

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Get latest server
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
go get -modfile go_test.mod github.com/nats-io/nats-server/v2@main

- name: Test
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
go test -modfile=go_test.mod -v -run=TestNoRace -p=1 ./... --failfast -vet=off
go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

135 changes: 23 additions & 112 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ A [Go](http://golang.org) client for the [NATS messaging system](https://nats.io
[License-Image]: https://img.shields.io/badge/License-Apache2-blue.svg
[ReportCard-Url]: https://goreportcard.com/report/github.com/nats-io/nats.go
[ReportCard-Image]: https://goreportcard.com/badge/github.com/nats-io/nats.go
[Build-Status-Url]: https://travis-ci.com/github/nats-io/nats.go
[Build-Status-Image]: https://travis-ci.com/nats-io/nats.go.svg?branch=main
[Build-Status-Url]: https://github.com/nats-io/nats.go/actions
[Build-Status-Image]: https://github.com/nats-io/nats.go/actions/workflows/ci.yaml/badge.svg?branch=main
[GoDoc-Url]: https://pkg.go.dev/github.com/nats-io/nats.go
[GoDoc-Image]: https://img.shields.io/badge/GoDoc-reference-007d9c
[Coverage-Url]: https://coveralls.io/r/nats-io/nats.go?branch=main
Expand All @@ -19,25 +19,14 @@ A [Go](http://golang.org) client for the [NATS messaging system](https://nats.io
## Installation

```bash
# Go client
go get github.com/nats-io/nats.go/
# To get the latest released Go client:
go get github.com/nats-io/nats.go@latest

# Server
go get github.com/nats-io/nats-server
```

When using or transitioning to Go modules support:

```bash
# Go client latest or explicit version
go get github.com/nats-io/nats.go/@latest
go get github.com/nats-io/nats.go/@v1.33.0
# To get a specific version:
go get github.com/nats-io/[email protected]

# For latest NATS Server, add /v2 at the end
go get github.com/nats-io/nats-server/v2

# NATS Server v1 is installed otherwise
# go get github.com/nats-io/nats-server
# Note that the latest major version for NATS Server is v2:
go get github.com/nats-io/nats-server/v2@latest
```

## Basic Usage
Expand Down Expand Up @@ -93,11 +82,13 @@ nc.Close()
```

## JetStream
[![JetStream API Reference](https://pkg.go.dev/badge/github.com/nats-io/nats.go/jetstream.svg)](https://pkg.go.dev/github.com/nats-io/nats.go/jetstream)

JetStream is the built-in NATS persistence system. `nats.go` provides a built-in
API enabling both managing JetStream assets as well as publishing/consuming
persistent messages.


### Basic usage

```go
Expand Down Expand Up @@ -134,60 +125,6 @@ To find more information on `nats.go` JetStream API, visit
The service API (`micro`) allows you to [easily build NATS services](micro/README.md) The
services API is currently in beta release.

## Encoded Connections

```go

nc, _ := nats.Connect(nats.DefaultURL)
c, _ := nats.NewEncodedConn(nc, nats.JSON_ENCODER)
defer c.Close()

// Simple Publisher
c.Publish("foo", "Hello World")

// Simple Async Subscriber
c.Subscribe("foo", func(s string) {
fmt.Printf("Received a message: %s\n", s)
})

// EncodedConn can Publish any raw Go type using the registered Encoder
type person struct {
Name string
Address string
Age int
}

// Go type Subscriber
c.Subscribe("hello", func(p *person) {
fmt.Printf("Received a person: %+v\n", p)
})

me := &person{Name: "derek", Age: 22, Address: "140 New Montgomery Street, San Francisco, CA"}

// Go type Publisher
c.Publish("hello", me)

// Unsubscribe
sub, err := c.Subscribe("foo", nil)
// ...
sub.Unsubscribe()

// Requests
var response string
err = c.Request("help", "help me", &response, 10*time.Millisecond)
if err != nil {
fmt.Printf("Request failed: %v\n", err)
}

// Replying
c.Subscribe("help", func(subj, reply string, msg string) {
c.Publish(reply, "I can help!")
})

// Close connection
c.Close();
```

## New Authentication (Nkeys and User Credentials)
This requires server with version >= 2.0.0

Expand Down Expand Up @@ -267,34 +204,6 @@ if err != nil {

```

## Using Go Channels (netchan)

```go
nc, _ := nats.Connect(nats.DefaultURL)
ec, _ := nats.NewEncodedConn(nc, nats.JSON_ENCODER)
defer ec.Close()

type person struct {
Name string
Address string
Age int
}

recvCh := make(chan *person)
ec.BindRecvChan("hello", recvCh)

sendCh := make(chan *person)
ec.BindSendChan("hello", sendCh)

me := &person{Name: "derek", Age: 22, Address: "140 New Montgomery Street"}

// Send via Go channels
sendCh <- me

// Receive via Go channels
who := <- recvCh
```

## Wildcard Subscriptions

```go
Expand Down Expand Up @@ -461,19 +370,21 @@ msg, err := nc.RequestWithContext(ctx, "foo", []byte("bar"))
sub, err := nc.SubscribeSync("foo")
msg, err := sub.NextMsgWithContext(ctx)

// Encoded Request with context
c, err := nats.NewEncodedConn(nc, nats.JSON_ENCODER)
type request struct {
Message string `json:"message"`
}
type response struct {
Code int `json:"code"`
}
req := &request{Message: "Hello"}
resp := &response{}
err := c.RequestWithContext(ctx, "foo", req, resp)
```

## Backwards compatibility

In the development of nats.go, we are committed to maintaining backward compatibility and ensuring a stable and reliable experience for all users. In general, we follow the standard go compatibility guidelines.
However, it's important to clarify our stance on certain types of changes:

- **Expanding structures:**
Adding new fields to structs is not considered a breaking change.

- **Adding methods to exported interfaces:**
Extending public interfaces with new methods is also not viewed as a breaking change within the context of this project. It is important to note that no unexported methods will be added to interfaces allowing users to implement them.

Additionally, this library always supports at least 2 latest minor Go versions. For example, if the latest Go version is 1.22, the library will support Go 1.21 and 1.22.

## License

Unless otherwise noted, the NATS source files are distributed
Expand Down
Loading
Loading