-
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.
feat: GetLatestMovies [User Story 1]
- Loading branch information
Showing
9 changed files
with
1,046 additions
and
1 deletion.
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
## Movies | ||
## Movies | ||
|
||
```sh | ||
|
||
$ export PATH="$PATH:$(go env GOPATH)/bin" | ||
$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/movies.proto | ||
|
||
``` |
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,52 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/qahta0/movies/grpc/proto" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
) | ||
|
||
func getLatestMovies(client proto.MoviesServiceClient) { | ||
res, err := client.GetLatestMovies(context.Background(), &proto.LatestMoviesRequest{}) | ||
if err != nil { | ||
log.Fatalf("Could not fetch latest movies: %v", err) | ||
} | ||
for _, movie := range res.GetMovies() { | ||
fmt.Println("ID:", movie.GetId()) | ||
fmt.Println("Adult:", movie.GetAdult()) | ||
fmt.Println("Backdrop Path:", movie.GetBackdropPath()) | ||
fmt.Println("Belongs to Collection:", movie.GetBelongsToCollection()) | ||
fmt.Println("Budget:", movie.GetBudget()) | ||
fmt.Println("Homepage:", movie.GetHomepage()) | ||
fmt.Println("IMDB ID:", movie.GetImdbId()) | ||
fmt.Println("Original Language:", movie.GetOriginalLanguage()) | ||
fmt.Println("Original Title:", movie.GetOriginalTitle()) | ||
fmt.Println("Overview:", movie.GetOverview()) | ||
fmt.Println("Popularity:", movie.GetPopularity()) | ||
fmt.Println("Poster Path:", movie.GetPosterPath()) | ||
fmt.Println("Release Date:", movie.GetReleaseDate()) | ||
fmt.Println("Revenue:", movie.GetRevenue()) | ||
fmt.Println("Runtime:", movie.GetRuntime()) | ||
fmt.Println("Status:", movie.GetStatus()) | ||
fmt.Println("Tagline:", movie.GetTagline()) | ||
fmt.Println("Title:", movie.GetTitle()) | ||
fmt.Println("Video:", movie.GetVideo()) | ||
fmt.Println("Vote Average:", movie.GetVoteAverage()) | ||
fmt.Println("Vote Count:", movie.GetVoteCount()) | ||
fmt.Println("########################################################") | ||
} | ||
} | ||
|
||
func main() { | ||
connection, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
if err != nil { | ||
log.Fatalf("err: %v", err) | ||
} | ||
defer connection.Close() | ||
client := proto.NewMoviesServiceClient(connection) | ||
getLatestMovies(client) | ||
} |
Oops, something went wrong.