-
-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(grpc): initial grpc server. (#253)
* feat(grpc): initial grpc server. * refactor(vendor): add missing vendor. * fix testing Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Loading branch information
Showing
102 changed files
with
21,797 additions
and
442 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,5 +126,5 @@ Retry: | |
goto Retry | ||
} | ||
|
||
return true | ||
return !isError | ||
} |
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
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,35 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
pb "github.com/appleboy/gorush/rpc/proto" | ||
"golang.org/x/net/context" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
const ( | ||
address = "localhost:50051" | ||
defaultName = "world" | ||
) | ||
|
||
func main() { | ||
// Set up a connection to the server. | ||
conn, err := grpc.Dial(address, grpc.WithInsecure()) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
c := pb.NewGorushClient(conn) | ||
|
||
r, err := c.Send(context.Background(), &pb.NotificationRequest{ | ||
Platform: 2, | ||
Tokens: []string{"1234567890"}, | ||
Message: "test message", | ||
}) | ||
if err != nil { | ||
log.Fatalf("could not greet: %v", err) | ||
} | ||
log.Printf("Success: %t\n", r.Success) | ||
log.Printf("Count: %d\n", r.Counts) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 @@ | ||
syntax = "proto3"; | ||
|
||
package proto; | ||
|
||
message NotificationRequest { | ||
repeated string tokens = 1; | ||
int32 platform = 2; | ||
string message = 3; | ||
string title = 4; | ||
string topic = 5; | ||
string key = 6; | ||
} | ||
|
||
message NotificationReply { | ||
bool success = 1; | ||
int32 counts = 2; | ||
} | ||
|
||
service Gorush { | ||
rpc Send (NotificationRequest) returns (NotificationReply) {} | ||
} | ||
|
Oops, something went wrong.