-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5ec968
commit 2512746
Showing
18 changed files
with
248 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
module github.com/khanzadimahdi/testproject | ||
|
||
go 1.20 | ||
go 1.22 | ||
|
||
toolchain go1.22.1 | ||
|
||
require ( | ||
github.com/gofrs/uuid v4.4.0+incompatible | ||
github.com/gofrs/uuid/v5 v5.0.0 | ||
github.com/golang-jwt/jwt/v5 v5.2.0 | ||
github.com/gofrs/uuid/v5 v5.2.0 | ||
github.com/golang-jwt/jwt/v5 v5.2.1 | ||
github.com/google/go-cmp v0.5.9 | ||
github.com/julienschmidt/httprouter v1.3.0 | ||
github.com/minio/minio-go/v7 v7.0.66 | ||
github.com/sethvargo/go-limiter v0.7.2 | ||
go.mongodb.org/mongo-driver v1.13.1 | ||
github.com/minio/minio-go/v7 v7.0.70 | ||
github.com/nats-io/nats.go v1.35.0 | ||
github.com/sethvargo/go-limiter v1.0.0 | ||
go.mongodb.org/mongo-driver v1.15.0 | ||
golang.org/x/crypto v0.23.0 | ||
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b | ||
) | ||
|
||
require ( | ||
github.com/dustin/go-humanize v1.0.1 // indirect | ||
github.com/goccy/go-json v0.10.3 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/google/uuid v1.5.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/klauspost/compress v1.17.4 // indirect | ||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/klauspost/compress v1.17.8 // indirect | ||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect | ||
github.com/minio/md5-simd v1.1.2 // indirect | ||
github.com/minio/sha256-simd v1.0.1 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/montanaflynn/stats v0.7.1 // indirect | ||
github.com/nats-io/nkeys v0.4.7 // indirect | ||
github.com/nats-io/nuid v1.0.1 // indirect | ||
github.com/rs/xid v1.5.0 // indirect | ||
github.com/sirupsen/logrus v1.9.3 // indirect | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect | ||
github.com/xdg-go/scram v1.1.2 // indirect | ||
github.com/xdg-go/stringprep v1.0.4 // indirect | ||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect | ||
golang.org/x/crypto v0.21.0 // indirect | ||
golang.org/x/net v0.21.0 // indirect | ||
golang.org/x/sync v0.6.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
github.com/youmark/pkcs8 v0.0.0-20240424034433-3c2c7870ae76 // indirect | ||
golang.org/x/net v0.25.0 // indirect | ||
golang.org/x/sync v0.7.0 // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
golang.org/x/text v0.15.0 // indirect | ||
gopkg.in/ini.v1 v1.67.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package nats | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/nats-io/nats.go" | ||
"github.com/nats-io/nats.go/jetstream" | ||
) | ||
|
||
func Connect() { | ||
nc, err := nats.Connect("nats:4222") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
js, _ := jetstream.New(nc) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
defer cancel() | ||
|
||
// get existing stream handle | ||
stream, _ := js.Stream(ctx, "foo") | ||
|
||
// retrieve consumer handle from a stream | ||
cons, _ := stream.Consumer(ctx, "cons") | ||
|
||
// consume messages from the consumer in callback | ||
cc, _ := cons.Consume(func(msg jetstream.Msg) { | ||
fmt.Println("Received jetstream message: ", string(msg.Data())) | ||
msg.Ack() | ||
}) | ||
//time.Millisecond | ||
defer cc.Stop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.