summaryrefslogtreecommitdiff
path: root/opendc-faas/opendc-faas-api/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-06-17 14:15:45 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-06-17 14:15:45 +0200
commit0fd7b3116fbace7deb8202d1849cece7146462a9 (patch)
treee0a152829b36532f321df63913f21fc2ee3ccdd0 /opendc-faas/opendc-faas-api/src
parent81c3b51169cc5dfafb80abb0cf55abb49646a72a (diff)
faas: Rename opendc-serverless to opendc-faas
This change renames the opendc-serverless module to opendc-faas to better distinguish between the two terms (Serverless and FaaS) and be clearer about the intent of the module. The opendc-faas module holds the code for the FaaS platform on top of OpenDC. Although this is one approach of doing serverless, serverless can also entail other services that will not be covered by this module.
Diffstat (limited to 'opendc-faas/opendc-faas-api/src')
-rw-r--r--opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSClient.kt74
-rw-r--r--opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSFunction.kt70
2 files changed, 144 insertions, 0 deletions
diff --git a/opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSClient.kt b/opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSClient.kt
new file mode 100644
index 00000000..ebda4f90
--- /dev/null
+++ b/opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSClient.kt
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.faas.api
+
+import java.util.*
+
+/**
+ * Client interface to the OpenDC FaaS platform.
+ */
+public interface FaaSClient : AutoCloseable {
+ /**
+ * Obtain the list of [FaaSFunction]s accessible by the requesting user.
+ */
+ public suspend fun queryFunctions(): List<FaaSFunction>
+
+ /**
+ * Obtain a [FaaSFunction] by its unique identifier.
+ *
+ * @param id The identifier of the flavor.
+ */
+ public suspend fun findFunction(id: UUID): FaaSFunction?
+
+ /**
+ * Obtain a [FaaSFunction] by its name.
+ *
+ * @param name The name of the function.
+ */
+ public suspend fun findFunction(name: String): FaaSFunction?
+
+ /**
+ * Create a new serverless function.
+ *
+ * @param name The name of the function.
+ * @param memorySize The memory allocated for the function in MB.
+ * @param labels The labels associated with the function.
+ * @param meta The metadata associated with the function.
+ */
+ public suspend fun newFunction(
+ name: String,
+ memorySize: Long,
+ labels: Map<String, String> = emptyMap(),
+ meta: Map<String, Any> = emptyMap()
+ ): FaaSFunction
+
+ /**
+ * Invoke the function with the specified [name].
+ */
+ public suspend fun invoke(name: String)
+
+ /**
+ * Release the resources associated with this client, preventing any further API calls.
+ */
+ public override fun close()
+}
diff --git a/opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSFunction.kt b/opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSFunction.kt
new file mode 100644
index 00000000..40f0092f
--- /dev/null
+++ b/opendc-faas/opendc-faas-api/src/main/kotlin/org/opendc/faas/api/FaaSFunction.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.faas.api
+
+import java.util.UUID
+
+/**
+ * A serverless function instance.
+ */
+public interface FaaSFunction {
+ /**
+ * The unique identifier of the function.
+ */
+ public val uid: UUID
+
+ /**
+ * The name of the function.
+ */
+ public val name: String
+
+ /**
+ * The amount of memory allocated for this function in MB.
+ */
+ public val memorySize: Long
+
+ /**
+ * The identifying labels attached to the resource.
+ */
+ public val labels: Map<String, String>
+
+ /**
+ * The non-identifying metadata attached to the resource.
+ */
+ public val meta: Map<String, Any>
+
+ /**
+ * Invoke the serverless function.
+ */
+ public suspend operator fun invoke()
+
+ /**
+ * Request the function to be deleted.
+ */
+ public suspend fun delete()
+
+ /**
+ * Refresh the local state of this object.
+ */
+ public suspend fun refresh()
+}