Skip to content

Commit

Permalink
autodetect Redis type when using "rediss://" uri as discoverer
Browse files Browse the repository at this point in the history
add test for redis ssl uri
  • Loading branch information
Freezystem committed Nov 21, 2023
1 parent 6a58b17 commit d249c27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/registry/discoverers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function resolve(opt) {
let DiscovererClass = getByName(opt);
if (DiscovererClass) return new DiscovererClass();

if (opt.startsWith("redis://")) return new Discoverers.Redis(opt);
if (opt.startsWith("redis://") || opt.startsWith("rediss://"))
return new Discoverers.Redis(opt);

if (opt.startsWith("etcd3://")) return new Discoverers.Etcd3(opt);

Expand Down
6 changes: 6 additions & 0 deletions test/unit/registry/discoverers/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ describe("Test Discoverers resolver", () => {
expect(discoverer.opts.redis).toEqual("redis://redis-server:6379");
});

it("should resolve Redis reporter from SSL connection string", () => {
const discoverer = Discoverers.resolve("rediss://redis-server:6379");
expect(discoverer).toBeInstanceOf(Discoverers.Redis);
expect(discoverer.opts.redis).toEqual("rediss://redis-server:6379");
});

it("should resolve Redis discoverer from obj", () => {
const options = { heartbeatInterval: 8 };
const discoverer = Discoverers.resolve({ type: "Redis", options });
Expand Down

0 comments on commit d249c27

Please sign in to comment.