Skip to content

Commit f8a24a3

Browse files
authored
change(obj): changed Svc to Svcm to align with Kvm, Objm, etc (#169)
fix(obj): changed test references to jsr bundles pointing wrong transport bundle Signed-off-by: Alberto Ricart <[email protected]>
1 parent 7ece568 commit f8a24a3

10 files changed

+51
-53
lines changed

Diff for: migration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ instance of Svc, which allows you to `add()` a service and create a
222222
ServiceClient `client(nc)`:
223223
224224
```typescript
225-
const svc = new Svc(nc);
225+
const svc = new Svcm(nc);
226226
const service = await svc.add({
227227
name: "max",
228228
version: "0.0.1",
@@ -234,4 +234,4 @@ const service = await svc.add({
234234
```
235235
236236
- `services` property has been removed. Install and import the `Services`
237-
library, and call `services(nc: NatsConnection)`
237+
library, and call `Svcm(nc: NatsConnection)`

Diff for: services/deno.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nats-io/services",
3-
"version": "3.0.0-21",
3+
"version": "3.0.0-22",
44
"exports": {
55
".": "./src/mod.ts",
66
"./internal": "./src/internal_mod.ts"

Diff for: services/examples/01_services.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { connect } from "jsr:@nats-io/[email protected]";
17-
18-
import type { QueuedIterator } from "jsr:@nats-io/[email protected]";
16+
import { connect, type QueuedIterator } from "jsr:@nats-io/transport-deno";
1917

2018
import {
2119
ServiceError,
2220
ServiceErrorCodeHeader,
2321
ServiceErrorHeader,
24-
Svc,
22+
Svcm,
2523
} from "../src/mod.ts";
2624
import type { ServiceMsg, ServiceStats } from "../src/mod.ts";
2725
import { assertEquals } from "jsr:@std/assert";
@@ -42,7 +40,7 @@ const statsHandler = (): Promise<unknown> => {
4240
};
4341

4442
// create a service - using the statsHandler
45-
const svc = new Svc(nc);
43+
const svc = new Svcm(nc);
4644
const service = await svc.add({
4745
name: "max",
4846
version: "0.0.1",
@@ -139,13 +137,13 @@ function decoder(r: ServiceMsg): Promise<number[]> {
139137
// Now we switch gears and look at a client making a request:
140138

141139
// we call the service without any payload and expect some errors
142-
await nc.request("max").then((r) => {
140+
await nc.request("max").then((r: ServiceMsg) => {
143141
// errors are really these two headers set on the message
144142
assertEquals(r.headers?.get(ServiceErrorHeader), "Bad JSON");
145143
assertEquals(r.headers?.get(ServiceErrorCodeHeader), "400");
146144
});
147145
// call it with an empty array also expecting an error response
148-
await nc.request("max", JSON.stringify([])).then((r) => {
146+
await nc.request("max", JSON.stringify([])).then((r: ServiceMsg) => {
149147
// Here's an alternative way of checking if the response is an error response
150148
assertEquals(ServiceError.isServiceError(r), true);
151149
const se = ServiceError.toServiceError(r);
@@ -154,7 +152,7 @@ await nc.request("max", JSON.stringify([])).then((r) => {
154152
});
155153

156154
// call it with valid arguments
157-
await nc.request("max", JSON.stringify([1, 10, 100])).then((r) => {
155+
await nc.request("max", JSON.stringify([1, 10, 100])).then((r: ServiceMsg) => {
158156
// no error headers
159157
assertEquals(ServiceError.isServiceError(r), false);
160158
// and the response is on the payload, so we process the JSON we

Diff for: services/examples/02_multiple_endpoints.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
*/
1515

1616
import { connect } from "jsr:@nats-io/[email protected]";
17-
import { ServiceError, Svc } from "../src/mod.ts";
17+
import { ServiceError, Svcm } from "../src/mod.ts";
1818
import type { ServiceMsg } from "../src/mod.ts";
1919

2020
// connect to NATS on demo.nats.io
2121
const nc = await connect({ servers: ["demo.nats.io"] });
2222

2323
// create a service - using the statsHandler and decoder
24-
const svc = new Svc(nc);
24+
const svc = new Svcm(nc);
2525
const calc = await svc.add({
2626
name: "calc",
2727
version: "0.0.1",

Diff for: services/examples/03_bigdata.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
*/
1515

1616
import { connect } from "jsr:@nats-io/[email protected]";
17-
import { Svc } from "../src/mod.ts";
17+
import { Svcm } from "../src/mod.ts";
1818
import { humanizeBytes } from "./03_util.ts";
1919
import type { DataRequest } from "./03_util.ts";
2020

2121
const nc = await connect({ servers: "demo.nats.io" });
22-
const svc = new Svc(nc);
22+
const svc = new Svcm(nc);
2323
const srv = await svc.add({
2424
name: "big-data",
2525
version: "0.0.1",

Diff for: services/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nats-io/services",
3-
"version": "3.0.0-21",
3+
"version": "3.0.0-22",
44
"files": [
55
"lib/",
66
"LICENSE",

Diff for: services/src/internal_mod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export {
3030
ServiceVerb,
3131
} from "./types.ts";
3232

33-
export class Svc {
33+
export class Svcm {
3434
nc: NatsConnection;
3535

3636
constructor(nc: NatsConnection) {

Diff for: services/src/mod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export {
2323
ServiceErrorHeader,
2424
ServiceResponseType,
2525
ServiceVerb,
26-
Svc,
26+
Svcm,
2727
} from "./internal_mod.ts";

Diff for: services/tests/service-check.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { cli } from "https://deno.land/x/[email protected]/mod.ts";
17-
import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-4";
16+
import { cli } from "jsr:@aricart/cobra";
17+
import { connect } from "@nats-io/transport-deno";
1818
import { collect, parseSemVer } from "@nats-io/nats-core/internal";
1919

2020
import type { NatsConnection } from "@nats-io/nats-core/internal";
@@ -24,7 +24,7 @@ import {
2424
ServiceError,
2525
ServiceResponseType,
2626
ServiceVerb,
27-
Svc,
27+
Svcm,
2828
} from "../src/mod.ts";
2929

3030
import type { ServiceClientImpl } from "../src/serviceclient.ts";
@@ -136,7 +136,7 @@ async function checkPing(nc: NatsConnection, name: string) {
136136
}
137137

138138
async function invoke(nc: NatsConnection, name: string): Promise<void> {
139-
const svc = new Svc(nc);
139+
const svc = new Svcm(nc);
140140
const sc = svc.client();
141141
const infos = await collect(await sc.info(name));
142142

@@ -199,7 +199,7 @@ async function check<T extends ServiceIdentity>(
199199
}
200200
};
201201

202-
const svc = new Svc(nc);
202+
const svc = new Svcm(nc);
203203
const sc = svc.client() as ServiceClientImpl;
204204
// all
205205
let responses = filter(

0 commit comments

Comments
 (0)