This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValveSubject<T> : ISubject<T> | |
{ | |
private enum Valve | |
{ | |
Open, | |
Closed | |
} | |
private readonly Subject<T> input = new Subject<T>(); | |
private readonly Subject<Valve> valveSubject = new Subject<Valve>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RegisterAsImplementedInterfaces(PerOwnedType = typeof (IConnectionScope))] | |
internal class ResponseDispatcher : IResponseDispatcher | |
{ | |
private static readonly ILog Log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | |
private readonly IRequestsPendingResponseRepository requestsPendingResponse; | |
private readonly IConnectionContext context; | |
public ResponseDispatcher(IRequestsPendingResponseRepository requestsPendingResponse, IConnectionContext context) | |
{ | |
this.requestsPendingResponse = requestsPendingResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ParallelQueryExtensions | |
{ | |
public static IObservable<T> ToUnorderedObservable<T>(this ParallelQuery<T> query) | |
{ | |
return Observable.Create<T>( | |
obs => | |
{ | |
try | |
{ | |
query.WithMergeOptions(ParallelMergeOptions.NotBuffered).ForAll(obs.OnNext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async void Main() | |
{ | |
var endPoint = new IPEndPoint(IPAddress.Loopback, 8080); | |
using (var listener = new UdpClient(endPoint)) | |
{ | |
while(true) { | |
var result = await listener.ReceiveAsync(); | |
var message = Encoding.UTF8.GetString(result.Buffer, 0, result.Buffer.Length); | |
XElement.Parse(message).Elements().ToDictionary(el=>el.Name, el=>el.Value).Dump(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Simple command line toggles parser: | |
/// - toggles are identified with (any number of) '-' prefixes | |
/// - toggle can be with or without associated value | |
/// - toggles are case-insensitive | |
/// | |
/// <example>--toggle_without_value -toggle value</example> | |
/// </summary> | |
public class ToggleParser | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.grpc.stub.{ClientCallStreamObserver, ClientResponseObserver, StreamObserver} | |
import monix.execution.Ack.{Continue, Stop} | |
import monix.execution.{Cancelable, Scheduler} | |
import monix.reactive.observers.Subscriber | |
import monix.reactive.{Observable, Observer} | |
import scala.concurrent.{CancellationException} | |
import scala.util.{Failure, Success} | |
object MonixGrpcAdapters { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.1.0", | |
"command": "${workspaceRoot}/node_modules/.bin/webpack", | |
"isShellCommand": true, | |
"args": [ | |
"--display-modules", | |
"--progress" | |
], | |
"echoCommand": true, | |
"tasks": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.stream._ | |
import akka.stream.stage.{ GraphStage, GraphStageLogic, InHandler, OutHandler } | |
/** | |
* Zips two streams, picking always the latest of the elements of each source | |
* | |
* No element is emitted until at least one element of each becomes available. Whenever a new | |
* element appears, a new tuple is emitted with the last seen element of the other type | |
* | |
* '''Emits when''' all of the inputs have at least an element available, and then each time an element becomes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.NotUsed | |
import akka.actor.typed.ActorRef | |
import akka.stream.OverflowStrategy | |
import akka.stream.scaladsl.Source | |
import akka.stream.typed.scaladsl.ActorSource | |
import akka.util.Timeout | |
import com.typesafe.scalalogging.StrictLogging | |
import scala.concurrent.TimeoutException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Ride(id: Ride.ID, | |
origin: Address, | |
destination: Address, | |
pickupTime: Instant, | |
vehicle: Option[Vehicle.ID], | |
status: Ride.Status) | |
object Ride { | |
sealed trait Status | |
case object Pending extends Status |
OlderNewer