-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3105: chore: remove Topic r=jniles a=jniles The Topic library is an event emitter with no consumers implemented. At our production sites, we do not even write to the database the events. Thus, this commit removes Topic until we have a real use case for it. It should also improve performances slightly since we will not be Pub/Sub-ing events to Redis. Closes #3091. Co-authored-by: Jonathan Niles <jonathanwniles@gmail.com>
- Loading branch information
Showing
18 changed files
with
41 additions
and
430 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 |
---|---|---|
@@ -1,57 +1,24 @@ | ||
/* global EventSource */ | ||
angular.module('bhima.services') | ||
.service('SystemService', SystemService); | ||
.service('SystemService', SystemService); | ||
|
||
SystemService.$inject = ['$http', 'util']; | ||
|
||
/** | ||
* System Service | ||
*/ | ||
function SystemService($http, util) { | ||
var service = this; | ||
var baseUrl = '/system'; | ||
const service = this; | ||
const baseUrl = '/system'; | ||
|
||
// exposed API | ||
service.information = information; | ||
service.events = events; | ||
service.stream = []; | ||
|
||
function information() { | ||
return $http.get(baseUrl.concat('/information')) | ||
.then(util.unwrapHttpResponse); | ||
} | ||
|
||
function events() { | ||
// forcibly clear the event queue | ||
service.stream.length = 0; | ||
|
||
return $http.get(baseUrl.concat('/events')) | ||
.then(util.unwrapHttpResponse); | ||
} | ||
|
||
function handleServerSentEvent(event) { | ||
console.log('Got Event:', event); | ||
service.stream.push(JSON.parse(event.data)); | ||
} | ||
|
||
function handleErrorEvent(event) { | ||
if (event.readyState === EventSource.CLOSED) { | ||
console.log('Connection was closed.'); | ||
} | ||
} | ||
|
||
function handleOpenEvent(event) { | ||
console.log('Connection was open.'); | ||
} | ||
|
||
/* | ||
// set up event stream | ||
var source = new EventSource(baseUrl.concat('/stream')); | ||
source.addEventListener('open', handleOpenEvent, false); | ||
source.addEventListener('message', handleServerSentEvent, false); | ||
source.addEventListener('error', handleErrorEvent, false); | ||
*/ | ||
|
||
return service; | ||
} |
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
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
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
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
Oops, something went wrong.