Skip to content
Snippets Groups Projects
Commit 4d8f568a authored by EstebanzG's avatar EstebanzG
Browse files

Initial commit

parent 375b1225
No related branches found
No related tags found
No related merge requests found
Showing with 1168 additions and 92 deletions
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/TP.iml" filepath="$PROJECT_DIR$/.idea/TP.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
LICENSE 0 → 100644
This diff is collapsed.
# TP_gRPC
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.imt-atlantique.fr/e22gomez/tp_grpc.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.imt-atlantique.fr/e22gomez/tp_grpc/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
# UE-AD-A1-GRPC
\ No newline at end of file
FROM python:3.8-alpine
WORKDIR /app
COPY requirements.txt /app
RUN pip install -r requirements.txt
ADD . /app/
CMD ["python","-u","booking.py"]
from flask import Flask, render_template, request, jsonify, make_response
import requests
import json
from werkzeug.exceptions import NotFound
app = Flask(__name__)
PORT = 3003
HOST = '0.0.0.0'
with open('{}/databases/bookings.json'.format("."), "r") as jsf:
bookings = json.load(jsf)["bookings"]
@app.route("/", methods=['GET'])
def home():
return "<h1 style='color:blue'>Welcome to the Booking service!</h1>"
if __name__ == "__main__":
print("Server running in port %s"%(PORT))
app.run(host=HOST, port=PORT)
{
"bookings": [
{
"userid": "chris_rivers",
"dates": [
{
"date": "20151201",
"movies": ["267eedb8-0f5d-42d5-8f43-72426b9fb3e6"]
}
]
},
{
"userid": "garret_heaton",
"dates": [
{
"date": "20151201",
"movies": ["267eedb8-0f5d-42d5-8f43-72426b9fb3e6"]
},
{
"date": "20151202",
"movies": ["276c79ec-a26a-40a6-b3d3-fb242a5947b6"]
}
]
},
{
"userid": "dwight_schrute",
"dates": [
{
"date": "20151201",
"movies": ["7daf7208-be4d-4944-a3ae-c1c2f516f3e6","267eedb8-0f5d-42d5-8f43-72426b9fb3e6"]
},
{
"date": "20151205",
"movies": ["a8034f44-aee4-44cf-b32c-74cf452aaaae","276c79ec-a26a-40a6-b3d3-fb242a5947b6"]
}
]
}
]
}
\ No newline at end of file
grpcio==1.47.0
grpcio-tools==1.47.0
protobuf==3.20.1
six==1.16.0
certifi==2021.5.30
charset-normalizer==2.0.3
click==8.0.1
Flask==2.0.1
idna==3.2
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
requests==2.26.0
urllib3==1.26.6
Werkzeug==2.0.1
import grpc
import movie_pb2
import movie_pb2_grpc
def get_movie_by_id(stub,id):
movie = stub.GetMovieByID(id)
print(movie)
def get_list_movies(stub):
allmovies = stub.GetListMovies(movie_pb2.Empty())
for movie in allmovies:
print("Movie called %s" % (movie.title))
def get_movie_by_title(stub, title):
movie = stub.GetMovieByTitle(title)
print(movie)
def get_movie_by_rate(stub, rating):
movies = stub.GetMovieByRate(rating)
for movie in movies:
print("Movie called %s" % (movie.title))
def run():
# NOTE(gRPC Python Team): .close() is possible on a channel and should be
# used in circumstances in which the with statement does not fit the needs
# of the code.
with grpc.insecure_channel('localhost:3001') as channel:
stub = movie_pb2_grpc.MovieStub(channel)
print("-------------- GetMovieByID --------------")
movieid = movie_pb2.MovieID(id="a8034f44-aee4-44cf-b32c-74cf452aaaae")
get_movie_by_id(stub, movieid)
print("-------------- GetListMovies --------------")
get_list_movies(stub)
print("-------------- GetMovieByTitle --------------")
movietitle = movie_pb2.MovieTitle(title="The Good Dinosaur")
get_movie_by_title(stub, movietitle)
print("-------------- GetMovieByRate --------------")
movierate = movie_pb2.MovieRate(rating=7.4)
get_movie_by_rate(stub, movierate)
channel.close()
if __name__ == '__main__':
run()
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: movie.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0bmovie.proto\"\x15\n\x07MovieID\x12\n\n\x02id\x18\x01 \x01(\t\"\x1b\n\nMovieTitle\x12\r\n\x05title\x18\x01 \x01(\t\"\x1b\n\tMovieRate\x12\x0e\n\x06rating\x18\x01 \x01(\x02\"H\n\tMovieData\x12\r\n\x05title\x18\x01 \x01(\t\x12\x0e\n\x06rating\x18\x02 \x01(\x02\x12\x10\n\x08\x64irector\x18\x03 \x01(\t\x12\n\n\x02id\x18\x04 \x01(\t\"\x07\n\x05\x45mpty2\xb4\x01\n\x05Movie\x12&\n\x0cGetMovieByID\x12\x08.MovieID\x1a\n.MovieData\"\x00\x12\'\n\rGetListMovies\x12\x06.Empty\x1a\n.MovieData\"\x00\x30\x01\x12,\n\x0fGetMovieByTitle\x12\x0b.MovieTitle\x1a\n.MovieData\"\x00\x12,\n\x0eGetMovieByRate\x12\n.MovieRate\x1a\n.MovieData\"\x00\x30\x01\x62\x06proto3')
_MOVIEID = DESCRIPTOR.message_types_by_name['MovieID']
_MOVIETITLE = DESCRIPTOR.message_types_by_name['MovieTitle']
_MOVIERATE = DESCRIPTOR.message_types_by_name['MovieRate']
_MOVIEDATA = DESCRIPTOR.message_types_by_name['MovieData']
_EMPTY = DESCRIPTOR.message_types_by_name['Empty']
MovieID = _reflection.GeneratedProtocolMessageType('MovieID', (_message.Message,), {
'DESCRIPTOR' : _MOVIEID,
'__module__' : 'movie_pb2'
# @@protoc_insertion_point(class_scope:MovieID)
})
_sym_db.RegisterMessage(MovieID)
MovieTitle = _reflection.GeneratedProtocolMessageType('MovieTitle', (_message.Message,), {
'DESCRIPTOR' : _MOVIETITLE,
'__module__' : 'movie_pb2'
# @@protoc_insertion_point(class_scope:MovieTitle)
})
_sym_db.RegisterMessage(MovieTitle)
MovieRate = _reflection.GeneratedProtocolMessageType('MovieRate', (_message.Message,), {
'DESCRIPTOR' : _MOVIERATE,
'__module__' : 'movie_pb2'
# @@protoc_insertion_point(class_scope:MovieRate)
})
_sym_db.RegisterMessage(MovieRate)
MovieData = _reflection.GeneratedProtocolMessageType('MovieData', (_message.Message,), {
'DESCRIPTOR' : _MOVIEDATA,
'__module__' : 'movie_pb2'
# @@protoc_insertion_point(class_scope:MovieData)
})
_sym_db.RegisterMessage(MovieData)
Empty = _reflection.GeneratedProtocolMessageType('Empty', (_message.Message,), {
'DESCRIPTOR' : _EMPTY,
'__module__' : 'movie_pb2'
# @@protoc_insertion_point(class_scope:Empty)
})
_sym_db.RegisterMessage(Empty)
_MOVIE = DESCRIPTOR.services_by_name['Movie']
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_MOVIEID._serialized_start=15
_MOVIEID._serialized_end=36
_MOVIETITLE._serialized_start=38
_MOVIETITLE._serialized_end=65
_MOVIERATE._serialized_start=67
_MOVIERATE._serialized_end=94
_MOVIEDATA._serialized_start=96
_MOVIEDATA._serialized_end=168
_EMPTY._serialized_start=170
_EMPTY._serialized_end=177
_MOVIE._serialized_start=180
_MOVIE._serialized_end=360
# @@protoc_insertion_point(module_scope)
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import movie_pb2 as movie__pb2
class MovieStub(object):
"""Missing associated documentation comment in .proto file."""
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.GetMovieByID = channel.unary_unary(
'/Movie/GetMovieByID',
request_serializer=movie__pb2.MovieID.SerializeToString,
response_deserializer=movie__pb2.MovieData.FromString,
)
self.GetListMovies = channel.unary_stream(
'/Movie/GetListMovies',
request_serializer=movie__pb2.Empty.SerializeToString,
response_deserializer=movie__pb2.MovieData.FromString,
)
self.GetMovieByTitle = channel.unary_unary(
'/Movie/GetMovieByTitle',
request_serializer=movie__pb2.MovieTitle.SerializeToString,
response_deserializer=movie__pb2.MovieData.FromString,
)
self.GetMovieByRate = channel.unary_stream(
'/Movie/GetMovieByRate',
request_serializer=movie__pb2.MovieRate.SerializeToString,
response_deserializer=movie__pb2.MovieData.FromString,
)
class MovieServicer(object):
"""Missing associated documentation comment in .proto file."""
def GetMovieByID(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetListMovies(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetMovieByTitle(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetMovieByRate(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_MovieServicer_to_server(servicer, server):
rpc_method_handlers = {
'GetMovieByID': grpc.unary_unary_rpc_method_handler(
servicer.GetMovieByID,
request_deserializer=movie__pb2.MovieID.FromString,
response_serializer=movie__pb2.MovieData.SerializeToString,
),
'GetListMovies': grpc.unary_stream_rpc_method_handler(
servicer.GetListMovies,
request_deserializer=movie__pb2.Empty.FromString,
response_serializer=movie__pb2.MovieData.SerializeToString,
),
'GetMovieByTitle': grpc.unary_unary_rpc_method_handler(
servicer.GetMovieByTitle,
request_deserializer=movie__pb2.MovieTitle.FromString,
response_serializer=movie__pb2.MovieData.SerializeToString,
),
'GetMovieByRate': grpc.unary_stream_rpc_method_handler(
servicer.GetMovieByRate,
request_deserializer=movie__pb2.MovieRate.FromString,
response_serializer=movie__pb2.MovieData.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'Movie', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
# This class is part of an EXPERIMENTAL API.
class Movie(object):
"""Missing associated documentation comment in .proto file."""
@staticmethod
def GetMovieByID(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/Movie/GetMovieByID',
movie__pb2.MovieID.SerializeToString,
movie__pb2.MovieData.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def GetListMovies(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_stream(request, target, '/Movie/GetListMovies',
movie__pb2.Empty.SerializeToString,
movie__pb2.MovieData.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def GetMovieByTitle(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/Movie/GetMovieByTitle',
movie__pb2.MovieTitle.SerializeToString,
movie__pb2.MovieData.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def GetMovieByRate(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_stream(request, target, '/Movie/GetMovieByRate',
movie__pb2.MovieRate.SerializeToString,
movie__pb2.MovieData.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
grpcio==1.47.0
grpcio-tools==1.47.0
protobuf==3.20.1
six==1.16.0
certifi==2021.5.30
charset-normalizer==2.0.3
click==8.0.1
Flask==2.0.1
idna==3.2
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
requests==2.26.0
urllib3==1.26.6
Werkzeug==2.0.1
version: "3.9"
services:
movie:
build: ./movie/
ports:
- "3001:3001"
showtime:
build: ./showtime/
ports:
- "3002:3002"
booking:
build: ./booking/
ports:
- "3003:3003"
user:
build: ./user/
ports:
- "3004:3004"
FROM python:3.8-alpine
WORKDIR /app
COPY requirements.txt /app
RUN pip install -r requirements.txt
ADD . /app/
CMD ["python","-u","movie.py"]
{
"movies": [
{
"title": "The Good Dinosaur",
"rating": 7.4,
"director": "Peter Sohn",
"id": "720d006c-3a57-4b6a-b18f-9b713b073f3c"
},
{
"title": "The Martian",
"rating": 8.2,
"director": "Ridley Scott",
"id": "a8034f44-aee4-44cf-b32c-74cf452aaaae"
},
{
"title": "The Night Before",
"rating": 7.4,
"director": "Jonathan Levine",
"id": "96798c08-d19b-4986-a05d-7da856efb697"
},
{
"title": "Creed",
"rating": 8.8,
"director": "Ryan Coogler",
"id": "267eedb8-0f5d-42d5-8f43-72426b9fb3e6"
},
{
"title": "Victor Frankenstein",
"rating": 6.4,
"director": "Paul McGuigan",
"id": "7daf7208-be4d-4944-a3ae-c1c2f516f3e6"
},
{
"title": "The Danish Girl",
"rating": 5.3,
"director": "Tom Hooper",
"id": "276c79ec-a26a-40a6-b3d3-fb242a5947b6"
},
{
"title": "Spectre",
"rating": 7.1,
"director": "Sam Mendes",
"id": "39ab85e5-5e8e-4dc5-afea-65dc368bd7ab"
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment