Coder Social home page Coder Social logo

anikeshk / aerospike-boolean-example Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4 KB

This is an experiment on how changing dependency versions can break your codebase. It uses the aerospike npm module as an example.

Home Page: https://anikeshk.com/breaking-changes-breaking-projects

Dockerfile 5.62% JavaScript 94.38%
breaking-changes docker npm

aerospike-boolean-example's Introduction

aerospike-boolean-example

This is an experiment on how changing dependency versions can break your codebase.

You can read the full article here - https://anikeshk.com/breaking-changes-breaking-projects

This experiment targets the aerospike Node.js module version 3.16.3, which introduced the boolean datatype for the Map datatype. Follow the instructions below to run this experiment yourself!

Pre-Requisites

  1. Install Docker from here.

Instructions

  1. Clone this repository and go to the folder.
git clone https://github.com/anikeshk/aerospike-boolean-example.git
  1. Create a docker network to connect the Aerospike and the Node.js script.
docker network create nodejs-aero
  1. Pull and start the Aerospike docker image.
docker pull aerospike:4.9.0.10
docker run --rm -tid --name aerospike --network nodejs-aero -p 3000:3000 -p 3001:3001 -p 3002:3002 aerospike:4.9.0.10

Note: We are using Aerospike server version 4.9.0.10 as this code was tested only with this server version.

  1. Connect to aql using the docker exec command.
docker exec -it <container id> aql

Note: You can get the container id by using the docker ps command.

  1. Switch to a new terminal. Go to the cloned repository. Build the image to use the [email protected] Node.js library.
cd aerospike-boolean-example
docker build -t aerospike-boolean-example:1.0 .
  1. Run this image and check the results.
docker run --network nodejs-aero aerospike-boolean-example:1.0

The output should be something like this:

Connection to Aerospike cluster succeeded!
User data stored!
User data fetched! {"age":21,"gender":"male","food":{"pizza":0,"burger":1,"taco":1}}
  1. Check aql for the same entry:
aql> select * from test.users where PK="tom"
+-------+-----+--------+------------------------------------------+
| PK    | age | gender | food                                     |
+-------+-----+--------+------------------------------------------+
| "tom" | 21  | "male" | MAP('{"pizza":0, "burger":1, "taco":1}') |
+-------+-----+--------+------------------------------------------+
1 row in set (0.000 secs)

In both the output from the script and aql, you can see Aerospike has stored the boolean values as 1 or 0 in the Map, depending if the choice is true or false.

  1. Delete the entry from the database.
aql> delete from test.users where PK="tom"
OK, 1 record affected.
  1. Change the aerospike version in the package.json to 3.16.3 using any editor.
{
  ...
  "dependencies": {
    "aerospike": "3.16.3"
  }
}
  1. Re-build the image using a different tag.
docker build -t aerospike-boolean-example:2.0 .
  1. Run this image and check the results.
docker run --network nodejs-aero aerospike-boolean-example:2.0

The output should be something like this:

Connection to Aerospike cluster succeeded!
User data stored!
User data fetched! {"age":21,"gender":"male","food":{"pizza":false,"burger":true,"taco":true}}
  1. Check aql for the same entry:
aql> select * from test.users where PK="tom"
+-------+-----+--------+------------------------------------------+
| PK    | age | gender | food                                     |
+-------+-----+--------+------------------------------------------+
| "tom" | 21  | "male" | MAP('{"pizza":0, "burger":1, "taco":1}') |
+-------+-----+--------+------------------------------------------+
1 row in set (0.000 secs)

This time in aql the values are stored as 1 or 0, but the script outputs true or false. The datatype of the output has changed!

  1. Stop and remove the Aerospike docker image.
docker rm -f <container-id>
  1. Delete the network created earlier.
docker network rm nodejs-aero

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.