Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ocm-engine
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
svdh
ocm-engine
Commits
d6b7b55a
Unverified
Commit
d6b7b55a
authored
1 year ago
by
Zdravko Iliev
Browse files
Options
Downloads
Patches
Plain Diff
fix: fix stream already exists
parent
3294ed43
No related branches found
No related tags found
1 merge request
!31
ci: issuer doesn't see any new connections in GET /connections or GET /connections/:id
Pipeline
#64822
canceled with stage
in 52 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/nats/src/base.nats.service.ts
+16
-1
16 additions, 1 deletion
libs/nats/src/base.nats.service.ts
libs/nats/src/consumer.nats.service.ts
+2
-2
2 additions, 2 deletions
libs/nats/src/consumer.nats.service.ts
with
18 additions
and
3 deletions
libs/nats/src/base.nats.service.ts
+
16
−
1
View file @
d6b7b55a
...
...
@@ -7,6 +7,7 @@ import {
JetStreamManager
,
JSONCodec
,
NatsConnection
,
NatsError
,
RetentionPolicy
,
StorageType
,
StreamConfig
,
...
...
@@ -66,7 +67,7 @@ export class NatsBaseService {
this
.
jsClient
=
this
.
client
.
jetstream
();
this
.
jsm
=
await
this
.
client
.
jetstreamManager
();
await
this
.
jsm
.
streams
.
add
(
this
.
streamConfig
);
await
this
.
registerStream
(
this
.
streamConfig
);
},
{
retries
:
5
,
...
...
@@ -89,4 +90,18 @@ export class NatsBaseService {
disconnect
=
()
=>
{
return
this
.
client
.
close
();
};
private
registerStream
=
async
(
sconfig
:
StreamConfig
)
=>
{
try
{
return
await
this
.
jsm
.
streams
.
add
(
sconfig
);
}
catch
(
e
)
{
this
.
logger
.
log
(
JSON
.
stringify
(
e
,
null
,
2
));
if
(
e
instanceof
NatsError
&&
e
.
api_error
?.
err_code
===
10065
)
{
return
await
this
.
jsm
.
streams
.
get
(
sconfig
.
name
);
}
throw
new
Error
(
`RegisterStream failed.`
);
}
};
}
This diff is collapsed.
Click to expand it.
libs/nats/src/consumer.nats.service.ts
+
2
−
2
View file @
d6b7b55a
...
...
@@ -38,8 +38,8 @@ export class ConsumerService extends NatsBaseService {
return
this
.
jsClient
.
consumers
.
get
(
stream
,
consumerConfig
.
name
);
}
catch
(
error
)
{
if
(
error
instanceof
NatsError
&&
error
.
api_error
?.
err_
code
===
10065
)
{
this
.
logger
.
log
(
"
Stream
already exists
"
);
if
(
error
instanceof
NatsError
&&
error
.
code
===
"
409
"
)
{
this
.
logger
.
log
(
"
Consumer
already exists
"
);
return
this
.
jsClient
.
consumers
.
get
(
stream
,
consumerConfig
.
name
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment