#service #agent #framework #message

memfault-ssf

Supporting crate for the Memfault memfaultd embedded Linux agent

9 stable releases

new 1.20.0 Apr 10, 2025
1.19.0 Mar 31, 2025
1.18.0 Feb 4, 2025
1.16.1 Jan 7, 2025
1.14.0 Sep 19, 2024

#1018 in Embedded development

Download history 98/week @ 2025-01-04 16/week @ 2025-01-11 216/week @ 2025-02-01 37/week @ 2025-02-08 9/week @ 2025-02-15 87/week @ 2025-03-15 22/week @ 2025-03-22 114/week @ 2025-03-29 121/week @ 2025-04-05

344 downloads per month
Used in memfaultd

Custom license

48KB
1K SLoC

Simple Service Framework

This library provides a simple abstraction to implement a service oriented architecture in a non-async Rust program.

Each service runs in its own thread with a processing loop waiting on a channel.

This library provides a few essential traits:

  • Service: a trait implemented by services
  • Message: a trait implemented by messages
  • Handler<M: Message>: a trait implemented by services that can handle messages of type M.

We provide some important structs to deploy the services:

  • ServiceThread: will start and run a service inside a dedicated thread. It returns a Mailbox.
  • Mailbox<S: Service>: a lightweight (cheap to clone()) handle to send messages to a thread.
  • Scheduler: a utility thread which keeps a schedule of messages that need to be sent at fixed intervals.

As well as important testing utilities that are a big part of the value provided by this framework:

  • ServiceJig: a way to run a service inside a test without using threads. The test can precisely decide when messages should be delivered and inspect the state of the service at any time.
  • ServiceMock: a service mock. Use this when you just need a place where to send messages. Your test can then verify that the right messages were sent to the mock.

memfault-ssf

Internal crate for use by the memfaultd crate, not for general use.

Dependencies

~4–12MB
~135K SLoC