Skip to content

Commit

Permalink
Merge 089d1c5 into 539e672
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewBemis committed Nov 12, 2020
2 parents 539e672 + 089d1c5 commit e1a11ca
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package org.broadinstitute.dsde.workbench.google2

import cats.effect.{Blocker, ContextShift, Resource, Sync, Timer}
import com.google.auth.Credentials
import com.google.cloud.ServiceOptions.getDefaultProjectId
import com.google.cloud.bigquery.BigQueryOptions.DefaultBigQueryFactory
import com.google.cloud.bigquery.{BigQuery, BigQueryOptions, JobId, QueryJobConfiguration, TableResult}
import io.chrisdavenport.log4cats.StructuredLogger
import org.broadinstitute.dsde.workbench.model.google.GoogleProject

trait GoogleBigQueryService[F[_]] {
def query(queryJobConfiguration: QueryJobConfiguration, options: BigQuery.JobOption*): F[TableResult]
Expand All @@ -22,6 +24,13 @@ object GoogleBigQueryService {
def resource[F[_]: Sync: ContextShift: Timer: StructuredLogger](
credentials: Credentials,
blocker: Blocker
): Resource[F, GoogleBigQueryService[F]] =
resource(credentials, blocker, GoogleProject(getDefaultProjectId))

def resource[F[_]: Sync: ContextShift: Timer: StructuredLogger](
credentials: Credentials,
blocker: Blocker,
projectId: GoogleProject
): Resource[F, GoogleBigQueryService[F]] =
for {
client <- Resource.liftF[F, BigQuery](
Expand All @@ -30,6 +39,7 @@ object GoogleBigQueryService {
BigQueryOptions
.newBuilder()
.setCredentials(credentials)
.setProjectId(projectId.value)
.build()
)
)
Expand Down

0 comments on commit e1a11ca

Please sign in to comment.