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

back: first services #12

Merged
merged 12 commits into from
Mar 3, 2019
Merged

back: first services #12

merged 12 commits into from
Mar 3, 2019

Conversation

daved
Copy link
Member

@daved daved commented Feb 27, 2019

Fixes #8

@daved daved changed the title WIP: back: first services back: first services Feb 27, 2019
@daved
Copy link
Member Author

daved commented Feb 27, 2019

This is done.
@champagneabuelo Please have a look.

Copy link
Collaborator

@toyotathon toyotathon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this review! This currently looks good to me; I added a comment concerning the sigmon object, and you answered my other question concerning the AddVoucher method. I like the idea of separating the user and auth services and having this voucher method of messaging between them.

}

func run() error {
sm := sigmon.New(nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does sigmon do in this context? Will this be the web server we use?

@daved
Copy link
Member Author

daved commented Mar 1, 2019

sigmon is a simple way to handle system signals. It allows us to type {Ctrl-C} to send SIGTERM to the application and have the application take some action. The Set method takes a callback which runs when any system signal is received. That callback must take a value representing that system signal in order for the logic to conditionally take different actions. In this case, all signals result in the graceful shutdown of the GRPC server. For more info: https://github.com/codemodus/sigmon

This application is a demonstration of a running GRPC server. It's only purpose for now is as an example of how to add services to the GRPC server. Each commit in this branch takes a small step toward adding one of two services and then wiring them together.

In order to get the "free HTTP" mentioned, we will leverage GRPC-Gateway. An instance of a gateway is created, with the relevant services registered to it. This is then served on it's own separate port. In effect, the GRPC is then a backend to the HTTP backend.

If needed later on, we can add a GraphQL termination point. Though, this would likely mean adding another set of messages which are more highly related/intermingled. Similarly, if HTTP2 is not sufficient for our use case at mitigating transport costs, but GraphQL remains not worth setting up, specific "view messages" could be added as needed. Depending on the circumstances at the time, either of these two systems can be added as a standalone server on it's own port using the GRPC server as a backend, added to some subset of paths (routes) in the then existing HTTP server, or as a standalone server using the HTTP server as a backend. The last option might be dumb, and it might help take care of the whole GraphQL caching issue. I'm not sure; It's late.

@daved
Copy link
Member Author

daved commented Mar 2, 2019

@champagneabuelo I just added a frontend file server. To try it out, run go run *.go from back/cmd/openbsrv or build as you might any Go app and run the artifact from that same directory.

The front files are currently being served using a relative path, but I'll work out how to run the project from anywhere. It will likely require the usage of some flag or envvar (preferably a flag). A good test file is http://localhost:4244/css/main.css

@daved
Copy link
Member Author

daved commented Mar 2, 2019

I'll merge this once I get an OK on the temporary front server.

@daved daved requested a review from toyotathon March 2, 2019 02:24
@toyotathon
Copy link
Collaborator

Working on getting in running locally now! Will report back soon.

@toyotathon
Copy link
Collaborator

After running the go run *.go command, this was the output I got:
{0 false false [] <nil> <nil> <nil> <nil> <nil> {} [] 0}

@daved
Copy link
Member Author

daved commented Mar 2, 2019

That is a random generated type that I selected to print just to prove that the generated code was working. Did it also give a notice about gracefully stopping the application?

@daved daved removed the request for review from toyotathon March 3, 2019 06:28
@daved daved merged commit 7422a59 into OpenEugene:master Mar 3, 2019
@daved daved deleted the new/back-firstsvcs-a branch March 3, 2019 06:36
@daved daved added the end: back label Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants