feat: auto-convert Python objects that are passed to/from Queue Binding#123
Conversation
|
Python 3.12+ -- the Now let me think about whether there are any actual bugs or issues:
Let me verify there are no issues I'm missing. One thing I want to verify is that the Overall, this PR looks well-structured and follows established patterns. The code is clean, tests are comprehensive, and the approach of reusing There is one thing I notice: the test file has a Let me check one more thing -- whether the consolidation of Looking at the original code: if _is_js_instance(binding, "KvNamespace"):
return _BindingWrapper(binding)
if _is_js_instance(binding, "R2Bucket"):
return _BindingWrapper(binding)
if _is_js_instance(binding, "D1Database"):
return _BindingWrapper(binding)New code: _BINDING_TYPES = {"KvNamespace", "R2Bucket", "D1Database", "WorkerQueue"}
if _is_js_instance(binding, self._BINDING_TYPES):
return _BindingWrapper(binding)This is equivalent for the existing three types, plus adds After thorough review, I don't find any actionable issues -- no logic bugs, no security concerns, no backward compatibility problems, no missing error handling. The code follows established patterns, the refactoring is correct, and test coverage is solid. LGTM |
dom96
left a comment
There was a problem hiding this comment.
A few suggestions, but overall nice!
Wrap Cloudflare Queue with our bindings wrapper so that users can see the native Python objects not JSProxies. By doing this, we can eliminate
to_jsandto_pywhen using Queue in Python workers.While Queue is not our top priority, this is to remove
to_jsfrom our Python workers doc (https://developers.cloudflare.com/workers/languages/python/examples/#publish-to-a-queue)