com.threewks.thundr.bigmetrics.BigMetricsModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of thundr-bigmetrics Show documentation
Show all versions of thundr-bigmetrics Show documentation
A thundr module for supporting metrics in big query
The newest version!
/*
* This file is a component of thundr, a software library from 3wks.
* Read more: http://www.3wks.com.au/thundr
* Copyright (C) 2014 3wks,
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.threewks.thundr.bigmetrics;
import com.google.appengine.api.appidentity.AppIdentityServiceFactory;
import com.threewks.thundr.bigmetrics.bigquery.BigQueryModule;
import com.threewks.thundr.bigmetrics.controller.EventQueueController;
import com.threewks.thundr.bigmetrics.service.BigMetricsServiceImpl;
import com.threewks.thundr.bigmetrics.service.BigQueryTypeMappings;
import com.threewks.thundr.bigmetrics.service.EventDispatcher;
import com.threewks.thundr.bigmetrics.service.PushQueueEventDispatcher;
import com.threewks.thundr.gae.GaeModule;
import com.threewks.thundr.injection.BaseModule;
import com.threewks.thundr.injection.UpdatableInjectionContext;
import com.threewks.thundr.module.DependencyRegistry;
import com.threewks.thundr.route.Router;
public class BigMetricsModule extends BaseModule {
public static final String BigmetricsViewEnsureAllUrl = "bigmetricsViewEnsureAllUrl";
public static final String BigmetricsTableEnsureAllUrl = "bigmetricsTableEnsureAllUrl";
public static final String BigmetricsPushQueueUrl = "bigmetricsPushQueueUrl";
public static final String BigmetricsAdminExportBucket = "bigmetricsAdminExportBucket";
@Override
public void requires(DependencyRegistry dependencyRegistry) {
super.requires(dependencyRegistry);
dependencyRegistry.addDependency(GaeModule.class);
dependencyRegistry.addDependency(BigQueryModule.class);
}
@Override
public void initialise(UpdatableInjectionContext injectionContext) {
super.initialise(injectionContext);
injectionContext.inject(PushQueueEventDispatcher.class).as(EventDispatcher.class);
injectionContext.inject(BigMetricsServiceImpl.class).as(BigMetricsService.class);
injectionContext.inject(BigQueryTypeMappings.class).as(BigQueryTypeMappings.class);
injectionContext.inject("/admin/bigmetrics/add/{tableId}").named(BigmetricsPushQueueUrl).as(String.class);
injectionContext.inject("/admin/bigmetrics/view/ensureAll").named(BigmetricsViewEnsureAllUrl).as(String.class);
injectionContext.inject("/admin/bigmetrics/table/ensureAll").named(BigmetricsTableEnsureAllUrl).as(String.class);
injectionContext.inject(AppIdentityServiceFactory.getAppIdentityService().getDefaultGcsBucketName()).named(BigmetricsAdminExportBucket).as(String.class);
// TODO remove this
injectionContext.inject("thundr-bigmetrics").named(BigmetricsAdminExportBucket).as(String.class);
}
@Override
public void configure(UpdatableInjectionContext injectionContext) {
super.configure(injectionContext);
Router router = injectionContext.get(Router.class);
String bigmetricsPushQueueUrl = injectionContext.get(String.class, BigmetricsPushQueueUrl);
String bigmetricsViewEnsureAllUrl = injectionContext.get(String.class, BigmetricsViewEnsureAllUrl);
String bigmetricsTableEnsureAllUrl = injectionContext.get(String.class, BigmetricsTableEnsureAllUrl);
router.post(bigmetricsPushQueueUrl, EventQueueController.class, "addEvent", "bigmetrics.add");
router.post(bigmetricsViewEnsureAllUrl, EventQueueController.class, "ensureViews", "bigmetrics.view.ensure.all");
router.post(bigmetricsTableEnsureAllUrl, EventQueueController.class, "ensureTables", "bigmetrics.table.ensure.all");
}
@Override
public void start(UpdatableInjectionContext injectionContext) {
super.start(injectionContext);
BigMetricsService bigMetricsService = injectionContext.get(BigMetricsService.class);
bigMetricsService.validateEvents();
bigMetricsService.asyncEnsureTablesExist();
bigMetricsService.asyncEnsureViewsExist();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy