#[non_exhaustive]pub struct JavaScriptUDF {
pub function_name: String,
pub code: String,
/* private fields */
}Expand description
User-defined JavaScript function that can transform or filter a Pub/Sub message.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.function_name: StringRequired. Name of the JavasScript function that should applied to Pub/Sub messages.
code: StringRequired. JavaScript code that contains a function function_name with the
below signature:
/**
* Transforms a Pub/Sub message.
* @return {(Object<string, (string | Object<string, string>)>|null)} - To
* filter a message, return `null`. To transform a message return a map
* with the following keys:
* - (required) 'data' : {string}
* - (optional) 'attributes' : {Object<string, string>}
* Returning empty `attributes` will remove all attributes from the
* message.
*
* @param {(Object<string, (string | Object<string, string>)>} Pub/Sub
* message. Keys:
* - (required) 'data' : {string}
* - (required) 'attributes' : {Object<string, string>}
*
* @param {Object<string, any>} metadata - Pub/Sub message metadata.
* Keys:
* - (optional) 'message_id' : {string}
* - (optional) 'publish_time': {string} YYYY-MM-DDTHH:MM:SSZ format
* - (optional) 'ordering_key': {string}
*/
function <function_name>(message, metadata) {
}Implementations§
Source§impl JavaScriptUDF
impl JavaScriptUDF
pub fn new() -> Self
Sourcepub fn set_function_name<T: Into<String>>(self, v: T) -> Self
pub fn set_function_name<T: Into<String>>(self, v: T) -> Self
Sets the value of function_name.
§Example
ⓘ
let x = JavaScriptUDF::new().set_function_name("example");Trait Implementations§
Source§impl Clone for JavaScriptUDF
impl Clone for JavaScriptUDF
Source§fn clone(&self) -> JavaScriptUDF
fn clone(&self) -> JavaScriptUDF
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JavaScriptUDF
impl Debug for JavaScriptUDF
Source§impl Default for JavaScriptUDF
impl Default for JavaScriptUDF
Source§fn default() -> JavaScriptUDF
fn default() -> JavaScriptUDF
Returns the “default value” for a type. Read more
Source§impl Message for JavaScriptUDF
impl Message for JavaScriptUDF
Source§impl PartialEq for JavaScriptUDF
impl PartialEq for JavaScriptUDF
impl StructuralPartialEq for JavaScriptUDF
Auto Trait Implementations§
impl Freeze for JavaScriptUDF
impl RefUnwindSafe for JavaScriptUDF
impl Send for JavaScriptUDF
impl Sync for JavaScriptUDF
impl Unpin for JavaScriptUDF
impl UnwindSafe for JavaScriptUDF
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request