forked from micronaut-projects/micronaut-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9550ba
commit 2878d88
Showing
19 changed files
with
211 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 8 additions & 11 deletions
19
...ambda/src/main/groovy/example/Book.groovy → ...da/src/main/groovy/example/Message.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
/* | ||
* Copyright 2017 original authors | ||
* | ||
* Copyright 2018 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* limitations under the License. | ||
*/ | ||
package example | ||
|
||
import groovy.transform.EqualsAndHashCode | ||
|
||
/** | ||
* @author Graeme Rocher | ||
* @author graemerocher | ||
* @since 1.0 | ||
*/ | ||
@EqualsAndHashCode | ||
class Book { | ||
String title | ||
class Message { | ||
String text | ||
} |
24 changes: 24 additions & 0 deletions
24
examples/hello-world-lambda/src/main/groovy/example/Person.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2018 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package example | ||
|
||
/** | ||
* @author graemerocher | ||
* @since 1.0 | ||
*/ | ||
class Person { | ||
String name | ||
} |
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
examples/hello-world-lambda/src/test/groovy/example/HelloClient.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2018 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package example | ||
|
||
import io.micronaut.function.client.FunctionClient | ||
import io.reactivex.Single | ||
|
||
import javax.inject.Named | ||
import javax.validation.constraints.NotNull | ||
|
||
/** | ||
* @author graemerocher | ||
* @since 1.0 | ||
*/ | ||
@FunctionClient | ||
interface HelloClient { | ||
|
||
@Named("hello-world") | ||
Single<Message> hello(@NotNull Person person) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
function-client/src/main/java/io/micronaut/function/client/FunctionDefinitionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2018 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.function.client; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Interface for a type that provides function definitions | ||
* | ||
* @author graemerocher | ||
* @since 1.0 | ||
*/ | ||
public interface FunctionDefinitionProvider { | ||
|
||
/** | ||
* @return The {@link FunctionDefinition} instances | ||
*/ | ||
Collection<FunctionDefinition> getFunctionDefinitions(); | ||
} |
63 changes: 63 additions & 0 deletions
63
...ent/src/main/java/io/micronaut/function/client/local/LocalFunctionDefinitionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2018 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.function.client.local; | ||
|
||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.function.LocalFunctionRegistry; | ||
import io.micronaut.function.client.FunctionDefinition; | ||
import io.micronaut.function.client.FunctionDefinitionProvider; | ||
import io.micronaut.runtime.server.EmbeddedServer; | ||
|
||
import javax.inject.Singleton; | ||
import java.net.URI; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author graemerocher | ||
* @since 1.0 | ||
*/ | ||
@Requires(beans = {EmbeddedServer.class, LocalFunctionRegistry.class}) | ||
@Singleton | ||
public class LocalFunctionDefinitionProvider implements FunctionDefinitionProvider { | ||
|
||
private final EmbeddedServer embeddedServer; | ||
private final LocalFunctionRegistry localFunctionRegistry; | ||
|
||
public LocalFunctionDefinitionProvider(EmbeddedServer embeddedServer, LocalFunctionRegistry localFunctionRegistry) { | ||
this.embeddedServer = embeddedServer; | ||
this.localFunctionRegistry = localFunctionRegistry; | ||
} | ||
|
||
@Override | ||
public Collection<FunctionDefinition> getFunctionDefinitions() { | ||
Map<String, URI> availableFunctions = localFunctionRegistry.getAvailableFunctions(); | ||
return availableFunctions.entrySet().stream().map((Function<Map.Entry<String, URI>, FunctionDefinition>) stringURIEntry -> new FunctionDefinition() { | ||
@Override | ||
public String getName() { | ||
return stringURIEntry.getKey(); | ||
} | ||
|
||
@Override | ||
public Optional<URI> getURI() { | ||
return Optional.of(embeddedServer.getURI().resolve(stringURIEntry.getValue())); | ||
} | ||
}).collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.