Topics

Featured in Development

Peter Alvaro talks about the reasons one should engage in language design and why many of us would (or should) do something so perverse as to design a language that no one will ever use. He shares some of the extreme and sometimes obnoxious opinions that guided his design process.

Featured in AI, ML & Data Engineering

Today on The InfoQ Podcast, Wes talks with Katharine Jarmul about privacy and fairness in machine learning algorithms. Jarul discusses what’s meant by Ethical Machine Learning and some things to consider when working towards achieving fairness. Jarmul is the co-founder at KIProtect a machine learning security and privacy firm based in Germany and is one of the three keynote speakers at QCon.ai.

Featured in Culture & Methods

Organizations struggle to scale their agility. While every organization is different, common patterns explain the major challenges that most organizations face: organizational design, trying to copy others, “one-size-fits-all” scaling, scaling in siloes, and neglecting engineering practices. This article explains why, what to do about it, and how the three leading scaling frameworks compare.

Introducing ActorFx, a Cloud Based Actor Runtime

Developed by MS Open Tech, a subsidiary of Microsoft, ActorFx intends to offer a “non-prescriptive, language-independent model of dynamic distributed objects.” The model is divided into two components, the actor itself and its data storage. These are represented by the interfaces IActor and IActorState.

State Management with IActorState

Originally IActorState was a very simple interface. It is essentially a dictionary that exposes Set, Get, TryGet, Remove, and Flush. The last operation, which can be run asynchronously, is used to commit changes. By convention, changes are stored in a “local side-effect buffer” until commit is called, at which point they should be atomically saved to a durable store.

This simplicity hides a secret, IActorState can be sued to store anything including active code.

Actor Methods

Prior to using an actor, that actor must be taught what it can do. Unlike traditional .NET programming, this isn’t done by manually deploying code to the server. Instead, methods are pushed to the actor at run time using the IActor.AddAssembly function. The assemblies are represented as a byte array so they can be transmitted over the wire and stored inside the IActorState itself.

This means each actor is a fully encapsulated object. It doesn’t inherit methods from a class or prototype, it owns them itself. And those methods can be changed at any time simply by pushing a new assembly with the same name.

Since they are loaded an assembly at a time, actual actor methods need to be tagged using the ActorMethod attribute. Methods so tagged must adhere to the delegate pattern Func<IActorState, object[], object>.

Sending Messages to Actors

IActor.CallMethod is used to send messages to an actor. IActor.CallMethod accepts a string that represents the name of a method from one of the previously added assemblies along with an array of parameters. Its return type is simply System.Object.

When methods are invoked via IActor.CallMethod, the client is expected to also pass in a client ID and sequence number. This allows the actor runtime to detect duplicate requests resend the result of previous invocations. The client will of course be responsible for ensure that the pair of values is unique to a given message.

Actor to Actor Communication

Actors communicate with each other via transient instances of IActorProxy. The proxy allows one actor to invoke another actor’s CallMethod. The simplest way to use the proxy is to

In addition to allowing direct method invocation, the proxy can be used to setup a subscription. Based on a modified version of IObserver, events from the publishing actor can cause methods to be invoked on the subscribing actor. The subscription can be cancelled by calling Dispose on a token returned by the Subscribe method.

A Sample Client

Most of what we’ve been talking about is of interest to actor runtime implementations. Most developers will be dealing with a client such as FabricActorClient. Here we see the key methods: