Skip to content

Support timeouts for FalClient::subscribe #9

Description

@Avinm

Would it be possible to support timeouts for the FalClient::subscribe method? Currently, neither SubscribeOptions nor QueueSubscribeOptions provide the ability to supply a timeout.

Ideally a timeout configuration would mean that the client would send it as the start_timeout:

start_timeout:
Server-side deadline in seconds, sent as the X-Fal-Request-Timeout header. This sets an absolute wall-clock deadline, computed once when the request is submitted. The server checks this deadline before processing begins. If the deadline has passed, the server returns a 504 without processing the request.

... as documented at https://fal.ai/docs/documentation/model-apis/inference/queue

Furthermore, it should also use the timeout to do a bounded wait on this future in QueueClientImpl.kt

public class QueueClientImpl implements QueueClient {
    ...
    public Completed subscribeToStatus(@Nonnull String endpointId, @Nonnull QueueSubscribeptions options)  {
        ...
        final var listener = new EventSourceListener {
            ...
            try {
                return future.get(); // -> future.get(start_timeout + some buffer?);
            } catch (Exception ex) {
                throw new FalException(ex.getMessage(), ex, options.getRequestId());
            }
        }
    }
}

Happy to contribute if this makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions