Skip to content

Commit 6c1a231

Browse files
authored
Merge pull request #11 from wanjunlei/master
add support for state store
2 parents ea84f0a + 7184e1f commit 6c1a231

File tree

9 files changed

+205
-160
lines changed

9 files changed

+205
-160
lines changed

functions-framework-api/pom.xml

Lines changed: 155 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -13,156 +13,164 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
-->
16-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
17-
<modelVersion>4.0.0</modelVersion>
18-
<dependencies>
19-
<dependency>
20-
<groupId>io.cloudevents</groupId>
21-
<artifactId>cloudevents-api</artifactId>
22-
<version>2.3.0</version>
23-
<scope>compile</scope>
24-
</dependency>
25-
</dependencies>
16+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
18+
<modelVersion>4.0.0</modelVersion>
19+
<dependencies>
20+
<dependency>
21+
<groupId>io.cloudevents</groupId>
22+
<artifactId>cloudevents-api</artifactId>
23+
<version>2.4.2</version>
24+
<scope>compile</scope>
25+
</dependency>
26+
<dependency>
27+
<groupId>io.dapr</groupId>
28+
<artifactId>dapr-sdk</artifactId>
29+
<version>1.8.0</version>
30+
</dependency>
31+
</dependencies>
2632

27-
<parent>
28-
<groupId>org.sonatype.oss</groupId>
29-
<artifactId>oss-parent</artifactId>
30-
<version>9</version>
31-
</parent>
33+
<parent>
34+
<groupId>org.sonatype.oss</groupId>
35+
<artifactId>oss-parent</artifactId>
36+
<version>9</version>
37+
</parent>
3238

33-
<groupId>dev.openfunction.functions</groupId>
34-
<artifactId>functions-framework-api</artifactId>
35-
<version>1.1.0-SNAPSHOT</version>
39+
<groupId>dev.openfunction.functions</groupId>
40+
<artifactId>functions-framework-api</artifactId>
41+
<version>1.1.0-SNAPSHOT</version>
3642

37-
<properties>
38-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
39-
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
40-
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
41-
<junit.jupiter.version>5.3.2</junit.jupiter.version>
42-
</properties>
43+
<properties>
44+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
45+
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
46+
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
47+
<junit.jupiter.version>5.3.2</junit.jupiter.version>
48+
</properties>
4349

44-
<licenses>
45-
<license>
46-
<name>Apache License, Version 2.0</name>
47-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
48-
<distribution>repo</distribution>
49-
</license>
50-
</licenses>
50+
<licenses>
51+
<license>
52+
<name>Apache License, Version 2.0</name>
53+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
54+
<distribution>repo</distribution>
55+
</license>
56+
</licenses>
5157

52-
<build>
53-
<plugins>
54-
<plugin>
55-
<groupId>org.apache.maven.plugins</groupId>
56-
<artifactId>maven-compiler-plugin</artifactId>
57-
<version>${maven-compiler-plugin.version}</version>
58-
<configuration>
59-
<source>11</source>
60-
<target>11</target>
61-
</configuration>
62-
</plugin>
63-
<plugin>
64-
<groupId>org.apache.maven.plugins</groupId>
65-
<artifactId>maven-javadoc-plugin</artifactId>
66-
<version>${maven-javadoc-plugin.version}</version>
67-
</plugin>
68-
<plugin>
69-
<groupId>org.apache.maven.plugins</groupId>
70-
<artifactId>maven-source-plugin</artifactId>
71-
<version>3.2.1</version>
72-
<executions>
73-
<execution>
74-
<id>attach-sources</id>
75-
<goals>
76-
<goal>jar</goal>
77-
</goals>
78-
</execution>
79-
</executions>
80-
</plugin>
81-
<plugin>
82-
<groupId>org.apache.maven.plugins</groupId>
83-
<artifactId>maven-release-plugin</artifactId>
84-
<version>2.5.3</version>
85-
<executions>
86-
<execution>
87-
<id>default</id>
88-
<goals>
89-
<goal>perform</goal>
90-
</goals>
91-
<configuration>
92-
<pomFileName>functions-framework-api/pom.xml</pomFileName>
93-
</configuration>
94-
</execution>
95-
</executions>
96-
</plugin>
97-
<plugin>
98-
<groupId>org.sonatype.plugins</groupId>
99-
<artifactId>nexus-staging-maven-plugin</artifactId>
100-
<version>1.6.7</version>
101-
<extensions>true</extensions>
102-
<configuration>
103-
<serverId>ossrh</serverId>
104-
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
105-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
106-
</configuration>
107-
</plugin>
108-
<plugin>
109-
<groupId>org.apache.maven.plugins</groupId>
110-
<artifactId>maven-gpg-plugin</artifactId>
111-
<version>1.5</version>
112-
<executions>
113-
<execution>
114-
<id>sign-artifacts</id>
115-
<phase>verify</phase>
116-
<goals>
117-
<goal>sign</goal>
118-
</goals>
119-
<configuration>
120-
<gpgArguments>
121-
<arg>--pinentry-mode</arg>
122-
<arg>loopback</arg>
123-
</gpgArguments>
124-
</configuration>
125-
</execution>
126-
</executions>
127-
</plugin>
128-
</plugins>
129-
<pluginManagement>
130-
<plugins>
131-
<plugin>
132-
<artifactId>maven-javadoc-plugin</artifactId>
133-
<version>${maven-javadoc-plugin.version}</version>
134-
<configuration>
135-
<quiet>true</quiet>
136-
<notimestamp>true</notimestamp>
137-
<encoding>UTF-8</encoding>
138-
<docencoding>UTF-8</docencoding>
139-
<charset>UTF-8</charset>
140-
<additionalOptions>
141-
<additionalOption>-XDignore.symbol.file</additionalOption>
142-
</additionalOptions>
143-
<linksource>true</linksource>
144-
<source>8</source>
145-
<detectJavaApiLink>false</detectJavaApiLink>
146-
</configuration>
147-
<executions>
148-
<execution>
149-
<id>attach-docs</id>
150-
<phase>post-integration-test</phase>
151-
<goals><goal>jar</goal></goals>
152-
</execution>
153-
</executions>
154-
</plugin>
155-
</plugins>
156-
</pluginManagement>
157-
</build>
158-
<distributionManagement>
159-
<snapshotRepository>
160-
<id>ossrh</id>
161-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
162-
</snapshotRepository>
163-
<repository>
164-
<id>ossrh</id>
165-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
166-
</repository>
167-
</distributionManagement>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-compiler-plugin</artifactId>
63+
<version>${maven-compiler-plugin.version}</version>
64+
<configuration>
65+
<source>11</source>
66+
<target>11</target>
67+
</configuration>
68+
</plugin>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-javadoc-plugin</artifactId>
72+
<version>${maven-javadoc-plugin.version}</version>
73+
</plugin>
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-source-plugin</artifactId>
77+
<version>3.2.1</version>
78+
<executions>
79+
<execution>
80+
<id>attach-sources</id>
81+
<goals>
82+
<goal>jar</goal>
83+
</goals>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-release-plugin</artifactId>
90+
<version>2.5.3</version>
91+
<executions>
92+
<execution>
93+
<id>default</id>
94+
<goals>
95+
<goal>perform</goal>
96+
</goals>
97+
<configuration>
98+
<pomFileName>functions-framework-api/pom.xml</pomFileName>
99+
</configuration>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
<plugin>
104+
<groupId>org.sonatype.plugins</groupId>
105+
<artifactId>nexus-staging-maven-plugin</artifactId>
106+
<version>1.6.7</version>
107+
<extensions>true</extensions>
108+
<configuration>
109+
<serverId>ossrh</serverId>
110+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
111+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
112+
</configuration>
113+
</plugin>
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-gpg-plugin</artifactId>
117+
<version>1.5</version>
118+
<executions>
119+
<execution>
120+
<id>sign-artifacts</id>
121+
<phase>verify</phase>
122+
<goals>
123+
<goal>sign</goal>
124+
</goals>
125+
<configuration>
126+
<gpgArguments>
127+
<arg>--pinentry-mode</arg>
128+
<arg>loopback</arg>
129+
</gpgArguments>
130+
</configuration>
131+
</execution>
132+
</executions>
133+
</plugin>
134+
</plugins>
135+
<pluginManagement>
136+
<plugins>
137+
<plugin>
138+
<artifactId>maven-javadoc-plugin</artifactId>
139+
<version>${maven-javadoc-plugin.version}</version>
140+
<configuration>
141+
<quiet>true</quiet>
142+
<notimestamp>true</notimestamp>
143+
<encoding>UTF-8</encoding>
144+
<docencoding>UTF-8</docencoding>
145+
<charset>UTF-8</charset>
146+
<additionalOptions>
147+
<additionalOption>-XDignore.symbol.file</additionalOption>
148+
</additionalOptions>
149+
<linksource>true</linksource>
150+
<source>8</source>
151+
<detectJavaApiLink>false</detectJavaApiLink>
152+
</configuration>
153+
<executions>
154+
<execution>
155+
<id>attach-docs</id>
156+
<phase>post-integration-test</phase>
157+
<goals>
158+
<goal>jar</goal>
159+
</goals>
160+
</execution>
161+
</executions>
162+
</plugin>
163+
</plugins>
164+
</pluginManagement>
165+
</build>
166+
<distributionManagement>
167+
<snapshotRepository>
168+
<id>ossrh</id>
169+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
170+
</snapshotRepository>
171+
<repository>
172+
<id>ossrh</id>
173+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
174+
</repository>
175+
</distributionManagement>
168176
</project>

functions-framework-api/src/main/java/dev/openfunction/functions/Context.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package dev.openfunction.functions;
1818

1919
import io.cloudevents.CloudEvent;
20+
import io.dapr.client.DaprClient;
2021

2122
import java.util.Map;
2223

@@ -95,4 +96,13 @@ public interface Context {
9596
* @return Outputs
9697
*/
9798
Map<String, Component> getOutputs();
99+
100+
/**
101+
* getDaprClient return a dapr client, so that use user
102+
* can call the dapr API directly.
103+
* Be carefully, the dapr client maybe null;
104+
*
105+
* @return Dapr client
106+
*/
107+
DaprClient getDaprClient();
98108
}

functions-framework-api/src/main/java/dev/openfunction/functions/Routable.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* An object that can route the specified http request to the specified function.
55
*/
66
public abstract class Routable {
7-
private static final String METHOD_DELETE = "DELETE";
8-
private static final String METHOD_HEAD = "HEAD";
9-
private static final String METHOD_GET = "GET";
10-
private static final String METHOD_PATCH = "PATCH";
11-
private static final String METHOD_POST = "POST";
12-
private static final String METHOD_PUT = "PUT";
7+
public static final String METHOD_DELETE = "DELETE";
8+
public static final String METHOD_HEAD = "HEAD";
9+
public static final String METHOD_GET = "GET";
10+
public static final String METHOD_PATCH = "PATCH";
11+
public static final String METHOD_POST = "POST";
12+
public static final String METHOD_PUT = "PUT";
1313

1414
/**
1515
* Get the supported http methods.

functions-framework-invoker/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@
191191
<artifactId>commons-beanutils</artifactId>
192192
<version>1.9.4</version>
193193
</dependency>
194+
<dependency>
195+
<groupId>com.fasterxml.jackson.core</groupId>
196+
<artifactId>jackson-databind</artifactId>
197+
<version>2.14.2</version>
198+
</dependency>
194199
</dependencies>
195200

196201
<build>

functions-framework-invoker/src/main/java/dev/openfunction/invoker/context/FunctionContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class FunctionContext {
2626
private String version;
2727
private Map<String, Component> inputs;
2828
private Map<String, Component> outputs;
29+
private Map<String, Component> states;
2930
private String runtime;
3031
private String port;
3132

@@ -108,4 +109,12 @@ public void setPluginsTracing(TracingConfig pluginsTracing) {
108109
public boolean isTracingEnabled() {
109110
return pluginsTracing != null && pluginsTracing.isEnabled();
110111
}
112+
113+
public Map<String, Component> getStates() {
114+
return states;
115+
}
116+
117+
public void setStates(Map<String, Component> states) {
118+
this.states = states;
119+
}
111120
}

0 commit comments

Comments
 (0)