Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tharwaninitin committed Dec 21, 2023
1 parent c324dd7 commit 27d465f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modules/bq/src/main/scala/gcp4zio/bq/BQ.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ trait BQ {
targetCompressionType: String = "gzip"
): Task[Unit]

/** Execute function with BigQuery as Input and return Generic o/p T
*
* @param f
* BigQuery => T
* @tparam T
* Output
* @return
*/
def execute[T](f: BigQuery => T): Task[T]
}

Expand Down Expand Up @@ -230,6 +238,14 @@ object BQ {
)
)

/** Execute function with BigQuery as Input and return Generic o/p T
*
* @param f
* BigQuery => T
* @tparam T
* Output
* @return
*/
def execute[T](f: BigQuery => T): RIO[BQ, T] = ZIO.environmentWithZIO(_.get.execute(f))

def live(credentials: scala.Option[String] = None): TaskLayer[BQ] = ZLayer.fromZIO(BQClient(credentials).map(bq => BQImpl(bq)))
Expand Down
8 changes: 8 additions & 0 deletions modules/bq/src/main/scala/gcp4zio/bq/BQImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,13 @@ case class BQImpl(client: BigQuery) extends BQ {
}
}

/** Execute function with BigQuery as Input and return Generic o/p T
*
* @param f
* BigQuery => T
* @tparam T
* Output
* @return
*/
override def execute[T](f: BigQuery => T): Task[T] = ZIO.attempt(f(client))
}

0 comments on commit 27d465f

Please sign in to comment.