Package com.codecademy.eventhub.index

Source Code of com.codecademy.eventhub.index.DatedEventIndexModule

package com.codecademy.eventhub.index;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.codecademy.eventhub.base.DB;
import org.fusesource.leveldbjni.JniDBFactory;
import org.iq80.leveldb.Options;

import javax.inject.Named;
import java.io.File;
import java.io.IOException;

public class DatedEventIndexModule extends AbstractModule {
  @Override
  protected void configure() {}

  @Provides
  @Named("eventhub.datedeventindex.filename")
  public String getDatedEventIndexFile(
      @Named("eventhub.directory") String eventIndexDirectory) {
    return eventIndexDirectory + "/dated_event_index.db";
  }

  @Provides
  public DatedEventIndex getDatedEventIndex(
      @Named("eventhub.directory") String eventIndexDirectory) throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    DB db = new DB(
        JniDBFactory.factory.open(new File(eventIndexDirectory + "/dated_event_index.db"), options));

    return DatedEventIndex.create(db);
  }
}
TOP

Related Classes of com.codecademy.eventhub.index.DatedEventIndexModule

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.