Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Дмитрий Иванов «JetBrains.RdFramework — консистентное реактивное программирование в распределённом мире»

DotNetRu
January 16, 2020

Дмитрий Иванов «JetBrains.RdFramework — консистентное реактивное программирование в распределённом мире»

Давайте шаг за шагом напишем «мини-райдер» — распределённое многопоточное приложение на нескольких языках программирования (в нашем случае это будут C# и Kotlin, оставим C++ в покое).

Какие строительные кирпичики, идеи и технические решения нам потребуются?

DotNetRu

January 16, 2020
Tweet

More Decks by DotNetRu

Other Decks in Programming

Transcript

  1. SIGNALS let’s apply lifetime pattern interface ISignal<T> { void Fire(T

    value) void Advise(Lifetime lf, Action<T> handler) }
  2. SIGNALS separation of concerns interface ISignalFrontend<T> { void Fire(T value)

    } interface ISource<T> { void Advise(Lifetime lf, Action<T> handler) } interface ISignal<T> : ISource<T>
  3. PROPERTIES stateful signals interface ISource<T> { void Advise(Lifetime lf, Action<T>

    handler) } interface IViewableProperty<T> : ISource<T> { T Value {get; set} ISource<T> Change; }
  4. PROPERTIES presenting viewable pattern interface ISink<T> { void Advise(Lifetime lf,

    Action<T> handler) } interface IViewableProperty<T> : ISink<T> { T Value {get; set} void View(Lifetime lf, Action<Lifetime, T> action) }
  5. PROPERTIES presenting viewable pattern interface ISink<T> { void Advise(Lifetime lf,

    Action<T> handler) } interface IViewableProperty<T> : ISink<T> { T Value {get; set} void View(Lifetime lf, Action<Lifetime, T> action) } initial value
  6. PROPERTIES presenting viewable pattern interface ISink<T> { void Advise(Lifetime lf,

    Action<T> handler) } interface IViewableProperty<T> : ISink<T> { T Value {get; set} void View(Lifetime lf, Action<Lifetime, T> action) } initial value
  7. PROPERTIES presenting viewable pattern interface ISink<T> { void Advise(Lifetime lf,

    Action<T> handler) } interface IViewableProperty<T> : ISink<T> { T Value {get; set} void View(Lifetime lf, Action<Lifetime, T> action) } initial value
  8. PROPERTIES presenting viewable pattern interface ISink<T> { void Advise(Lifetime lf,

    Action<T> handler) } interface IViewableProperty<T> : ISink<T> { T Value {get; set} void View(Lifetime lf, Action<Lifetime, T> action) } initial value
  9. MAPS reactive collections interface IViewableMap<K,V> : IDictionary<K,V>, ISource<MapEvent<K,V>> { ISource<MapEvent<K,V>>

    Change; } enum AddUpdateRemove {Add, Update, Remove} class MapEvent<K,V>{ AddUpdateRemove kind; K key; V value; }
  10. SETS reactive collections interface IViewableSet<T> : ISet<T> ISource<SetEvent<T>> { }

    enum AddUpdate {Add, Remove} class SetEvent<T>{ AddUpdate kind; T item; }
  11. LIST reactive collections interface IViewableList<T> : IList<T>, ISource<ListEvent<T>> { }

    class ListEvent<T>{ AddUpdateRemove kind; int index; [CanBeNull] V oldValue; [CanBeNull] V newValue; }
  12. REAL WORLD Idea R# MsBuild Unity Editor Debugger (+remote) Roslyn

    WPF Preview Unreal ThinClient (rdclient) WebStorm (rdbackend) R# front
  13. RIDER FRAMEWORK DSL Frontend (IJ IDEA) Code Kotlin RdFramework Kotlin

    Generated Code Backend (ReSharper) Code C# RdFramework C# Generated Code dsl based model github (rd-net) github (rd-kt) github (rd-kt/rd-gen) RdModel.csproj rider-generated rider-model
  14. object Solution : Ext(IdeRoot) { init { map(“editors”, string, classdef(“Editor”)

    { list(“document”, char) property(“caret”, int) }) } }
  15. object Solution : Ext(IdeRoot) { init { map(“editors”, string, classdef(“Editor”)

    { list(“document”, char) property(“caret”, int) map(“highlighters”, Range, Highlighter) }) } val Range = structdef(“Range”) { field(“start”, int) field(“length”, int) } val Highlighter = classdef(“Highlighter”) { field(“attributes”, immutableList(string)) } }
  16. object Solution : Ext(IdeRoot) { init { map(“editors”, string, classdef(“Editor”)

    { list(“document”, char) property(“caret”, int) map(“highlighters”, Range, Highlighter) property(“completion”, Completion.nullable) }) } val Range = structdef(“Range”) { field(“start”, int) field(“length”, int) } val Highlighter = classdef(“Highlighter”) { immutableList(attributes) } }
  17. object Solution : Ext(IdeRoot) { init { map(“editors”, string, classdef(“Editor”)

    { list(“document”, char) property(“caret”, int) map(“highlighters”, Range, Highlighter) property(“completion”, Completion.nullable) }) source(“build”, void) } val Range = structdef(“Range”) { field(“start”, int) field(“length”, int) } val Highlighter = classdef(“Highlighter”) { … } }
  18. BUILDING BLOCKS of RdProtocol Primitive types: • int8, int16, int32,

    int64 • uint(s) • float, double • char, boolean, void • string • secureString • byteArray, intArray, doubleArray … • guid, uri, dateTime
  19. BUILDING BLOCKS of RdProtocol Scalar types: (could be used in

    signals, calls) • enums (+flags) • structdef (abstract/sealed) - can contain fields of scalars
  20. BUILDING BLOCKS of RdProtocol Bindable types: • classdef (abstract/sealed) •

    can contain: • signals • properties • lists, sets, maps • calls (+ lifetime per call) • fields of scalars/bindable
  21. HOW TO START Protocol (ctor) : • Serializers (+ IPolymorphicTypeCatalog)

    • Identities • Scheduler • RdDispatcher • SingleThreadScheduler • SynchronousScheduler • Wire (Local, Socket.Server, Socket.Client)