Skip to main content

kinetics_macro/
lib.rs

1use kinetics_parser::{Cron, Endpoint, Worker};
2use proc_macro::TokenStream;
3use syn::parse_macro_input;
4
5/// Lambda endpoint
6///
7/// Parameters:
8/// - `name`: override the function name
9/// - `url_path`: URL path of the endpoint
10/// - `environment`: environment variables
11#[proc_macro_attribute]
12pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream {
13    // Parse the macro attributes in order to validate the inputs,
14    // then discard the result.
15    let _args = parse_macro_input!(attr as Endpoint);
16    item
17}
18
19/// Cron lambda
20///
21/// Parameters:
22/// - `name`: override the function name
23/// - `schedule`: [Schedule expression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpression)
24/// - `environment`: environment variables
25#[proc_macro_attribute]
26pub fn cron(attr: TokenStream, item: TokenStream) -> TokenStream {
27    // Parse the macro attributes in order to validate the inputs,
28    // then discard the result.
29    let _args = parse_macro_input!(attr as Cron);
30    item
31}
32
33/// Worker lambda
34///
35/// Parameters:
36/// - `name`: override the function name
37/// - `concurrency`: max number of concurrent workers
38/// - `fifo`: set to true to enable FIFO processing
39/// - `batch_size`: max number of records to process in a single batch (1..10) for fifo queues
40///   and (1..100) for standard queues
41/// - `environment`: environment variables
42#[proc_macro_attribute]
43pub fn worker(attr: TokenStream, item: TokenStream) -> TokenStream {
44    // Parse the macro attributes in order to validate the inputs,
45    // then discard the result.s
46    let _args = parse_macro_input!(attr as Worker);
47    item
48}