Skip to content

Commit 547ae34

Browse files
max-zillabodom0015lmarini
authored
Split RabbitMQPlugin into ExtractorRoutingService and MessageService (#155)
* Initial split into services * single MessageService file * Add stubbed EventSinkService (using fake MessageService) * Included an example of how to call EventSinkService from within an HTML template * Wiring updates * wiring for ExtractorRoutingService * more wiring * Sync to switch branches * further wiring of new services * more wiring * enough updates to compile! * add Singleton marker * initialize factory to account for lack of onStart * Filled out EventSinkService impl * Adjust direct calls to Amplitude to use EventSinkService * add noop for MessageService * fix: cleanup commented out yucky code * Added missing tracking for file uploads * Remove direct usage of Amplitude Javascript SDK * Fix logFileUploadEvent, starting to think about auth question * add manual submission event * Update RabbitMQMessageService.scala * Fix failing test case / wrong package name * Fix failing test case, revert package name change * Parameterize exchange_type (default value is "topic") * Removed old call to Amplitude. It was breaking the upload page. File div would disappear after upload even though the file was successfully added. * Added rabbitmq info back to status. Created a getInfo() function to let the implementation specify what to use. Might want to use the same pattern for future plugin -> services conversions. Co-authored-by: Mike Lambert <[email protected]> Co-authored-by: Luigi Marini <[email protected]>
1 parent cf768e5 commit 547ae34

33 files changed

+2123
-1940
lines changed

app/api/Datasets.scala

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ class Datasets @Inject()(
5252
relations: RelationService,
5353
userService: UserService,
5454
thumbnailService : ThumbnailService,
55+
routing: ExtractorRoutingService,
5556
appConfig: AppConfigurationService,
56-
esqueue: ElasticsearchQueue) extends ApiController {
57+
esqueue: ElasticsearchQueue,
58+
sinkService: EventSinkService) extends ApiController {
5759

5860
lazy val chunksize = play.Play.application().configuration().getInt("clowder.chunksize", 1024*1024)
5961

@@ -606,9 +608,7 @@ class Datasets @Inject()(
606608
val mdMap = metadata.getExtractionSummary
607609

608610
//send RabbitMQ message
609-
current.plugin[RabbitmqPlugin].foreach { p =>
610-
p.metadataAddedToResource(metadataId, metadata.attachedTo, mdMap, Utils.baseUrl(request), request.apiKey, request.user)
611-
}
611+
routing.metadataAddedToResource(metadataId, metadata.attachedTo, mdMap, Utils.baseUrl(request), request.apiKey, request.user)
612612

613613
events.addObjectEvent(request.user, id, x.name, EventType.ADD_METADATA_DATASET.toString)
614614

@@ -655,9 +655,7 @@ class Datasets @Inject()(
655655
val mdMap = metadata.getExtractionSummary
656656

657657
//send RabbitMQ message
658-
current.plugin[RabbitmqPlugin].foreach { p =>
659-
p.metadataAddedToResource(metadataId, metadata.attachedTo, mdMap, Utils.baseUrl(request), request.apiKey, request.user)
660-
}
658+
routing.metadataAddedToResource(metadataId, metadata.attachedTo, mdMap, Utils.baseUrl(request), request.apiKey, request.user)
661659

662660
events.addObjectEvent(request.user, id, x.name, EventType.ADD_METADATA_DATASET.toString)
663661

@@ -739,10 +737,8 @@ class Datasets @Inject()(
739737
}
740738

741739
// send extractor message after attached to resource
742-
current.plugin[RabbitmqPlugin].foreach { p =>
743-
metadataIds.foreach { mId =>
744-
p.metadataRemovedFromResource(mId, ResourceRef(ResourceRef.dataset, id), Utils.baseUrl(request), request.apiKey, request.user)
745-
}
740+
metadataIds.foreach { mId =>
741+
routing.metadataRemovedFromResource(mId, ResourceRef(ResourceRef.dataset, id), Utils.baseUrl(request), request.apiKey, request.user)
746742
}
747743

748744
Ok(toJson(Map("status" -> "success", "count" -> metadataIds.size.toString)))
@@ -2500,8 +2496,10 @@ class Datasets @Inject()(
25002496
val baseURL = controllers.routes.Datasets.dataset(id).absoluteURL(https(request))
25012497

25022498
// Increment download count if tracking is enabled
2503-
if (tracking)
2499+
if (tracking) {
25042500
datasets.incrementDownloads(id, user)
2501+
sinkService.logDatasetDownloadEvent(dataset, user)
2502+
}
25052503

25062504
// Use custom enumerator to create the zip file on the fly
25072505
// Use a 1MB in memory byte array

0 commit comments

Comments
 (0)