Skip to content

Commit c080bf1

Browse files
committed
core.15; run syncAll in it's own Fiber (#175), key/debug log in (#182)
1 parent 3813dae commit c080bf1

File tree

7 files changed

+36
-18
lines changed

7 files changed

+36
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Current versions of each package (requires manual, explicit updates until
1616
the stable release):
1717

1818
```
19-
meteor add msgfmt:core@2.0.0-preview.14
19+
meteor add msgfmt:core@2.0.0-preview.15 (2015-12-23)
2020
meteor add msgfmt:extract@2.0.0-preview.12
2121
meteor add msgfmt:ui@2.0.0-preview.5
2222
```

msgfmt:core/.versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ http@1.1.1
3131
id-map@1.0.4
3232
jag:pince@0.0.6
3333
jquery@1.11.4
34-
local-test:msgfmt:core@2.0.0-preview.14
34+
local-test:msgfmt:core@2.0.0-preview.15
3535
logging@1.0.8
3636
meteor@1.1.10
3737
meteorhacks:inject-initial@1.0.2
3838
minifiers@1.1.7
3939
minimongo@1.0.10
4040
mongo@1.1.3
4141
mongo-id@1.0.1
42-
msgfmt:core@2.0.0-preview.14
42+
msgfmt:core@2.0.0-preview.15
4343
npm-mongo@1.4.39_1
4444
observe-sequence@1.0.7
4545
ordered-dict@1.0.4

msgfmt:core/History.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
## vNEXT
22

3+
## 2.0.0-preview.15
4+
5+
* Run `syncAll` in it's own Fiber to avoid blocking on load
6+
from `server/mfAll.js` in the case of slow I/O (#175).
7+
Thanks also @sbalmer and @1u.
8+
9+
* When warning about calling mf() on the server from outside
10+
a method/publish, mention the offfending key (!)
11+
use `log.warn` instead of `console.log`.
12+
Thanks @MartinFournier (#182).
13+
314
## 2.0.0-preview.14
415

516
* Add `check` package (now that Meteor 1.2 is stricter)

msgfmt:core/lib/mfPkg/messageformat-server.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var Fiber = Npm.require('fibers');
2+
13
// server only, but used on the client in msgfmt:ui
24
mfPkg.mfRevisions = new Mongo.Collection('mfRevisions');
35

@@ -158,21 +160,26 @@ mfPkg.addNative = function(strings, meta) {
158160

159161
// called from mfTrans.js
160162
mfPkg.syncAll = function(strings, meta) {
163+
new Fiber(function() {
164+
var startTime = Date.now();
165+
166+
var lastSync = msgfmt.mfMeta.findOne('syncTrans');
167+
lastSync = lastSync ? lastSync.mtime : 0;
161168

162-
var lastSync = this.mfMeta.findOne('syncTrans');
163-
lastSync = lastSync ? lastSync.mtime : 0;
169+
for (lang in strings)
170+
if (lang != msgfmt.native)
171+
msgfmt.langUpdate(lang, strings[lang], meta, lastSync);
164172

165-
for (lang in strings)
166-
if (lang != this.native)
167-
this.langUpdate(lang, strings[lang], meta, lastSync);
173+
// TODO. Sync native strings too, ensure _id's are the same,
174+
// allow for random load order
168175

169-
// TODO. Sync native strings too, ensure _id's are the same,
170-
// allow for random load order
176+
msgfmt['syncTrans'] = meta.updatedAt;
177+
msgfmt.mfMeta.upsert('syncTrans', {$set: {mtime: msgfmt['syncTrans'] } });
171178

172-
this['syncTrans'] = meta.updatedAt;
173-
this.mfMeta.upsert('syncTrans', {$set: {mtime: this['syncTrans'] } });
179+
msgfmt.observeFrom(meta.updatedAt, 'trans');
174180

175-
this.observeFrom(meta.updatedAt, 'trans');
181+
log.debug('Finished syncAll (in a fiber) in ' + (Date.now() - startTime) + ' ms');
182+
}).run();
176183
}
177184

178185
var meta = mfPkg.mfMeta.find().fetch();

msgfmt:core/lib/mfPkg/messageformat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ mf = function(key, params, message, locale) {
133133
if (currentInvocation)
134134
locale = currentInvocation.connection.locale;
135135
else {
136-
console.log(
137-
"[msgfmt] You called mf() with the key '" + key +
136+
log.warn(
137+
"You called mf() with the key '" + key +
138138
"' outside of a method/publish and " +
139139
"without specifying a locale, defaulting to native (" + msgfmt.native + ")"
140140
);

msgfmt:core/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package.describe({
22
name: "msgfmt:core",
3-
version: "2.0.0-preview.14",
3+
version: "2.0.0-preview.15",
44
summary: "MessageFormat support, the Meteor way",
55
git: "https://github.com/gadicc/meteor-messageformat.git",
66
});

website/.meteor/versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ mobile-status-bar@1.0.3
5757
momentjs:moment@2.10.6
5858
mongo@1.1.0
5959
mrt:sp-marked@0.0.2
60-
msgfmt:core@2.0.0-preview.13
61-
msgfmt:extract@2.0.0-preview.10
60+
msgfmt:core@2.0.0-preview.14
61+
msgfmt:extract@2.0.0-preview.12
6262
msgfmt:ui@2.0.0-preview.5
6363
nicolaslopezj:router-layer@0.0.11
6464
npm-bcrypt@0.7.8_2

0 commit comments

Comments
 (0)