Skip to content

Commit

Permalink
Merge branch 'release/2.2' into bug/direct-collection-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ committed Jun 10, 2023
2 parents 852c172 + f301ad5 commit 6eb49c2
Show file tree
Hide file tree
Showing 85 changed files with 1,709 additions and 1,503 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [StorytellerCZ]
31 changes: 31 additions & 0 deletions .github/workflows/comment-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Add immediate comment on new issues

on:
issues:
types: [opened]

jobs:
createComment:
runs-on: ubuntu-latest
steps:
- name: Create Comment
uses: peter-evans/create-or-update-comment@v1.4.2
with:
issue-number: ${{ github.event.issue.number }}
body: |
Thank you for submitting this issue!
We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.
However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee you issues to be solved within certain time.
If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.
Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
meteor: [1.12.2, 2.6.1, 2.7.3, 2.8.1, 2.12]
redis-version: [4, 5, 6, 7]

steps:
- uses: actions/checkout@v3

- name: Start Redis
uses: supercharge/redis-github-action@1.5.0
with:
redis-version: ${{ matrix.redis-version }}

- name: Setup Meteor
uses: meteorengineer/setup-meteor@v1
with:
meteor-release: ${{ matrix.meteor }}
- name: Setup tests
run: |
meteor create --release ${{ matrix.meteor }} --bare test
cd test
meteor npm i --save puppeteer@1.18.1 simpl-schema chai
- name: Test
working-directory: ./test
run: METEOR_PACKAGE_DIRS="../" TEST_BROWSER_DRIVER=puppeteer meteor test-packages --raw-logs --once --driver-package meteortesting:mocha ../
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
dump.rdb
npm-debug.log
npm-debug.log
.idea/

test/
5 changes: 5 additions & 0 deletions .meteorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
.github/
test/
docs/
testing/
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
accounts-base@2.2.4
accounts-password@2.3.1
alanning:roles@3.4.0
aldeed:collection2@3.0.6
allow-deny@1.1.1
babel-compiler@7.9.2
babel-runtime@1.5.1
base64@1.0.12
binary-heap@1.0.11
boilerplate-generator@1.7.1
callback-hook@1.4.0
check@1.3.1
cultofcoders:redis-oplog@2.1.1
ddp@1.4.0
ddp-client@2.5.0
ddp-common@1.4.0
ddp-rate-limiter@1.1.0
ddp-server@2.5.0
diff-sequence@1.1.1
dynamic-import@0.7.2
ecmascript@0.16.2
ecmascript-runtime@0.8.0
ecmascript-runtime-client@0.12.1
ecmascript-runtime-server@0.11.0
ejson@1.1.2
email@2.2.1
fetch@0.1.1
geojson-utils@1.0.10
id-map@1.1.1
inter-process-messaging@0.1.1
local-test:cultofcoders:redis-oplog@2.1.1
localstorage@1.2.0
logging@1.3.1
matb33:collection-hooks@1.1.4
meteor@1.10.0
meteortesting:browser-tests@0.1.2
meteortesting:mocha@0.4.4
minimongo@1.8.0
modern-browsers@0.1.8
modules@0.18.0
modules-runtime@0.13.0
mongo@1.15.0
mongo-decimal@0.1.3
mongo-dev-server@1.1.0
mongo-id@1.0.8
natestrauser:publish-performant-counts@0.1.2
npm-mongo@4.3.1
ordered-dict@1.1.0
practicalmeteor:mocha-core@1.0.1
promise@0.12.0
raix:eventemitter@0.1.3
random@1.2.0
rate-limit@1.0.9
react-fast-refresh@0.2.3
reactive-var@1.0.11
reload@1.3.1
retry@1.1.0
reywood:publish-composite@1.7.3
routepolicy@1.1.1
service-configuration@1.3.0
sha@1.0.9
socket-stream-client@0.5.0
tmeasday:check-npm-versions@0.3.2
tracker@1.2.0
underscore@1.0.10
url@1.3.2
webapp@1.13.1
webapp-hashing@1.1.0
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
## CHANGELOG

