RPC
RESTRICTED_PUBLISHER_OPTIONS = ('exchange', 'routing_key', 'mandatory', 'reply_to', 'correlation_id')
module-attribute
Publisher options that cannot be overridden when configuring an RPC client
Client
Bases: object
Helper object for making RPC calls.
The target service and method name may be specified at construction time or by attribute or dict access, for example:
# target at construction time
client = Client(
publish, register_for_reply, context_data,
"target_service", "target_method"
)
client(*args, **kwargs)
# equivalent with attribute access
client = Client(publish, register_for_reply, context_data)
client = client.target_service.target_method # now fully-specified
client(*args, **kwargs)
Calling a fully-specified Client
will make the RPC call and block for the
result. The call_async
method initiates the call but returns an
RpcReply
object that can be used later to retrieve the result.
:Parameters: publish : callable Function to publish an RPC request register_for_reply : callable Function to register a new call with a reply listener. Returns another function that should be used to retrieve the response. context_data: dict Worker context data to be sent as extra headers service_name : str Optional target service name, if known method_name : str Optional target method name, if known
Source code in nameko/rpc.py
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
|
ClusterRpc
Bases: DependencyProvider
DependencyProvider for injecting an RPC client to a cluster of services into a service.
:Parameters:
**publisher_options
Options to configure the :class:~nameko.amqqp.publish.Publisher
that sends the message.
Source code in nameko/rpc.py
ReplyListener
Bases: SharedExtension
SharedExtension for consuming replies to RPC requests.
Creates a queue and consumes from it in a managed thread. RPC requests
should register their correlation_id
with
:meth:~ReplyListener.register_for_reply
in order for the ReplyListener
to capture the reply.
Source code in nameko/rpc.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
ReplyConsumer
Bases: Consumer
Subclass Consumer to add disconnection check
Source code in nameko/rpc.py
get_consumers(consumer_cls, channel)
Check for messages lost while the reply listener was disconnected from the broker.
Source code in nameko/rpc.py
register_for_reply(correlation_id)
Register an RPC call with the given correlation_id
for a reply.
Returns a function that can be used to retrieve the reply, blocking until it has been received.
Source code in nameko/rpc.py
Responder
Bases: object
Helper object for publishing replies to RPC calls.
Source code in nameko/rpc.py
Rpc
Bases: Entrypoint
A limitation of using a shared queue for all RPC entrypoints is that we can’t accept per-entrypoint consumer options. The best solution to this is to start using a queue per entrypoint, but this will require a consumer (and if using kombu, a connection) per entrypoint.
For the time being consumer options are not supported in RPC entrypoints.
Source code in nameko/rpc.py
RpcCall
Bases: object
Encapsulates a single RPC request and response.
:Parameters: correlation_id : str Identifier for this call send_request : callable Function that initiates the request get_response : callable Function that retrieves the response
Source code in nameko/rpc.py
get_response()
Retrieve the response for this RPC call. Blocks if the response has not been received.
result()
Return the result of this RPC call, blocking if the response has not been received.
Raises a RemoteError
if the remote service returned an error
response.
Source code in nameko/rpc.py
ServiceRpc
Bases: ClusterRpc
DependencyProvider for injecting an RPC client to a specific service into a service.
As per :class:~nameko.rpc.ClusterRpc
but with a pre-specified target
service.
:Parameters: target_service : str Target service name