These are chat archives for akkadotnet/akka.net

1st
Nov 2015
Zetanova
@Zetanova
Nov 01 2015 10:05
If i am creating a temp actor, will it be allways on the local system? I need want to initialize it with a RX Subject and just pass it as Props to it.
Bartosz Sypytkowski
@Horusiath
Nov 01 2015 10:21
@Zetanova if you need an actor to be initialized only in local scope, there is a design patter for that. Often instead of creating Props each time, we have a factory methods inside an actor type definition itself and use it:
class MyActor : ReceiveActor
{
    public static Props Props(/* some args */) 
    {
        return Actor.Props.Create(() => new MyActor(/* args */)).WithDeploy(Deploy.Local);
    }
}

// in code
var aref = Context.ActorOf(MyActor.Props(/* args */));
Zetanova
@Zetanova
Nov 01 2015 10:25
thx
Zetanova
@Zetanova
Nov 01 2015 11:08
 public class PNetObserverActor : ActorBase
    {
        readonly IObserver<Object> observer;

        bool done;

        public static Props Props(IObserver<Object> observer)
        {
            return Akka.Actor.Props.Create(() => new PNetObserverActor(observer)).WithDeploy(Deploy.Local);
        }

        public PNetObserverActor(IObserver<Object> observer)
        {
            this.observer = observer;
        }

        protected override bool Receive(object message)
        {
            if (done)
                return false;

            message.Match()
                .With<PNetMessages.Success>(OnCompleted)
                .With<PNetMessages.Failure>(OnError)
                .Default(m => observer.OnNext(m));

            return true;
        }

        void OnError(PNetMessages.Failure msg)
        {
            done = true;
            observer.OnError(msg.Cause);
        }

        void OnCompleted(PNetMessages.Success msg)
        {
            done = true;
            observer.OnCompleted();
        }
    }
that simple?
or do i miss something?
Zetanova
@Zetanova
Nov 01 2015 11:17
The Observer is a custom QueueSubject that is scheduled on the CurrentThread of the creator (out side world)
Bartosz Sypytkowski
@Horusiath
Nov 01 2015 11:23
yes, it's basically it. What I'd suggest is splitting behavior instead of using done flag:
public class PNetObserverActor : ActorBase
{
    readonly IObserver<Object> observer;
    public static Props Props(IObserver<Object> observer)
    {
        return Akka.Actor.Props.Create(() => new PNetObserverActor(observer)).WithDeploy(Deploy.Local);
    }

    public PNetObserverActor(IObserver<Object> observer)
    {
       this.observer = observer;
    }

    protected override bool Receive(object message)
    {
        message.Match()
             .With<PNetMessages.Success>(OnCompleted)
             .With<PNetMessages.Failure>(OnError)
             .Default(m => observer.OnNext(m));

        return true;
    }

    protected bool Done(object message) { return false; }

    void OnError(PNetMessages.Failure msg)
    {
        Context.Become(Done);
        observer.OnError(msg.Cause);
    }

    void OnCompleted(PNetMessages.Success msg)
    {
        Context.Become(Done);
        observer.OnCompleted();
    }
}
thinking is terms of state machines is a lot easier to reason about than using if's and flags
Zetanova
@Zetanova
Nov 01 2015 11:25
yes, thx! I saw some obstacle/not used List<IObserver<object> observers in the Akka Inbox class, maybe the ObserverActor is useful there
Bartosz Sypytkowski
@Horusiath
Nov 01 2015 11:26
observables will be covered in Akka.Streams, when they will be finally ready
Kamil Wojciechowski
@aph5nt
Nov 01 2015 17:35
tag 1.0.4 - SnapshotStore.cs ls 57
else if (message is SaveSnapshotSuccess)
{
var msg = (SaveSnapshotSuccess)message;
Saved(msg.Metadata);
Sender.Tell(message); // Sender is PersistentActor
}
Sender.Tell(message); // Sender is PersistentActor ---- this is not sending back the SaveSnapshotSuccess
in logs I got: DEBUG"Unhandled message from akka://ServerSystem/system/akka.persistence.snapshot-store.blob-storage : Akka.Persistence.SaveSnapshotSuccess"{"propertiesObject":{"message":"Unhandled message from akka://ServerSystem/system/akka.persistence.s...
I got a breakpoint in my 'Sender' and Im unable to receive
with Persistent View I got no issues
but with persistentactor I have
Kamil Wojciechowski
@aph5nt
Nov 01 2015 17:59
sam story for different persistance provider
DEBUG"Unhandled message from akka://ServerSystem/system/akka.persistence.snapshot-store.sql-server : Akka.Persistence.SaveSnapshotSuccess"{"propertiesObject":{"message":"Unhandled message from akka://ServerSystem/system/akka.persistence.s...
same*
Roger Johansson
@rogeralsing
Nov 01 2015 18:36
@Horusiath I might have solved the binary formatter stuff anyway, https://gist.github.com/rogeralsing/b966d18d66349521a228 looks like it could work
Bartosz Sypytkowski
@Horusiath
Nov 01 2015 19:56
@aph5nt are you sure sender is a persistent actor? for SaveSnapshotSuccess I supose it should be a SnapshotStore
@rogeralsing nice to hear :) do you think, we should add some specs to verify serializer compatibility with akka.net?
Bartosz Sypytkowski
@Horusiath
Nov 01 2015 20:04
also I've shared the idea for postgres in akkadotnet/Akka.Persistence.PostgreSql#10 - I haven't got much experience in using jsonb from .net , but if it's possible, such support would be great.
Kamil Wojciechowski
@aph5nt
Nov 01 2015 21:47
@Horusiath in SnapShotstore we got a line : Sender.Tell(message); // Sender is PersistentActor