You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am in the early learning phase, and I am attempting to produce minimal working example of small counter app, which is integrating Akka.net, Akkling and Falco
open Falco
open Falco.Routing
open Falco.HostBuilder
open Akkling
open Akka.Actor
open Akka
let system: ActorSystem = System.create "basic-sys" <| Configuration.defaultConfig()
type Message =
| IncreaseCounter
| GetCounter
let greeter (m:Actor<Message>) =
let rec loop state = actor {
let! msg = m.Receive ()
match msg with
| IncreaseCounter -> return! loop (state + 1)
| GetCounter -> m.Sender() <! state.ToString()
return! loop state
}
loop 0
let greeterRef = spawnAnonymous system (props greeter)
webHost [||] {
endpoints [
get "/counter" (
let counter = greeterRef <? GetCounter |> Async.RunSynchronously
Response.ofPlainText counter
)
put "/counter" (
greeterRef <! IncreaseCounter
Response.ofEmpty
)
]
}
I am experiencing the "get counter" always returning 0.
It is almost like the actor gets re-created repeatedly instead of sleeping and awaiting a message.
When I take this very same code outside of Falco and go with something like this
let greeterRef = spawnAnonymous system (props greeter)
greeterRef <! IncreaseCounter
let counter = greeterRef <? GetCounter |> Async.RunSynchronously
it works as expected.
So it is clear that the integration part is wrong.
Apologies for creating this as an issue - if we had Discussions here I would post it there.
Thanx!
The text was updated successfully, but these errors were encountered:
Without knowing Falco, it would seem to me you're partially applying the GET handler, so the counter value 0 is embedded in it. Similarly, the counter is increased once during startup, not on every PUT.
I am in the early learning phase, and I am attempting to produce minimal working example of small counter app, which is integrating Akka.net, Akkling and Falco
I am experiencing the "get counter" always returning 0.
It is almost like the actor gets re-created repeatedly instead of sleeping and awaiting a message.
When I take this very same code outside of Falco and go with something like this
it works as expected.
So it is clear that the integration part is wrong.
Apologies for creating this as an issue - if we had Discussions here I would post it there.
Thanx!
The text was updated successfully, but these errors were encountered: