Skip to content

Instantly share code, notes, and snippets.

View mgodave's full-sized avatar
🤟

Dave Rusek mgodave

🤟
  • ex-Twitter
  • Denver, CO
  • 19:35 (UTC -06:00)
View GitHub Profile
/**
* Copyright [2020] David J. Rusek <dave.rusek@gmail.com>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
  • Status: Proposal
  • Author: Dave Rusek - Streamlio
  • Pull Request: See Below
  • Mailing List discussion:

Motivation

Data flowing through a messaging system is typically untyped. Data flows from end-to-end as bytes and only the producers and consumers are aware of the type

Keybase proof

I hereby claim:

  • I am mgodave on github.
  • I am daverusek (https://keybase.io/daverusek) on keybase.
  • I have a public key whose fingerprint is 0632 699D 471F 7255 B581 2B71 2DE6 CBB6 229F 7DBC

To claim this, I am signing this object:

import com.twitter.concurrent.AsyncStream
import com.twitter.concurrent.AsyncStream._
import com.twitter.util.{Await, Future}
object MapConcurrentLeak extends App{
def stream(i: Int, stop: Int): AsyncStream[Int] = {
if (i >= stop) fromFuture(Future.never)
else i +:: stream(i + 1, stop)
}
import com.twitter.concurrent.AsyncStream
import com.twitter.util._
object Merge {
def merge[E](streams: Seq[AsyncStream[E]]): AsyncStream[E] = {
def inner(next: Seq[Future[Option[(E, () => AsyncStream[E])]]]): AsyncStream[E] = {
AsyncStream.fromFuture(Future.select(next)) flatMap {
case (Return(Some((head, tail))), tails) =>
object AsyncStreams {
def collect[E](streams: Seq[AsyncStream[E]]): AsyncStream[E] = {
AsyncStream.fromFuture(
Future.collect(
streams.map(_.head)
).map(_.flatten)
).flatMap(AsyncStream.fromSeq) ++ collect(streams)
}
}
import com.twitter.util.{Var, Witness}
import org.mockito.Matchers.anyInt
import org.mockito.Mockito.{times, verify}
import org.scalatest.mockito.MockitoSugar
import org.scalatest.prop.PropertyChecks
import org.scalatest.{MustMatchers, WordSpec}
class VarsTest extends WordSpec with MustMatchers with PropertyChecks with MockitoSugar {
def max[T](values: Var[T])(implicit ord: Ordering[T]): Var[T] = {
class UpdateClass {
var _x = 1
def update(x: Int) = {
_x = x
}
}
val u = new UpdateClass()
println(u._x) // prints 1
u() = 2

Keybase proof

I hereby claim:

  • I am mgodave on github.
  • I am daverusek (https://keybase.io/daverusek) on keybase.
  • I have a public key whose fingerprint is 3DF3 2C1A 47C9 F842 A196 64EE F584 6BA0 56DA 28B2

To claim this, I am signing this object:

package org.robotninjas.util.pool;
import com.google.common.base.Ticker;
import org.apache.commons.pool2.BaseObjectPool;
import org.apache.commons.pool2.KeyedObjectPool;
import org.apache.commons.pool2.KeyedPooledObjectFactory;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;