Skip to content

Commit

Permalink
Fix poll logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rtitle committed Mar 22, 2020
1 parent 647024f commit c59bf28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,11 @@ private[google2] class GoogleComputeInterpreter[F[_]: Async: StructuredLogger: T

override def pollOperation(project: GoogleProject, operation: Operation, delay: FiniteDuration, maxAttempts: Int)(
implicit ev: ApplicativeAsk[F, TraceId]
): Stream[F, Operation] =
): Stream[F, PollOperation] =
(Stream.eval(getOperation(project, operation)) ++ Stream.sleep_(delay))
.repeatN(maxAttempts)
.takeThrough(_.getStatus == "DONE")
.map(op => PollOperation(op, op.getStatus == "DONE"))
.takeThrough(!_.isDone)

private def buildMachineTypeUri(zone: ZoneName, machineTypeName: MachineTypeName): String =
s"zones/${zone.value}/machineTypes/${machineTypeName.value}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ trait GoogleComputeService[F[_]] {

def pollOperation(project: GoogleProject, operation: Operation, delay: FiniteDuration, maxAttempts: Int)(
implicit ev: ApplicativeAsk[F, TraceId]
): Stream[F, Operation]
): Stream[F, PollOperation]
}

object GoogleComputeService {
Expand Down Expand Up @@ -195,3 +195,4 @@ final case class MachineTypeName(value: String) extends AnyVal
final case class RegionName(value: String) extends AnyVal
final case class NetworkName(value: String) extends AnyVal
final case class SubnetworkName(value: String) extends AnyVal
final case class PollOperation(op: Operation, isDone: Boolean)

0 comments on commit c59bf28

Please sign in to comment.