-
-
Notifications
You must be signed in to change notification settings - Fork 16
event
argument type
#12
Comments
+1 |
I wonder if this could be accomplished as is without a breaking change since deserialize is already implemented for value https://docs.serde.rs/serde_json/enum.Value.html |
Using something like https://docs.serde.rs/serde_json/fn.from_value.html |
True, Since |
Feel like this is a worth while breaking change. The only cases where in haven't called serde_json::from_value(...) are cases where I don't need to reference the event, typically scheduled cloudwatch event crons. The advantage of the current interface is that it gives the application control over error handling when deserializing fails. For me, I would be willing to fold on that for the convenience of having crowbar do the deserialization for me. This also allows for future optimization where crowbar could skip the intermediary serde_json::Value type and deserialize directly from pyobject to my deserialize type with serde. |
Agreed, and if you did need to do manual error handling, you could always have your handler use |
+1 |
Along the same lines as #11 it would be nice to move away from
event: Value
as the input to a lambda function. A few options:: Deserialize
would be great but would rely on inference, which may require an annotation of the type in the handler definition. Not a problem at all forfn handler(event: Whatever, context: Context)
, but maybe slightly annoying for|event: Whatever, context|
? Not sure if that's a real concern or not, this seems like a nice ergonomic approach with a lot of flexibility.Value
type could just be a newtype wrapper aroundPyObject
that implsDeserializer
so that handlers could just do:let event = Whatever::deserialize(event)?
. Value-esque accessors to the PyObject's attributes could be supplied for anyone who wants to use it without serde and just access things by string keys.The text was updated successfully, but these errors were encountered: