diff --git a/lib/client.dart b/lib/client.dart index 0f843d8..51a193e 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -8,6 +8,11 @@ import './queue.dart'; abstract class Client { Queue get queue; + /// Run a function by its [id]. + /// [method] is the HTTP method to use. + /// [path] is the path to append to the function url. + /// [input] is the input to the function. + /// Returns a map with the function response. Future> run( String id, { String method = 'post', @@ -17,6 +22,7 @@ abstract class Client { Future> subscribe( String id, { + String path = '', Map? input, int pollInterval = 3000, bool logs = false, @@ -58,13 +64,14 @@ class FalClient implements Client { @override Future> subscribe(String id, - {Map? input, + {String path = '', + Map? input, int pollInterval = 3000, // 3 seconds int timeout = 300000, // 5 minutes bool logs = false, Function(String)? onEnqueue, Function(QueueStatus)? onQueueUpdate}) async { - final enqueued = await queue.submit(id, input: input); + final enqueued = await queue.submit(id, input: input, path: path); final requestId = enqueued.requestId; if (onEnqueue != null) { @@ -94,7 +101,7 @@ class FalClient implements Client { while (true) { if (DateTime.now().isAfter(expiryTime)) { throw FalApiException( - message: 'Request timed out after \$timeout milliseconds.', + message: 'Request timed out after $timeout milliseconds.', status: 408); } final queueStatus = diff --git a/lib/queue.dart b/lib/queue.dart index ca4e067..d77bd70 100644 --- a/lib/queue.dart +++ b/lib/queue.dart @@ -125,7 +125,7 @@ class QueueClient implements Queue { Future submit(String id, {String path = '', Map? input}) async { final result = await sendRequest(id, - config: config, path: '$path/fal/queue/submit', input: input); + config: config, path: '/fal/queue/submit$path', input: input); return EnqueueResult.fromMap(result); }