Questions tagged [twitter-util]

Twitter Util is a collection of general purpose Scala tools developed and open sourced by Twitter.

Twitter Util is a collection of general purpose Scala tools developed and open sourced by Twitter. It provides (among many other things) the future implementation used in Finagle and many other projects at Twitter.

23 questions
19
votes
2 answers

What are advantages of a Twitter Future over a Scala Future?

I know a lot of reasons for Scala Future to be better. Are there any reasons to use Twitter Future instead? Except the fact Finagle uses it.
Sergey Alaev
  • 3,851
  • 2
  • 20
  • 35
6
votes
3 answers

dynamically parse a string and return a function in scala using reflection and interpretors

I am trying to dinamically interpret code given as a String. Eg: val myString = "def f(x:Int):Int=x+1". Im looking for a method that will return the real function out of it: Eg: val myIncrementFunction =…
5
votes
1 answer

Twitter's Future.collect not working concurrently (Scala)

Coming from a node.js background, I am new to Scala and I tried using Twitter's Future.collect to perform some simple concurrent operations. But my code shows sequential behavior rather than concurrent behavior. What am I doing wrong? Here's my…
Ram
  • 53
  • 3
4
votes
1 answer

com.twitter.util.Await doesn't raise a com.twitter.util.TimeoutException

I expect that this code will raise a TimeoutException, but it doesn't. What do I do wrong? import com.twitter.conversions.time._ import com.twitter.util.{Await, Future} object Tmp { def main(args: Array[String]): Unit = { Await.result( …
Alexander Ershov
  • 1,105
  • 2
  • 12
  • 26
4
votes
2 answers

filtering out users using TwitterUtils

Is there a way to extract only specific user who post a tweet when using TwitterUtils.createStream()? (JAVA) The "filters" argument specifies the strings that need to be contained in the tweets, but I am not sure how this can be used to specify the…
slimoo
  • 123
  • 2
  • 14
3
votes
2 answers

Why does Finatra use flatMap and not just map?

This might be a really dumb question but I am trying to understand the logic behind using #flatMap and not just #map in this method definition in Finatra's HttpClient definition: def executeJson[T: Manifest](request: Request, expectedStatus: Status…
3
votes
2 answers

Does a Future get a new thread?

Does a future implemented like below get a new thread? Apparently it is not(see the output below). Why? What should I do if I want my code to run on a new thread? package MyTest import com.twitter.util._ import scala.language.postfixOps object…
Jonna
  • 1,625
  • 1
  • 18
  • 38
2
votes
0 answers

How do you combine multiple com.twitter.util.Awaitable's with Future.select semantics?

In a service, I have a main method that starts a com.twitter.finagle.ListeningServer and also creates a custom "channel" returning a com.twitter.util.Future that never completes (unless there is an error). Both are actually…
reikje
  • 2,850
  • 2
  • 24
  • 44
2
votes
1 answer

Is there com.twitter.util.Local for Scala Future and ExecutionContext?

ThreadLocal-like class that keeps its value through Future.map/Future.flatMap is extremely useful to trace request, for example, for logging. Is there existing abstraction in Scala library to serve as such Local? Is there a way to attach such Local…
Sergey Alaev
  • 3,851
  • 2
  • 20
  • 35
1
vote
1 answer

Twitter Futures - how are unused futures handled?

So I have a api in Scala that uses twitter.util.Future. In my case, I want to create 2 futures, one of which is dependent on the result of the other and return the first future: def apiFunc(): Future[Response]={ val future1 = getFuture1() val…
DFL
  • 53
  • 8
1
vote
0 answers

How to specify the execution service for future callbacks in Twitter Util?

I don't get how I can specify an certain execution service from Java, like a thread pool, to execute my callback of a future. For example, I can have a chain of map operations: val executionService =…
Baradé
  • 1,290
  • 1
  • 15
  • 35
1
vote
3 answers

Executing sequence of functions that return a future sequentially

I have a sequence of functions that return a future. I want to execute them sequentially i.e. after the first function future is complete, execute the next function and so on. Is there a way to do it? ops: Seq[() => Future[Unit]]
Jonna
  • 1,625
  • 1
  • 18
  • 38
1
vote
1 answer

Java-Scala interop issue involving BoxedUnit/void return types

I have the same problem as in Java interoperability woes with Scala generics and boxing, but I don't think the solution there will work for me because it would require a modification to third-party code. Specifically, from Java (say MyJavaClass) I'm…
danielpcox
  • 466
  • 4
  • 11
1
vote
2 answers

Spark SQL: TwitterUtils Streaming fails for unknown reason

I am using the latest Spark master and additionally, I am loading these jars: - spark-streaming-twitter_2.10-1.1.0-SNAPSHOT.jar - twitter4j-core-4.0.2.jar - twitter4j-stream-4.0.2.jar My simple test program that I execute in the shell looks as…
helm
  • 713
  • 2
  • 16
  • 30
1
vote
1 answer

finagle in java - Function, Function1 etc

How do I create Function1 object for use in flatMap method of finagle's Future object in Java? Tried this: Function1 f = new Function1() { @Override public String apply(String s) { return null; …
user3489275
  • 401
  • 4
  • 8
1
2