Skip to content

Commit

Permalink
fix: request url path
Browse files Browse the repository at this point in the history
  • Loading branch information
drochetti committed Nov 3, 2023
1 parent 4472cb9 commit 70ed1b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, dynamic>> run(
String id, {
String method = 'post',
Expand All @@ -17,6 +22,7 @@ abstract class Client {

Future<Map<String, dynamic>> subscribe(
String id, {
String path = '',
Map<String, dynamic>? input,
int pollInterval = 3000,
bool logs = false,
Expand Down Expand Up @@ -58,13 +64,14 @@ class FalClient implements Client {

@override
Future<Map<String, dynamic>> subscribe(String id,
{Map<String, dynamic>? input,
{String path = '',
Map<String, dynamic>? 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) {
Expand Down Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion lib/queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class QueueClient implements Queue {
Future<EnqueueResult> submit(String id,
{String path = '', Map<String, dynamic>? 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);
}

Expand Down

0 comments on commit 70ed1b1

Please sign in to comment.