Comments (2)
Had a go at this, haven't had a chance to test since I'm going to sleep now but it seems we can stop deliveries to the consumer setup in amqpSubscribe
in a way that keeps the rest of the channel open by using Channel.Cancel
to stop deliveries to rpc.ServerQueue
and flush the channel of remaining messages so we can Publish()
the responses before we close the entire channel...
I'll work on this a bit more tomorrow but here is a rough sketch of what I've come up with so far
// Starts the AMQP-RPC server running in a separate thread.
// There is currently no Stop() method.
func (rpc *AmqpRPCServer) Start() (err error) {
msgs, err := amqpSubscribe(rpc.channel, rpc.serverQueue)
if err != nil {
return
}
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM)
signal.Notify(sigChan, os.Interrupt)
go func() {
<-sigChan
log.Printf(" [!] SIGTERM/SIGINT recieved, stopping new deliveries and processing remaining messages")
// Lets clean things uuup, stop delivers to the consumer
// i'm not sure if this blocks itself, or if we need to block
// until len(msgs) == 0...
rpc.channel.Cancel(rpc.serverQueue, false)
log.Printf(" [!] Finished processing messages, exiting...")
// close channel cleanly
rpc.channel.Close()
// success i guess?
os.Exit(0)
}()
go func() {
for msg := range msgs {
// XXX-JWS: jws.Verify(body)
cb, present := rpc.dispatchTable[msg.Type]
log.Printf(" [s<] received %s(%s) [%s]", msg.Type, core.B64enc(msg.Body), msg.CorrelationId)
if !present {
continue
}
response := cb(msg.Body)
log.Printf(" [s>] sending %s(%s) [%s]", msg.Type, core.B64enc(response), msg.CorrelationId)
rpc.channel.Publish(
AmqpExchange,
msg.ReplyTo,
AmqpMandatory,
AmqpImmediate,
amqp.Publishing{
CorrelationId: msg.CorrelationId,
Type: msg.Type,
Body: response, // XXX-JWS: jws.Sign(privKey, body)
})
}
}()
return
}
from boulder.
@jcjones You could mold https://github.com/fvbock/endless into what you need.
from boulder.
Related Issues (20)
- Track chosen certificate profile in RA audit log and metric HOT 1
- PSL update
- Run pkilint in integration tests
- sa: investigate removing requestedNames table HOT 1
- Consider removing Subject Key Identifier from end-entity certificates
- Azure Rate Limit Exclusion question HOT 2
- go1.22: Remove loop variable lexical rebindings after a future gopls update
- ratelimits: Old to new conversion tool for overrides formats HOT 1
- admin block-key failed
- Remove resolverAddrs from WFE validation record responses
- Add ari-03 to eggsampler/acme to we can use it in integration tests HOT 1
- Name ID tool HOT 4
- ratelimits: Add support for -1 count overrides HOT 1
- Implement paused-account checking
- Replace all test private keys with dynamically-generated keys like //.hierarchy HOT 3
- ratelimits: Support new "comment" field adjacent in Ids
- Update PSL to solve Azure domain rate limit HOT 1
- renewalInfo endpoint includes extraneous trailing slash HOT 2
- Update weppos/publicsuffix-go HOT 1
- Akamai Purger's throughput configuration should just be "count of peer copies" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boulder.