Giter VIP home page Giter VIP logo

Comments (5)

arbarlow avatar arbarlow commented on May 22, 2024

there ins't one currently, gRPC just stops via normal signals. But I'm open to a better running that listens to signal that we can act on. It would be useful for draining subscribers too.

from lile.

nadilas avatar nadilas commented on May 22, 2024

I'll put one in with consul in one go. We can discuss from there

from lile.

nadilas avatar nadilas commented on May 22, 2024

So here's what I've got so far:
https://github.com/nadilas/lile

The templates are supposed to be updated, although I haven't done a clean install test yet. I will do that later.

first:
consul agent -dev

server:
go run service/main.go up --pubsub --consul --service_port=8555

time="2018-03-18T14:29:49+01:00" level=warning msg="Using noop pubsub provider"
time="2018-03-18T14:29:49+01:00" level=info msg="Regsitered service 'srvsearch-4485272b-a433-49cb-bf43-699369a58a77' at consul."
time="2018-03-18T14:29:49+01:00" level=info msg=Subscribing...
time="2018-03-18T14:29:49+01:00" level=info msg="Serving gRPC on localhost:8555"
time="2018-03-18T14:29:49+01:00" level=info msg="Using Zipkin HTTP tracer: http://localhost:9411/api/v1/spans"
time="2018-03-18T14:29:49+01:00" level=info msg="Prometheus metrics at http://localhost:9555/metrics"
time="2018-03-18T14:29:57+01:00" level=info msg="Captured interrupt. Exiting..."
time="2018-03-18T14:29:57+01:00" level=info msg="Shutting gRPC service 'srvsearch'"
time="2018-03-18T14:29:57+01:00" level=info msg="Deregistered service 'srvsearch-4485272b-a433-49cb-bf43-699369a58a77' at consul."
time="2018-03-18T14:29:57+01:00" level=info msg=Unsubscribing...

Process finished with exit code 0

client:

INFO[0000] Creating srvsearch gRPC client               
INFO[0000] read from service: id:"created at server"   

from lile.

arbarlow avatar arbarlow commented on May 22, 2024

Looks like a good start! Can you make a pull-request and we'll go through it?

Some first thoughts. I quite like to the move to AppConfig or something similar, but I would like to keep pubsub and consul abstracted away, I moved pubsub to https://github.com/lileio/pubsub and it's been good as internal we not use that without any gRPC logic at all.

So perhaps we should make Registery an interface? During generation we could allow the passing flags like --pubsub --consul to generate the required parts.

The shutdown hook is great and I definitely get that support into pubsub ASAP, I'm working on a v2 branch here with middleware etc https://github.com/lileio/pubsub/tree/v2

from lile.

nadilas avatar nadilas commented on May 22, 2024

Making the registry pluggable is definitely a great idea! I'll leave it for this PR as is, but I'll extract it out later this week. Would you open a lileio/registry repo? Then I can create a PR against it later this week. I'd even go as far as:
--pubsub=gcloud --registry=consul
having pluggable implementations for registry then: consul,zookeeper, etc...

My problem with AppConfig was that I couldn't get cobra/viper to read the cli arg as an env var at the same time, I'm sure it's possible I just didn't want to spend too much time on it initially. Ideal would be a setup like in this flag implementation: https://github.com/ogier/pflag.

pubsub V2 looks nice! I just moved the pubsub.Subscribe() to the main Run() in the core, but based on user flags and an interfaced pubsub initialization --pubsub=gcloud it will even be better.

PR: #32

from lile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.