Publish to my blog (weekly)

    • Akka does provide Cluster Singleton to create a singleton instance of an actor in a clustered environment.
    • Akka extensions has two basic components namely Extensions and ExtensionId. Extensions are loaded only once per actor system. ExtensionId is needed to get the instance of our extension.
    • val queue = (new BasicIntQueue  | with Filtering with Incrementing)
    • Scala allows to mix in a trait (creating an anonymous type) when creating a new instance of a class.
    • You can return that anonymous function from the body of another function as follows:
    • Because saySomething returns a function, you can assign that resulting function to a variable.
    • sealed traits can only be extended in the same file
    • this lets the compiler easily know all possible subtypes
    • use sealed traits when the number of possibly subtypes is finite and known in advance
    • they can be a way of creating something like an enum in Java
    • they help you define algebraic data types
    • The most important use of sealed is in defining algebraic data types.
    • ogical ors, such as List, which is a :: or Nil; and
    • logical ands, such as ::, which has a head and a tail.
    • product type
    • sum type
    • This complex definition is just an algebraic data type — it is defined entirely in terms of ands and ors.
    • structural recursion
    • None (a sum type)
    • Some has an element x (a product type, albeit a very simple one containing a single field)
    • Each branch in a sum type (a logical or) gets its own case in the pattern matching
    • each product type (a logical and) requires us to extract and do something with the elements.
    • This is all that structural recursion is.
    • we can model a very general class of data using algebraic data types
    • we can mechanically convert an algebraic data type into Scala definitions
    • we can mechanically write Scala code to use any algebraic data type via structural recursion
    • the compiler to perform exhaustiveness checking
    • this means the compiler will shout at us if we miss out a case in our structural recursion.
    • If so you’ll know how easy it is to forget to check for the null (or nil) case. Exhaustiveness checking completely prevents this type of error.
    • It is also extremely useful when refactoring code
    • A sealed trait can only be extended within the file in which it defined.
    • Note that we can get exhaustive checking in the example above if we declare the type as Base. Exhaustiveness checking is controlled entirely by the type of the expression being matched.
    • final modifier has similar semantics to sealed. A sealed trait can only be extended in the defining file
    • a final class cannot be extended anywhere.
    • I believe sealed abstract classes lead to a slightly faster implementation and easier Java interoperation
    • The biggest challenge was related to back pressure: how could we prevent our connection Actors from being flooded with messages in case the endpoint system slowed down or was not available? With 6000 messages per second an Actor's mailbox is flooded very quickly.
    • we had to find a way to pull only as many messages in our broker as it could deliver to the endpoint.
    • provide our own back pressure implementation.
    • The core ingredients of a Reactive Stream consist of three building blocks:
    • A Source that produces some values
    • A Flow that performs some transformation of the elements produced by a Source
    • A Sink that consumes the transformed values of a Flow
    • val numberReverserFlow: Flow[Int, String] = Flow[Int].map(_.toString.reverse)
    • Source(100 to 200)
    • ForeachSink(println)
    • The exact same pipeline can be expressed in various ways, such as:
    • Source(100 to 200)
    • to(ForeachSink(println))
    • via(numberReverserFlow)
    • run()
    • run()
    • to(ForeachSink(println))
    • map(_.toString.reverse)
    • Source(100 to 200)
    • The manager is an actor that handles the underlying low level I/O resources (selectors, channels) and instantiates workers for specific tasks, such as listening to incoming connections.
    • IO(Tcp) ! Connect(remote)
    • case c @ Connected(remote, local)
    • The first step of connecting to a remote address is sending a Connect message to the TCP manager
    • reply either with a CommandFailed
    • it will spawn an internal actor representing the new connection
    • closes the connection when that one terminates
    • cleaning up all internal resources associated with that connection
    • The connection actor
    • watches the registered handler
    • In order to activate the new connection a Register message must be sent to the connection acto
    • It enables one to bind a matched pattern to a variable
    • But if you need to write a custom TCP client that communicates with a server using a proprietary protocol then you are on your own.
    • IO(Tcp) returns reference to an actor
    • All we have to do is intercept these messages from our receive method.
    • the connection actor a Register message to set our TcpClient actor as receiver of various IO events (like socket is readable or writable).
    • The attempt to write the request data has failed.
    • The socket is readable indicating the server has written some response data.
    • The server has closed the connection.
    • There are many other possible events that can happen.
    • To process these messages we use a separate receive method. This is defined using context become.
    • context become
    • trumps everything else
      • 다른 무엇보다 우선하다.
    • rationale
      • 이론적 해석
    • polishing
      • 세련함
    • churning
      • 휘젖다.
      • The "diamond problem" (sometimes referred to as the "deadly diamond of death"[4]) is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and C have overridden, and D does not override it, then which version of the method does D inherit: that of B, or that of C?
    • coping with
      • 대처하다.
    • per se
      • 본질적으로, 그것 자체로
    • Classes and objects can extend traits but traits cannot be instantiated and therefore have no parameters.
    • What makes them different from abstract classes is that interfaces cannot store state.
    • the developer must explicitly code the desired behavior.
    • Kotlin’s is consistent with its philosophy: being explicit and readable before being concise.
    • tail : => Stream[A]
    • cons가 메서드[각주:2]가 아닌 inner object로 구현되어 있다는 사실도 흥미롭다. 내부의 cons object에 apply를 정의해 마치 cons를 메서드처럼 활용했다.
    • apply의 인자 tail이 by-name 타입으로 정의되어 있다는 점
    • Stream은 우선 List가 감당하기 힘든 크기의 수열을 표현할 수 있다.
    • 자연수 전체와 같은 무한 수열 또한 표현 가능

Posted from Diigo. The rest of my favorite links are here.

댓글

이 블로그의 인기 게시물

Publish to my blog (weekly)

Publish to my blog (weekly)