88 * Instantiate Algorithmia clients for calling algorithms and accessing data
99 */
1010public final class Algorithmia {
11-
11+ private static final int DEFAULT_MAX_CONNECTIONS = 10 ;
1212 private static AlgorithmiaClient defaultClient = null ;
1313
1414 private Algorithmia () {} // Not instantiable
1515
1616 /**
1717 * Returns the default Algorithmia client which will
18- * look for ALGORITHMI_API_KEY environment variable or java property
18+ * look for ALGORITHMIA_API_KEY environment variable or java property
1919 * If no key is found, then requests will be unauthenticated which only works
2020 * when making requests from an algorithm running within the Algorithmia cluster
2121 * @return an Algorithmia client
@@ -24,11 +24,22 @@ public static AlgorithmiaClient client() {
2424 return getDefaultClient ();
2525 }
2626
27+ /**
28+ * Returns the default Algorithmia client which will
29+ * look for ALGORITHMIA_API_KEY environment variable or java property
30+ * If no key is found, then requests will be unauthenticated which only works
31+ * when making requests from an algorithm running within the Algorithmia cluster
32+ * @param maxConnections max number of concurrent connections to hold open to Algorithmia
33+ * @return an Algorithmia client
34+ */
35+ public static AlgorithmiaClient client (int maxConnections ) {
36+ return new AlgorithmiaClient (null , maxConnections );
37+ }
2738
2839 /**
2940 * Builds an Algorithmia client that makes all requests with your API key
3041 * If API key is null, the default client is returned, which will
31- * look for ALGORITHMI_API_KEY environment variable or java property
42+ * look for ALGORITHMIA_API_KEY environment variable or java property
3243 * If no key is found, then requests will be unauthenticated which only works
3344 * when making requests from an algorithm running within the Algorithmia cluster
3445 * @param simpleKey API Key for simple authentication (prefixed with "sim")
@@ -38,10 +49,29 @@ public static AlgorithmiaClient client(String simpleKey) {
3849 if (simpleKey == null ) {
3950 return getDefaultClient ();
4051 } else {
41- return new AlgorithmiaClient (new SimpleAuth (simpleKey ));
52+ return new AlgorithmiaClient (new SimpleAuth (simpleKey ), DEFAULT_MAX_CONNECTIONS );
4253 }
4354 }
4455
56+ /**
57+ * Builds an Algorithmia client that makes all requests with your API key
58+ * If API key is null, the default client is returned, which will
59+ * look for ALGORITHMIA_API_KEY environment variable or java property
60+ * If no key is found, then requests will be unauthenticated which only works
61+ * when making requests from an algorithm running within the Algorithmia cluster
62+ * @param simpleKey API Key for simple authentication (prefixed with "sim")
63+ * @param maxConnections max number of concurrent connections to hold open to Algorithmia
64+ * @return an Algorithmia client
65+ */
66+ public static AlgorithmiaClient client (String simpleKey , int maxConnections ) {
67+ if (simpleKey == null ) {
68+ return getDefaultClient ();
69+ } else {
70+ return new AlgorithmiaClient (new SimpleAuth (simpleKey ), maxConnections );
71+ }
72+ }
73+
74+
4575 /**
4676 * Initialize an Algorithm object using the default client
4777 * @param algoUri the algorithm's URI, e.g., algo://user/algoname
@@ -71,7 +101,7 @@ public static DataFile file(String path) {
71101
72102 private static AlgorithmiaClient getDefaultClient () {
73103 if (defaultClient == null ) {
74- defaultClient = new AlgorithmiaClient ();
104+ defaultClient = new AlgorithmiaClient (null , DEFAULT_MAX_CONNECTIONS );
75105 }
76106 return defaultClient ;
77107 }
0 commit comments