toxiproxy-node-client icon indicating copy to clipboard operation
toxiproxy-node-client copied to clipboard

feat(api): make `Proxy` and `Toxic` classes immutable

Open dvag-gloeckner-daniel opened this issue 1 year ago • 3 comments

Make Proxy and Toxic classes immutable and remove cyclic dependencies.

Removing the cyclic dependencies between the objects has many benefits, for example JSON (de-)serialization of Axios errors now just works.

BREAKING CHANGE: Proxy and Toxic objects are now updated by posting an update to the server with the attributes to be updated. This is a breaking change because the update methods return a new instance of a Proxy or Toxic object instead of returning the mutated object.

dvag-gloeckner-daniel avatar Mar 14 '24 16:03 dvag-gloeckner-daniel

Sorry for making this a breaking change but I think the improvements justify the trouble :)

dvag-gloeckner-daniel avatar Mar 14 '24 16:03 dvag-gloeckner-daniel

Tests are green:

docker run --rm -p 8474:8474 ghcr.io/shopify/toxiproxy:latest

 npm run test

> [email protected] test
> jest --runInBand

 PASS  src/tests/ToxicTypes.spec.ts
 PASS  src/tests/Toxiproxy.spec.ts
 PASS  src/tests/Toxic.spec.ts
 PASS  src/tests/Proxy.spec.ts

Test Suites: 4 passed, 4 total
Tests:       18 passed, 18 total
Snapshots:   0 total
Time:        1.173 s, estimated 3 s

dvag-gloeckner-daniel avatar Mar 14 '24 16:03 dvag-gloeckner-daniel

@ihsw thanks a lot for merging the previous change. If we get this one merged I can close a dark fork of this very helpful project and we should be ready for the next years of maintenance work (happy to help) :)

dvag-gloeckner-daniel avatar Mar 14 '24 16:03 dvag-gloeckner-daniel

@dvag-gloeckner-daniel it is merged and published as [email protected]

ihsw avatar Jul 06 '24 21:07 ihsw