-
direct:
when a queue is bound to this exchange with a specific routing_key(rk), messages coming into the exchange with topic of the same with the routing_key(rk) will be pushed into the queue. if there are multiple queues bound with the same routing key, the message will be fan-outed to all the queues.
-
fan-out
when a queue is bound to this exchange, whatever the routing key is specified, a message coming into the exchange will be fan-outed to the queue.
-
topic
| package main | |
| import ( | |
| "fmt" | |
| "runtime" | |
| ) | |
| // reference: https://stackoverflow.com/questions/28432658/does-go-garbage-collect-parts-of-slices/28432812#28432812 | |
| func main() { | |
| manyBigSlices := make([][]int, 10) |
| use std::thread::{self, sleep}; | |
| use std::time::Duration; | |
| #[tokio::test] | |
| async fn test_async_call_sync() { | |
| fn sync_dummy_func() -> i32 { | |
| sleep(Duration::from_secs(1)); | |
| 1 | |
| } |
| // reference: https://go.dev/ref/mem#chan | |
| package main | |
| import ( | |
| "fmt" | |
| "sync" | |
| "testing" | |
| ) | |
| func TestChan(t *testing.T) { |
| #!/bin/bash | |
| # bash generate random alphanumeric string | |
| # | |
| # bash generate random 32 character alphanumeric string (upper and lowercase) and | |
| NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
| # bash generate random 32 character alphanumeric string (lowercase only) | |
| cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 |
| import sys | |
| import os | |
| print os.path.join(sys.prefix, "lib","python" + sys.version[:3]) |
The ConnectionHandler is not a connection -- it only handles connections. It does so in a perfectly thread-safe manner by storing them on self._connections, which is a thread.local instance. The ConnectionHandler overrides getitem to support thread-local connections. When you access connections['default'], it looks if the default attribute exists on self._connections, which is a thread local. If it does, that would be the connection to the default database for the current thread. If it doesn't, it'll create a new one and set it on self._connections. Other threads won't be able to access this connection, since it's set on a thread local object. In the end it pretty much comes down to the public API. Setting a ConnectionHandler on a thread-local object would work as well, but the public API would be more complicated than it currently is, since user code would manually need to check if the
| # Autoreloading launcher. | |
| # Borrowed from Peter Hunt and the CherryPy project (https://cherrypy.org/). | |
| # Some taken from Ian Bicking's Paste (http://pythonpaste.org/). | |
| # | |
| # Portions copyright (c) 2004, CherryPy Team (team@cherrypy.org) | |
| # All rights reserved. | |
| # | |
| # Redistribution and use in source and binary forms, with or without modification, | |
| # are permitted provided that the following conditions are met: | |
| # |