Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/rollup #377

Merged
merged 11 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ jobs:
run: |
psql --version &&
psql -d postgresql://ueberdb:[email protected]/ueberdb -c '\dt'
- name: Create javascript files from typescript
run: npm run build

- run: npm test
- run: npm run lint
Expand Down Expand Up @@ -125,7 +127,7 @@ jobs:
# the second's will succeed.
-
name: Convert typescript and create dist folder
run: tsc
run: npx rollup -c rollup.config.cjs
-
run: npm publish
env:
Expand Down
4 changes: 2 additions & 2 deletions databases/cassandra_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import AbstractDatabase, {Settings} from '../lib/AbstractDatabase';
import cassandra, {ArrayOrObject, Client, types, ValueCallback} from 'cassandra-driver';
import {ArrayOrObject, Client, types, ValueCallback} from 'cassandra-driver';
import ResultSet = types.ResultSet;


Expand Down Expand Up @@ -64,7 +64,7 @@ export const Database = class Cassandra_db extends AbstractDatabase {
*/
init(callback: (arg: any)=>{}) {
// Create a client
this.client = new cassandra.Client(this.settings.clientOptions);
this.client = new Client(this.settings.clientOptions);

// Pass on log messages if a logger has been configured
if (this.settings.logger) {
Expand Down
29 changes: 2 additions & 27 deletions databases/redis_db.ts

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* limitations under the License.
*/

// @ts-ignore
import cacheAndBufferLayer from './lib/CacheAndBufferLayer';
import {Database as DatabaseCache} from './lib/CacheAndBufferLayer';
import {normalizeLogger} from './lib/logging';
import {callbackify} from 'util';
import {Settings} from './lib/AbstractDatabase';
Expand All @@ -34,8 +33,9 @@ const cbDb = {
setSub: () => {},
};
const fns = ['close', 'findKeys', 'flush', 'get', 'getSub', 'init', 'remove', 'set', 'setSub'];
for (const fn of fns) { // @ts-ignore
cbDb[fn] = callbackify(cacheAndBufferLayer.Database.prototype[fn]);
for (const fn of fns) {
// @ts-ignore
cbDb[fn] = callbackify(DatabaseCache.prototype[fn]);
}
const makeDoneCallback = (callback: (err?:any)=>{}, deprecated:(err:any)=>{}) => (err: null) => {
if (callback) callback(err);
Expand Down Expand Up @@ -75,7 +75,7 @@ export const Database = class {
this.logger = normalizeLogger(logger);
const db = new this.dbModule.Database(this.dbSettings);
db.logger = this.logger;
this.db = new cacheAndBufferLayer.Database(db, this.wrapperSettings, this.logger);
this.db = new DatabaseCache(db, this.wrapperSettings, this.logger);

// Expose the cache wrapper's metrics to the user. See lib/CacheAndBufferLayer.js for details.
//
Expand Down
6 changes: 3 additions & 3 deletions lib/CacheAndBufferLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const util = require('util');
/**
* Cache with Least Recently Used eviction policy.
*/
class LRU {
export class LRU {
/**
* @param evictable Optional predicate that dictates whether it is permissable to evict the entry
* if it is old and the cache is over capacity. The predicate is passed two arguments (key,
Expand Down Expand Up @@ -132,7 +132,7 @@ const defaultSettings =
charset: 'utf8mb4',
};

exports.Database = class {
export const Database = class {
/**
* @param wrappedDB The Database that should be wrapped
* @param settings (optional) The settings that should be applied to the wrapper
Expand Down Expand Up @@ -660,6 +660,6 @@ const clone = (obj, key = '') => {
throw new Error("Unable to copy obj! Its type isn't supported.");
};

exports.exportedForTesting = {
export const exportedForTesting = {
LRU,
};
3 changes: 1 addition & 2 deletions lib/logging.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Console} from 'console';
import {stdout, stderr} from 'process';

class ConsoleLogger extends Console {
export class ConsoleLogger extends Console {
constructor(opts = {}) { super({stdout, stderr, inspectOptions: {depth: Infinity}, ...opts}); }
isDebugEnabled() { return false; }
isInfoEnabled() { return true; }
Expand Down Expand Up @@ -30,4 +30,3 @@ export const normalizeLogger = (logger: null | Function) => {
return logger;
};

export default {ConsoleLogger};
Loading