{"_id":"@dwwoelfel/subscriptions-lds","_rev":"3-f6bae957d2e4ebc548ba89f055ff5c85","name":"@dwwoelfel/subscriptions-lds","dist-tags":{"latest":"4.4.5-alpha.0"},"versions":{"4.4.3-alpha.0":{"publishConfig":{"access":"public"},"name":"@dwwoelfel/subscriptions-lds","version":"4.4.3-alpha.0","description":"Subscriptions plugin for PostGraphile using PostgreSQL logicial decoding","main":"dist/index.js","scripts":{"db:init":"dropdb --if-exists lds_test && createdb lds_test && psql -X1v ON_ERROR_STOP=1 -v VERBOSITY=verbose -f __tests__/schema.sql lds_test","test":"npm run db:init && jest -i","tslint":"prettier --list-different 'src/**/*' && tslint --config ../../tslint.json --project tsconfig.json","prepack":"tsc","watch":"tsc --watch"},"repository":{"type":"git","url":"git+ssh://git@github.com/graphile/graphile-engine.git"},"keywords":["pg","Postgres","plugin","PostgreSQL","logicial","decoding","logical","replication","changes","Graphile","PostGraphile"],"author":{"name":"Benjie Gillam","email":"code@benjiegillam.com"},"license":"MIT","bugs":{"url":"https://github.com/graphile/graphile-engine/issues"},"homepage":"https://github.com/graphile/graphile-engine/tree/master/packages/subscriptions-lds#readme","dependencies":{"@dwwoelfel/lds":"^4.4.3-alpha.0","@types/ws":"^6.0.1","ws":"^6.1.3"},"peerDependencies":{"@dwwoelfel/postgraphile-core":">4.3.1 <5"},"devDependencies":{"@types/jest":"^24.0.5","jest":"23.x","pg":">=6.5 <8","ts-jest":"^23.10.5","typescript":"^3.3.1"},"gitHead":"70990b98c55d184ff96b6a5f05a94853298ca9a2","_resolved":"","_integrity":"","_from":"file:dwwoelfel-subscriptions-lds-4.4.3-alpha.0.tgz","_id":"@dwwoelfel/subscriptions-lds@4.4.3-alpha.0","_npmVersion":"6.4.1","_nodeVersion":"11.0.0","_npmUser":{"name":"dww","email":"dwwoelfel@gmail.com"},"dist":{"integrity":"sha512-EqZjcFG0jj+b0kRYjQD3oyB+TF08IHOGaz8ri+/rwLUQYt6nadPXiDpJs8IuWPM8XLj3F7GILsadIKOwCO6XKw==","shasum":"f31e3c59bf38d1ea0bf79cf925d578d6719f35f9","tarball":"https://registry.npmjs.org/@dwwoelfel/subscriptions-lds/-/subscriptions-lds-4.4.3-alpha.0.tgz","fileCount":9,"unpackedSize":26208,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcgA+BCRA9TVsSAnZWagAA0TEP/RocQjmPyWKo6Cp1lWiE\nuCDto1BR4TuteVvwI8IK4JyspM3gK+wmk1Qfv1J07z1XenUR/9B8c4CFxZK/\n79bqBjzZt5GdJrRKSzWD1lePtDM5SfUuiqVIdcI/fJFpnqsZOEQofv7czuXe\nHLOQBhz6Uw1JBsgo0tOeGT6l2mr41ypwhlhHxCjGkpPpS4skkVKHAhdLGm5P\n+c9BrU3E9iVIkJSr2pgLRc53qiawahlAtToS7XoLvGPuHXLn1qG7ZPIr/EIG\nw7zb1wcuApTGeJ4WFtJ0KkDvDSGo1Ib5+apzar/UB//uyBYxr0WvTYrNlRm/\n9wrUgqtx9U5qwiV6Ost6x+jLU1UkWpy2PmbnoWm63wEI8e/NwOMkZZyFb6YD\nHJQrW1OcZeQOSCC+KA763DtWp4ScLvlf7miPXXTsMPZMOrU7VXaDZJphwigg\ntGaO/BuD2Wu00UHpkx3f/FFnBkkoCCxjd1LyvHFtPxX2wyTAsZ0h2G7RskWV\nAyYAzq+aocUydUh0/gcBCehKB+zDPrVBPkYnsSULrhAysoZg26o6KOo0R3te\n0eskFUkvo/fD7erXtduLijrQm+y+Ulp7USjxCV9/x98mOCjvQHoHRp/O2Fso\nkgIUqWxaMpSX69fxvAau3z+lt5f3JhtMWDCpYpteqC39sK33BHi8Lw2iQaDN\nSGZ6\r\n=BlLL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7dOWqIsv1QWEPvrYYUpZoqxV2LotKJdVzAYJFd/SDigIgRr+kA36H8/nExXYRTmH/LsXH5Oo4/EpNig2+y/AoxJg="}]},"maintainers":[{"name":"dww","email":"dwwoelfel@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/subscriptions-lds_4.4.3-alpha.0_1551896448968_0.7071783478226505"},"_hasShrinkwrap":false},"4.4.4-alpha.0":{"publishConfig":{"access":"public"},"name":"@dwwoelfel/subscriptions-lds","version":"4.4.4-alpha.0","description":"Subscriptions plugin for PostGraphile using PostgreSQL logicial decoding","main":"dist/index.js","scripts":{"db:init":"dropdb --if-exists lds_test && createdb lds_test && psql -X1v ON_ERROR_STOP=1 -v VERBOSITY=verbose -f __tests__/schema.sql lds_test","test":"npm run db:init && jest -i","tslint":"prettier --list-different 'src/**/*' && tslint --config ../../tslint.json --project tsconfig.json","prepack":"tsc","watch":"tsc --watch"},"repository":{"type":"git","url":"git+ssh://git@github.com/graphile/graphile-engine.git"},"keywords":["pg","Postgres","plugin","PostgreSQL","logicial","decoding","logical","replication","changes","Graphile","PostGraphile"],"author":{"name":"Benjie Gillam","email":"code@benjiegillam.com"},"license":"MIT","bugs":{"url":"https://github.com/graphile/graphile-engine/issues"},"homepage":"https://github.com/graphile/graphile-engine/tree/master/packages/subscriptions-lds#readme","dependencies":{"@dwwoelfel/lds":"^4.4.4-alpha.0","@types/ws":"^6.0.1","ws":"^6.1.3"},"peerDependencies":{"@dwwoelfel/postgraphile-core":">4.3.1 <5"},"devDependencies":{"@types/jest":"^24.0.5","jest":"23.x","pg":">=6.5 <8","ts-jest":"^23.10.5","typescript":"^3.3.1"},"gitHead":"a3818ddf26ef41d18331732d4da7faedc3cc4af8","_resolved":"","_integrity":"","_from":"file:dwwoelfel-subscriptions-lds-4.4.4-alpha.0.tgz","_id":"@dwwoelfel/subscriptions-lds@4.4.4-alpha.0","_npmVersion":"6.4.1","_nodeVersion":"11.0.0","_npmUser":{"name":"dww","email":"dwwoelfel@gmail.com"},"dist":{"integrity":"sha512-RonzTJtCGNWwI4B4rKSOgoQ+mVjB+8GYtdnlpNREJBgT8oC2IcuWzdPR61S5PaN/Yv0ImKso8cs7CqBxANh8JQ==","shasum":"81ec73082f17394de878398bec4b2fecd43d2bc8","tarball":"https://registry.npmjs.org/@dwwoelfel/subscriptions-lds/-/subscriptions-lds-4.4.4-alpha.0.tgz","fileCount":9,"unpackedSize":26208,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcgBR3CRA9TVsSAnZWagAAs0IQAIdNA6EAydFkPjv+vY28\nVSiiX1HHE7874QemrN64+k/UPQpGpvSpT725LshWj50iE9/mJ2XpTRid0bH3\nFmvano2+onfwvYoZgyjJq5YZ36tIbzvzEVIsZV6beIvFMWdQXfLK97wM8uTZ\n6FdzS/EXlJakkpUQk/CkGBnZJgS2ns13kx/WjJyNoBLsfMK9THxRMhc4+avE\nw+odyxHGJUUEFOVbRQzd2kGYNvJl+cfcKrlporKQEjj57/Z5A0NoQVyXCarc\ntbNBXeSlsz3DvL6g2w2Q1HqFMck5zWBvEAkIaG3jVY7KCCDpguz2TSJ7Z8Tn\n7YIxfqi/GnEUMEf3Y0SF0gcAuNVa5G2jvk/kqhd3e6mLIfBCch6lo361GgBf\nb2to5jysUTg/+CYwMg9TaUPxkfIfREdMnWz9Hp9/cMetVX0NV4Lq7xweBnFy\nnd3jRVaeJtUZUQiTjUN4X9TzQw0eGU6zJKDusPwoc8qA5SYtLenxYpgTQGGt\nYbAWtXADFmgN53jShNlhRDCIYA0UeKgZqz+zc0Y8sIHiQsB4InoCC8m+zc9H\nCoWlS0BC4PeP2JzzTU0533W+nhnVIw2FVa58nrE+vM2bhC5OaA9z5Ba4npDV\nJCjjoJp1HUsq9u1be8lB/gB1IvK/LNCNdaEG+q3CI9AZ/SYMw2wGtCI8june\n6dYw\r\n=uhXp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFvDuT+gIV4C87XteigJ/edH30eeA0kWh9YjBI71IHiyAiBZNcjiROcUPauBT4m0+kpHzMXBkWlEO7QUDu6nhC6mPg=="}]},"maintainers":[{"name":"dww","email":"dwwoelfel@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/subscriptions-lds_4.4.4-alpha.0_1551897719049_0.08994914379396857"},"_hasShrinkwrap":false},"4.4.5-alpha.0":{"publishConfig":{"access":"public"},"name":"@dwwoelfel/subscriptions-lds","version":"4.4.5-alpha.0","description":"Subscriptions plugin for PostGraphile using PostgreSQL logicial decoding","main":"dist/index.js","scripts":{"db:init":"dropdb --if-exists lds_test && createdb lds_test && psql -X1v ON_ERROR_STOP=1 -v VERBOSITY=verbose -f __tests__/schema.sql lds_test","test":"npm run db:init && jest -i","tslint":"prettier --list-different 'src/**/*' && tslint --config ../../tslint.json --project tsconfig.json","prepack":"tsc","watch":"tsc --watch"},"repository":{"type":"git","url":"git+ssh://git@github.com/graphile/graphile-engine.git"},"keywords":["pg","Postgres","plugin","PostgreSQL","logicial","decoding","logical","replication","changes","Graphile","PostGraphile"],"author":{"name":"Benjie Gillam","email":"code@benjiegillam.com"},"license":"MIT","bugs":{"url":"https://github.com/graphile/graphile-engine/issues"},"homepage":"https://github.com/graphile/graphile-engine/tree/master/packages/subscriptions-lds#readme","dependencies":{"@dwwoelfel/lds":"^4.4.5-alpha.0","@types/ws":"^6.0.1","ws":"^6.1.3"},"peerDependencies":{"@dwwoelfel/postgraphile-core":">4.3.1 <5"},"devDependencies":{"@types/jest":"^24.0.5","jest":"23.x","pg":">=6.5 <8","ts-jest":"^23.10.5","typescript":"^3.3.1"},"gitHead":"13938f563b26a0a7ccacd8f02376bb8f0ce8d0e5","_resolved":"","_integrity":"","_from":"file:dwwoelfel-subscriptions-lds-4.4.5-alpha.0.tgz","_id":"@dwwoelfel/subscriptions-lds@4.4.5-alpha.0","_npmVersion":"6.4.1","_nodeVersion":"11.0.0","_npmUser":{"name":"dww","email":"dwwoelfel@gmail.com"},"dist":{"integrity":"sha512-rAp9CN3a6bK+THpRFavfujhEOkRxNsl8o72ttDLSXCDNK/TkhJtNCxoWWrYsEkJQEQFK26ukxAlAXtS/CVr7ig==","shasum":"dcc2ff81298b01c815b7367c51cc3edea2766846","tarball":"https://registry.npmjs.org/@dwwoelfel/subscriptions-lds/-/subscriptions-lds-4.4.5-alpha.0.tgz","fileCount":9,"unpackedSize":26230,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcgBYZCRA9TVsSAnZWagAACSYP/RH4pCfR4XPuAMibIoNm\n2ii19NQrmZNKiQC4lg+ZIRAzR+SyVfZDPDH9Jjcfwi7V3VYOrMFNMBduTJov\nVgoS13EjS7pabR3RRKjvIgWjh3MFEAnzaZfmATfsuAbhFQgWUQk1krfsQbC7\n+iOF3FrKZKyxzKYByq/7/Vb4RldBNtSmpUDF9FHGRkz2Bfjre8HIdKX1BN4x\nD3B0wakPoWg4/Afi9eEcIlFxHg/0z4C7t5pAw8uKqV8VdP2QRNfS9n2N9tGR\nE2yQ6cIt8wzgIZzXN7fULSbbkhsRwQ9lsoN3pY0Gi/mbXmWXGugRgA/fAKnv\nU5v+t/k56qfHMoZGkj5EElZATUWOo52KnoWej3bOFNZTrE7et6vjoIvP1Ke+\nD27taGd6k6fEYuUqefLUGNEiae4DcnCIjc7ELNGWtJmxfLSCFjSLAcSrbLhZ\n7pRpROWejeK3WkFPfGu1KIry5Wy27FbEiwXyNSP1LoZ2v01Lp3Rrwg0h3Duw\nRhG+A4dUmiBLcbiPdvDbnNp47rzh8/iW9pdQy8sBTRrlpyD+PJphxwkHu0XT\ndR4IPRdj8PqwTwSwWFoqKlSBPMEflxxqZ1UTBMUXcwA0JDuhXJ14L7XI6VOl\nqfx8WiTf3pU4of+6SubH38T0bWtY/HuMf/VuIrnv34czwnH16LgcaQ8a830A\ntORT\r\n=dLdZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAGJxdThr6zzeOI4GahN/sGSnseLLNUvR2+IU50olgIlAiEA1vUU8x7YSlE96BaFgrYZSOc6T/g4oprbu6PjhicZGhk="}]},"maintainers":[{"name":"dww","email":"dwwoelfel@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/subscriptions-lds_4.4.5-alpha.0_1551898137047_0.36977432214218187"},"_hasShrinkwrap":false}},"time":{"created":"2019-03-06T18:20:48.812Z","4.4.3-alpha.0":"2019-03-06T18:20:49.115Z","modified":"2022-04-05T06:13:23.730Z","4.4.4-alpha.0":"2019-03-06T18:41:59.192Z","4.4.5-alpha.0":"2019-03-06T18:48:57.149Z"},"maintainers":[{"name":"dww","email":"dwwoelfel@gmail.com"}],"description":"Subscriptions plugin for PostGraphile using PostgreSQL logicial decoding","homepage":"https://github.com/graphile/graphile-engine/tree/master/packages/subscriptions-lds#readme","keywords":["pg","Postgres","plugin","PostgreSQL","logicial","decoding","logical","replication","changes","Graphile","PostGraphile"],"repository":{"type":"git","url":"git+ssh://git@github.com/graphile/graphile-engine.git"},"author":{"name":"Benjie Gillam","email":"code@benjiegillam.com"},"bugs":{"url":"https://github.com/graphile/graphile-engine/issues"},"license":"MIT","readme":"# @graphile/subscriptions-lds\n\nPostGraphile schema plugin to provide live updates powered by PostgreSQL\nlogical decoding. Used as part of PostGraphile's live queries support.\n\nFor more background, see [postgraphile issue #92](https://github.com/graphile/postgraphile/issues/92#issuecomment-313476989).\n\n## Installation:\n\nInstall alongside `postgraphile`, e.g.:\n\n```\nyarn add @graphile/subscriptions-lds\n```\n\n### Usage:\n\nTo use this plugin:\n\n- Ensure your PostgreSQL server has `wal_level = logical` and the `wal2json` plugin (see \"Setting up PostgreSQL\" below)\n- Load this plugin with `--append-plugins` (or `appendPlugins`)\n- Enable PostGraphile live with `--live` (or `live: true`)\n- If you don't use a superuser or database owner PostgreSQL user with PostGraphile normally (or if you pass a pool to the PostGraphile library), you must provide a superuser or database owner connection string via `--owner-connection` (or `ownerConnectionString`)\n\nCLI:\n\n```\npostgraphile \\\n  --live \\\n  --owner-connection postgres://db_owner:db_owner_pass@host/db \\\n  --append-plugins @graphile/subscriptions-lds \\\n  ...\n```\n\nLibrary:\n\n```js\napp.use(\n  postgraphile(DB, SCHEMA, {\n    // ...\n\n    // Enable live support in PostGraphile\n    live: true,\n    // We need elevated privileges for logical decoding\n    ownerConnectionString: \"postgres://db_owner:db_owner_pass@host/db\",\n    // Add this plugin\n    appendPlugins: [\n      //...\n      require(\"@graphile/subscriptions-lds\").default,\n    ],\n  })\n);\n```\n\n## Setting up PostgreSQL\n\nWe currently only support PG10+; if you need support for 9.x please get in\ntouch.\n\nTL;DR: set `wal_level = logical` in `postgresql.conf` and ensure `wal2json`\nis installed.\n\nThis plugin uses logical decoding and `wal2json`, so you must configure your\nPostgreSQL database to support this.\n\n### Setting wal_level = logical\n\nIn your `postgresql.conf` you need to enable `wal_level = logical`. You\nshould ensure that the following settings are set (the `10`s can be any\nnumber greater than 1; set them to how many PostGraphile instances you're\nexpecting to run, plus a little buffer for regular replication needs):\n\n```\nwal_level = logical\nmax_wal_senders = 10\nmax_replication_slots = 10\n```\n\n### Installing wal2json\n\nYou also need to ensure that `wal2json` is installed. This comes as standard\nin many managed PostgreSQL services, such as Amazon RDS, but to install it locally:\n\n1. Ensure that `which pg_config` returns the path to the **correct**\n   `pg_config` binary - the one related to your PostgreSQL install. (For\n   example, if on a Mac you've installed both Postgres.app _and_ PostgreSQL from\n   homebrew then you must modify your `PATH` variable to point at whichever one\n   you use, e.g. `export PATH=\"/Applications/Postgres.app/Contents/Versions/10/bin/:$PATH\"`)\n2. Run the below code (it takes about 10 seconds):\n\n```bash\ngit clone https://github.com/eulerto/wal2json.git\ncd wal2json\nUSE_PGXS=1 make\nUSE_PGXS=1 make install\n```\n\n3. (optional) delete the wal2json folder\n\n## Optimising\n\nPlease note that the defaults shown below are likely to change over time\nbased on user feedback. This document will not necessarily be updated with\nthe new defaults.\n\n### `LD_WAIT` (default 125)\n\nThis environmental variable controls how often in milliseconds we check for\nchanges from the database. Setting it smaller leads to more timely updates\nbut increases overhead. Setting it larger increases efficiency but means each\nbatch takes longer to process which may slow the Node.js event loop.\n\n### `LIVE_THROTTLE` (default 500)\n\nThis environmental variable is the minimum duration in milliseconds between\nlive updates to the same subscription.\n\nIf your server is getting overwhelmed, you may increase this to increase the\nperiod between live updates sent to clients.\n\nIf your application is not responsive enough, you may decrease this to get\ncloser to real-time updates.\n\n(Throttle fires on both the leading and trailing edge, so decreasing this\nonly affects successive updates, not the initial update.)\n\n### `LD_TABLE_PATTERN` (default \"\\*.\\*\")\n\nSet this envvar to e.g. `app_public.*` to only monitor tables in the\n`app_public` schema. See [`filter-tables` in the wal2json\ndocumentation](https://github.com/eulerto/wal2json#parameters)\n\n## Running LDS externally\n\nIf you reach sufficient scale that running `@graphile/lds` on its own server\nmakes sense (rather than using the embedded version) then you can do so\neasily. Follow the steps in the `@graphile/lds` README to get the server up\nand running, and then set environmental variable `LDS_SERVER_URL` to the full\nwebsocket URL to your LDS server, e.g. `ws://127.0.0.1:9876` (default) before\nloading this plugin.\n\n## Compatibility check\n\nYou can determine if your PostgreSQL instance is configured correctly with this:\n\n```sql\nDO $$\nBEGIN\n  if current_setting('wal_level') is distinct from 'logical' then\n    raise exception 'wal_level must be set to ''logical'', your database has it set to ''%''. Please edit your `%` file and restart PostgreSQL.', current_setting('wal_level'), current_setting('config_file');\n  end if;\n  if (current_setting('max_replication_slots')::int >= 1) is not true then\n    raise exception 'Your max_replication_slots setting is too low, it must be greater than 1. Please edit your `%` file and restart PostgreSQL.', current_setting('config_file');\n  end if;\n  if (current_setting('max_wal_senders')::int >= 1) is not true then\n    raise exception 'Your max_wal_senders setting is too low, it must be greater than 1. Please edit your `%` file and restart PostgreSQL.', current_setting('config_file');\n  end if;\n  perform pg_create_logical_replication_slot('compatibility_test', 'wal2json');\n  perform pg_drop_replication_slot('compatibility_test');\n  raise notice 'Everything seems to be in order.';\nend;\n$$ LANGUAGE plpgsql;\n```\n\nIf you see the following message then all should be good:\n\n```\nNOTICE:  00000: Everything seems to be in order.\n```\n","readmeFilename":"README.md"}