# Cask Actors: Cask Actors: a tiny, lightweight, typed Scala Actor library

**URL:** <https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265>\
**Category:** Libraries\
**Created:** [November 4, 2019, 1:04am UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265 "2019-11-04T01:04:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lihaoyi](https://users.scala-lang.org/user_avatar/users.scala-lang.org/lihaoyi/32/290_2.png) [@lihaoyi](https://users.scala-lang.org/u/lihaoyi)\
**Post date:** [November 4, 2019, 1:04am UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265/1 "2019-11-04T01:04:13Z")

</div>

I’ve just published a new Actor library, Cask Actors:

- [http://www.lihaoyi.com/cask/page/cask-actors.html](http://www.lihaoyi.com/cask/page/cask-actors.html)

This library aims at small-scale in-process use cases, where you want to model things using concurrent actors, but pulling in a huge framework like Akka might be an overkill. The linked docs go into more detail in how to use it. Any feedback is welcome!

---

<div class="post-metadata">

**Author:** ![markehammons](https://users.scala-lang.org/user_avatar/users.scala-lang.org/markehammons/32/782_2.png) [@markehammons](https://users.scala-lang.org/u/markehammons)\
**Post date:** [November 4, 2019, 11:00am UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265/2 "2019-11-04T11:00:50Z")

</div>

This seems interesting! I’m on the beginning stages of making a window manager for linux using dotty, and I might use this inside it.

---

<div class="post-metadata">

**Author:** ![apoigne](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@apoigne](https://users.scala-lang.org/u/apoigne)\
**Post date:** [November 4, 2019, 11:27am UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265/3 "2019-11-04T11:27:08Z")

</div>

Is interesting for me too. Question: can one do dynamic routing as, e.g., needed for REST (you post a resource and get a new path to access the resource9

---

<div class="post-metadata">

**Author:** ![lihaoyi](https://users.scala-lang.org/user_avatar/users.scala-lang.org/lihaoyi/32/290_2.png) [@lihaoyi](https://users.scala-lang.org/u/lihaoyi)\
**Post date:** [November 4, 2019, 1:11pm UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265/4 "2019-11-04T13:11:26Z")

</div>

> Is interesting for me too. Question: can one do dynamic routing as, e.g., needed for REST (you post a resource and get a new path to access the resource9

Cask Actors does not come with any feature for routing; you can only send messages to actors via programmatic reference to the `Actor[T]`. You’ll have to deal with resolving REST URLs to individual actors, as well as de-serializing HTTP fields into structured case classes, yourself: perhaps using a dictionary of actors with a serialization library like uPickle, or a server routing library like cask.Routes

---

<div class="post-metadata">

**Author:** ![apoigne](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@apoigne](https://users.scala-lang.org/u/apoigne)\
**Post date:** [November 5, 2019, 9:56am UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265/5 "2019-11-05T09:56:34Z")

</div>

I asked the wrong question for the email subject. From Cask Actors i was seduced to look at the main page of Cask. So the question addressed the Http framework. Does Cask provide dynamic routing?

---

<div class="post-metadata">

**Author:** ![lihaoyi](https://users.scala-lang.org/user_avatar/users.scala-lang.org/lihaoyi/32/290_2.png) [@lihaoyi](https://users.scala-lang.org/u/lihaoyi)\
**Post date:** [November 6, 2019, 2:56am UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265/6 "2019-11-06T02:56:25Z")

</div>

Yes, in two ways:

- The strings you pass to the route decorators like `@cask.get("...")` are dynamic; you can construct them from local variables, class constructor parameters, environment variables, etc.

- If you need ultimate flexibility, you can define a route that takes a `subpath = True` as documented [here](http://www.lihaoyi.com/cask/#variable-routes), take the `request.remainingPathSegments` and dispatch to your own custom logic in any way you’d like

---

<div class="post-metadata">

**Author:** ![lihaoyi](https://users.scala-lang.org/user_avatar/users.scala-lang.org/lihaoyi/32/290_2.png) [@lihaoyi](https://users.scala-lang.org/u/lihaoyi)\
**Post date:** [November 7, 2019, 5:04am UTC](https://users.scala-lang.org/t/cask-actors-cask-actors-a-tiny-lightweight-typed-scala-actor-library/5265/7 "2019-11-07T05:04:44Z")

</div>

The Cask Actors library has been moved to its own repo and artifact, [https://github.com/lihaoyi/castor](https://github.com/lihaoyi/castor)