### 2.2.0
- Bumped minimum Meteor version to v1.12.2
- Updated tests to cover from Meteor v1.12.2 to the latest v2.12
- Added testing for Redis v7
- Updated `node-redis` to v3.1.2
- Updated `deep-extend` to v0.6.0
- Fix update not returning number
- Fix SyntheticMutator not applying `globalRedisPrefix`

### 2.1.1
- Fixes callback is not a function error when using SyntheticMutator.update

### 2.1.0
- Meteor 2.6 support
- Projections option support
- Update Mocha tests
- Update tests to use Meteor 1.12.2 to fix certificates issues

### 1.2.3
- Redis connection failover handling
- Refetching the up to date collection when Redis connection resumes
- Re-fetching the up-to-date collection when Redis connection resumes
- Bug fixes and improvements

### 1.2.2
Expand All @@ -29,4 +47,4 @@

### 1.0.3
- Added support for publish composite
- Fixed randomly failing tests
- Fixed randomly failing tests
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ It is also always helpful to have some context for your pull request. What was t

### Setup
```
meteor create --release 1.8.1 --bare test
meteor create --release 1.12.2 --bare test
cd test
meteor npm i --save puppeteer@1.18.1 simpl-schema
meteor npm i --save puppeteer@1.18.1 simpl-schema chai
```

### Start Tests
Expand Down Expand Up @@ -78,4 +78,4 @@ Thank you to all our sponsors! (please ask your company to also support this ope
<a href="https://opencollective.com/redis-oplog/sponsor/8/website" target="_blank"><img src="https://opencollective.com/redis-oplog/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/redis-oplog/sponsor/9/website" target="_blank"><img src="https://opencollective.com/redis-oplog/sponsor/9/avatar.svg"></a>

<!-- This `CONTRIBUTING.md` is based on @nayafia's template https://github.com/nayafia/contributing-template -->
<!-- This `CONTRIBUTING.md` is based on @nayafia's template https://github.com/nayafia/contributing-template -->
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Welcome to Redis Oplog
## Introducing BlueLibs

- [GitHub BlueLibs Monorepo](https://github.com/bluelibs/bluelibs)
- Following the same bold vision of Meteor, but with a modern twist. www.bluelibs.com
- Read more about our approach coming from Meteor: https://www.bluelibs.com/blog/2021/11/26/the-meteor-of-2022
- We've implemented [RedisOplog](https://www.bluelibs.com/docs/package-x-bundle#live-data) in our framework as well, but it also works with in-memory and with customisable pubsub, not bound to redis.

# Welcome to Redis Oplog

### LICENSE: MIT

[![Build Status](https://api.travis-ci.org/cult-of-coders/redis-oplog.svg?branch=master)](https://travis-ci.org/cult-of-coders/redis-oplog) [![Backers on Open Collective](https://opencollective.com/redis-oplog/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/redis-oplog/sponsors/badge.svg)](#sponsors)
[![Backers on Open Collective](https://opencollective.com/redis-oplog/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/redis-oplog/sponsors/badge.svg)](#sponsors)

## RedisOplog

Expand Down
4 changes: 2 additions & 2 deletions docs/failover.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In order to configure these events, you can do it like this:
// in a server-side file that is loaded on startup
import { Config } from 'meteor/cultofcoders:redis-oplog';

_.extend(Config.redisExtras.events, {
Object.assign(Config.redisExtras.events, {
reconnect({delay, attempt, error}) {
// put your logic here.
},
Expand All @@ -30,4 +30,4 @@ _.extend(Config.redisExtras.events, {
Since we have the logic of refreshing an observable collection, we can make it so it falls back to polling.
But polling is very dangerous and very expensive, so we should avoid it at all costs, however
this could be implemented and customized per collection, but honestly, your redis-server needs to have
high-availability, since it's a core component of your app.
high-availability, since it's a core component of your app.
4 changes: 2 additions & 2 deletions docs/finetuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ Messages.configureRedisOplog({
}
if (event === Events.REMOVE) {
// If it performs a remove by _id (which is the most usual)
threadId = Messages.findOne({_id: selector._id}, {fields: {threadId: 1}}).threadId;
threadId = Messages.findOne({_id: selector._id}, {projection: {threadId: 1}}).threadId;
}
if (event === Events.UPDATE) {
// If it performs an update by _id (which is the most usual)
threadId = Messages.findOne({_id: selector._id}, {fields: {threadId: 1}}).threadId;
threadId = Messages.findOne({_id: selector._id}, {projection: {threadId: 1}}).threadId;
}

options.namespace = `threads::${threadId}`;
Expand Down
6 changes: 3 additions & 3 deletions docs/outside_mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ redis.publish('tasks', JSON.stringify({

You have to be careful, if in your app you subscribe by `_id`:
```js
return Task.find({_id: taskId})
return Tasks.find({_id: taskId})
```

In order for the processor to catch the event you have to send it to the `tasks::taskId` channel, where `taskId` represents the actual id inside MongoDB.
Expand All @@ -47,7 +47,7 @@ So, if you have both types of publications, you have to publish it to both `task

If you use namespaces, the channels also change:
```js
return Task.find({groupId}, {
return Tasks.find({groupId}, {
namespace: `group::${groupId}`
})
```
Expand All @@ -57,7 +57,7 @@ you have to send it to both `group::groupId::tasks` and `tasks::taskId`, where `

Keep in mind, that namespaces don't affect direct query processing:
```js
return Task.find({_id: taskId}, {
return Tasks.find({_id: taskId}, {
namespace: `group::${groupId}`
})
```
Expand Down
28 changes: 17 additions & 11 deletions lib/cache/ObservableCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const allowedOptions = [
'skip',
'sort',
'fields',
'projection',
'channels',
'channel',
'namespace',
Expand Down Expand Up @@ -89,34 +90,37 @@ export default class ObservableCollection {
this.options = {};
}

var fields = this.options.projection || this.options.fields;

// check for empty projector object and delete.
if (this.options.fields && _.isEmpty(this.options.fields)) {
if (fields && _.isEmpty(fields)) {
delete this.options.projection;
delete this.options.fields;
}

if (this.options.fields) {
this.fieldsArray = _.keys(this.options.fields);
if (fields) {
this.fieldsArray = Object.keys(fields);

if (!_.isArray(this.fieldsArray)) {
throw new Meteor.Error(
'We could not properly extract any fields. "fields" must be an object. This was provided: ' +
JSON.stringify(this.options.fields)
'We could not properly extract any fields. "projection" or "fields" must be an object. This was provided: ' +
JSON.stringify(fields)
);
}

this.projectFieldsOnDoc = LocalCollection._compileProjection(
this.options.fields
fields
);
this.isFieldsProjectionByExclusion = fieldProjectionIsExclusion(
this.options.fields
fields
);
}

this.channels = getChannels(this.collectionName, this.options);
this.fieldsOfInterest = this._getFieldsOfInterest();
this.__isInitialized = false;

var projection = this.options.fields || {};
var projection = fields || {};
this._projectionFn = LocalCollection._compileProjection(projection); // Projection function, result of combining important fields for selector and
// existing fields projection

Expand Down Expand Up @@ -152,7 +156,7 @@ export default class ObservableCollection {
isEligibleByDB(_id) {
if (this.matcher) {
return !!this.collection.findOne(
_.extend({}, this.selector, { _id }),
Object.assign({}, this.selector, { _id }),
{ fields: { _id: 1 } }
);
}
Expand Down Expand Up @@ -308,7 +312,9 @@ export default class ObservableCollection {
* @return {true|object}
*/
_getFieldsOfInterest() {
if (!this.options.fields) {
const fields = this.options.projection || this.options.fields;

if (!fields) {
return true;
}

Expand All @@ -320,7 +326,7 @@ export default class ObservableCollection {

// if we have options, we surely have fields array
let fieldsArray = this.fieldsArray.slice();
if (_.keys(this.selector).length > 0) {
if (Object.keys(this.selector).length > 0) {
fieldsArray = _.union(
fieldsArray,
extractFieldsFromFilters(this.selector)
Expand Down
2 changes: 2 additions & 0 deletions lib/cache/lib/extractFieldsFromFilters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { _ } from 'meteor/underscore';

const deepFilterFieldsArray = ['$and', '$or', '$nor'];
const deepFilterFieldsObject = ['$not'];

Expand Down
Loading

0 comments on commit 6eb49c2

Please sign in to comment.