Skip to content

Commit

Permalink
util-core: Remove forwarding types on c.t.util package object
Browse files Browse the repository at this point in the history
Problem

In the interest of having finer grained pants build targets the source
code within util-core should not have cycles.

Solution

Remove the forwarding types `c.t.util.TimeConversions` and
`c.t.util.StorageUnitConversions`.  Use `c.t.conversions.time` and
`c.t.conversions.storage` directly as replacements.

Result

Removes the cycle between the `c.t.util` and `c.t.conversions`
packages.

JIRA Issues: CSL-7094

Differential Revision: https://phabricator.twitter.biz/D227363
  • Loading branch information
kevinoliver authored and jenkins committed Oct 11, 2018
1 parent 2f8ee90 commit 0c83ebc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Breaking API Changes

* util-core: `c.t.util.TempFolder` has been moved to `c.t.io.TempFolder`. ``PHAB_ID=D226940``

* util-core: Removed the forwarding types `c.t.util.TimeConversions` and
`c.t.util.StorageUnitConversions`. Use `c.t.conversions.time` and
`c.t.conversions.storage` directly. ``PHAB_ID=D227363``

Runtime Behavior Changes
~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion util-cache/src/main/scala/com/twitter/cache/Refresh.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicReference
* def getData(): Future[T] = { ... }
*
* can be memoized with a TTL of 1 hour as follows:
* import com.twitter.util.TimeConversions._
* import com.twitter.conversions.time._
* import com.twitter.cache.Refresh
* val getData: () => Future[T] = Refresh.every(1.hour) { ... }
*/
Expand Down
13 changes: 5 additions & 8 deletions util-cache/src/test/scala/com/twitter/cache/RefreshTest.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.twitter.cache

import com.twitter.util.{Await, Future, Time, Promise}
import com.twitter.conversions.time._
import com.twitter.util.{Await, Future, Promise, Time}
import org.mockito.Mockito._
import com.twitter.util.TimeConversions._
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest._
import org.scalatest.mockito.MockitoSugar

@RunWith(classOf[JUnitRunner])
class RefreshTest extends FunSuite with MockitoSugar {

class Ctx {
Expand Down Expand Up @@ -73,7 +70,7 @@ class RefreshTest extends FunSuite with MockitoSugar {
val ctx = new Ctx
import ctx._

val promise = Promise[Int]
val promise = Promise[Int]()
reset(provider)
when(provider())
.thenReturn(promise)
Expand All @@ -93,7 +90,7 @@ class RefreshTest extends FunSuite with MockitoSugar {
val ctx = new Ctx
import ctx._

val promise = Promise[Int]
val promise = Promise[Int]()
reset(provider)
when(provider()).thenReturn(promise)

Expand All @@ -108,7 +105,7 @@ class RefreshTest extends FunSuite with MockitoSugar {
verify(provider, times(1))()

reset(provider)
val promise2 = Promise[Int]
val promise2 = Promise[Int]()
when(provider()).thenReturn(promise2)

val result3 = memoizedFuture()
Expand Down
23 changes: 0 additions & 23 deletions util-core/src/main/scala/com/twitter/util/package.scala

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twitter.util

import com.twitter.util.TimeConversions.intToTimeableNumber
import com.twitter.conversions.time.intToTimeableNumber
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.concurrent.{Eventually, IntegrationPatience}
Expand Down
2 changes: 1 addition & 1 deletion util-core/src/test/scala/com/twitter/util/TimeTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.scalatest.concurrent.{Eventually, IntegrationPatience}
import org.scalatest.junit.JUnitRunner
import org.scalatest.prop.GeneratorDrivenPropertyChecks

import com.twitter.util.TimeConversions._
import com.twitter.conversions.time._

trait TimeLikeSpec[T <: TimeLike[T]] extends WordSpec with GeneratorDrivenPropertyChecks {
val ops: TimeLikeOps[T]
Expand Down

0 comments on commit 0c83ebc

Please sign in to comment.