Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v1.1.1 - 2025-08-06

- Updated `actor.start` documentation to reflect current use case.
- Added `actor.set_timeout` function for setting `Builder` timeout.

## v1.1.0 - 2025-08-05

- The `call` function in the `gleam/otp/actor` module gains the labels
Expand Down
18 changes: 11 additions & 7 deletions src/gleam/otp/actor.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,16 @@ pub fn new_with_initialiser(
)
}

/// Set the timeout for a `Builder` in milliseconds. This timeout value
/// determines how long the actor should await intitialisation before returning
/// an error.
pub fn set_timeout(
timeout: Int,
builder: Builder(state, message, return),
) -> Builder(state, message, return) {
Builder(..builder, initialisation_timeout: timeout)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, I have made a mistake. This isn't needed as the new_with_initialiser function takes the timeout as an argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! I'll take that out then.


/// Set the message handler for the actor. This callback function will be
/// called each time the actor receives a message.
///
Expand Down Expand Up @@ -588,13 +598,7 @@ type StartInitMessage(data) {
Mon(process.Down)
}

/// Start an actor from a given specification. If the actor's `init` function
/// returns an error or does not return within `init_timeout` then an error is
/// returned.
///
/// If you do not need to specify the initialisation behaviour of your actor
/// consider using the `start` function.
///
/// Starts an actor from a given `Builder`. On failure, `start` returns a `StartError`
pub fn start(
builder: Builder(state, msg, return),
) -> Result(Started(return), StartError) {
Expand Down