-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the b64 log format to track offsets for pause/play support
- Loading branch information
1 parent
6447785
commit bc3f02b
Showing
3 changed files
with
75 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Ember from 'ember'; | ||
import queryString from 'npm:query-string'; | ||
|
||
const { Mixin, computed, assign } = Ember; | ||
const CHUNK_SIZE = 50000; | ||
|
||
export default Mixin.create({ | ||
url: '', | ||
params: computed(() => ({})), | ||
logFetch() { | ||
Ember.assert( | ||
'Loggers need a logFetch method, which should have an interface like window.fetch' | ||
); | ||
}, | ||
|
||
endOffset: null, | ||
|
||
offsetParams: computed('endOffset', function() { | ||
const endOffset = this.get('endOffset'); | ||
return endOffset | ||
? { origin: 'start', offset: endOffset } | ||
: { origin: 'end', offset: CHUNK_SIZE }; | ||
}), | ||
|
||
additionalParams: computed(() => ({})), | ||
|
||
fullUrl: computed('url', 'params', 'offsetParams', 'additionalParams', function() { | ||
const queryParams = queryString.stringify( | ||
assign({}, this.get('params'), this.get('offsetParams'), this.get('additionalParams')) | ||
); | ||
return `${this.get('url')}?${queryParams}`; | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters