Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Proto files from an URL #204

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ hs_err_pid*
# Some other generated folders/files
**/components/redis.yaml
**/components/redis_messagebus.yaml
/proto/dapr
/proto/daprclient
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<grpc.version>1.25.0</grpc.version>
<protobuf.version>3.11.0</protobuf.version>
<protoc.version>3.10.0</protoc.version>
<dapr.proto.url>https://raw.githubusercontent.com/dapr/dapr/master/pkg/proto/dapr/dapr.proto</dapr.proto.url>
<dapr.client.proto.url>https://raw.githubusercontent.com/dapr/dapr/master/pkg/proto/daprclient/daprclient.proto</dapr.client.proto.url>
<os-maven-plugin.version>1.6.2</os-maven-plugin.version>
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
Expand Down
106 changes: 0 additions & 106 deletions proto/dapr/dapr.proto

This file was deleted.

76 changes: 0 additions & 76 deletions proto/daprclient/daprclient.proto

This file was deleted.

35 changes: 35 additions & 0 deletions sdk-autogen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@

<build>
<plugins>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<id>getDaprProto</id>
<!-- the wget goal actually binds itself to this phase by default -->
<phase>initialize</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>${dapr.proto.url}</url>
<outputFileName>dapr.proto</outputFileName>
<!-- default target location, just to demonstrate the parameter -->
<outputDirectory>${protobuf.input.directory}/dapr</outputDirectory>
</configuration>
</execution>
<execution>
<id>getDaprClientProto</id>
<!-- the wget goal actually binds itself to this phase by default -->
<phase>initialize</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>${dapr.client.proto.url}</url>
<outputFileName>daprclient.proto</outputFileName>
<!-- default target location, just to demonstrate the parameter -->
<outputDirectory>${protobuf.input.directory}/daprclient</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package io.dapr.it.methodinvoke.http;

import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
* SpringBoot Controller to handle input binding.
*/
@RestController
public class MethodInvokeController {

private static final Map<Integer,String> messagesReceived = new HashMap<>();
private static final List<Person> persons= new ArrayList<>();

@PostMapping("/messages")
public void postMessages(@RequestBody String message){
System.out.println("Controller got message: " + message);
final Optional<Integer> maxKey = messagesReceived.keySet().stream().max(Integer::compareTo);
final Integer key = maxKey.orElse(-1)+1;
messagesReceived.put(key,message);
System.out.println("Controller save the message: " + message);
}

@PutMapping(path = "/messages/{messageId}")
public void putMessages(@PathVariable Integer messageId, @RequestBody String message){
messagesReceived.put(messageId,message);
}

@DeleteMapping(path = "/messages/{messageId}")
public void deleteMessages(@PathVariable Integer messageId){
messagesReceived.remove(messageId);
}

@GetMapping(path = "/messages")
public Map<Integer, String> getMessages() {
return messagesReceived;
}

@PostMapping("/persons")
public void postPerson(@RequestBody Person person){
System.out.println("Controller get person: " + person);
final Optional<Integer> max = persons.stream().map(person1 -> person1.getId()).max(Integer::compareTo);
final Integer key = max.orElse(-1)+1;
person.setId(key);
persons.add(person);
System.out.println("Controller save the person: " + person);
}

@PutMapping(path = "/persons/{personId}")
public void putPerson(@PathVariable Integer personId, @RequestBody Person person){
final Optional<Person> auxPerson = persons.stream().filter(person1 -> person1.getId() == personId).findFirst();
if(auxPerson.isPresent()){
auxPerson.get().setName(person.getName());
auxPerson.get().setLastName(person.getLastName());
auxPerson.get().setBirthDate(person.getBirthDate());
}
}

@DeleteMapping(path = "/persons/{personId}")
public void deletePerson(@PathVariable Integer personId){
final Optional<Person> auxPerson = persons.stream().filter(person1 -> person1.getId() == personId).findFirst();
if(auxPerson.isPresent()) {
persons.remove(auxPerson.get());
}
}

@GetMapping(path = "/persons")
public List<Person> getPersons() {
return persons;
}
}
Loading