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/// - `queues`: SQS queues accessible from the lambda
12#[proc_macro_attribute]
13pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream {
14 // Parse the macro attributes in order to validate the inputs,
15 // then discard the result.
16 let _args = parse_macro_input!(attr as Endpoint);
17 item
18}
19
20/// Cron lambda
21///
22/// Parameters:
23/// - `name`: override the function name
24/// - `schedule`: [Schedule expression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpression)
25/// - `environment`: environment variables
26#[proc_macro_attribute]
27pub fn cron(attr: TokenStream, item: TokenStream) -> TokenStream {
28 // Parse the macro attributes in order to validate the inputs,
29 // then discard the result.
30 let _args = parse_macro_input!(attr as Cron);
31 item
32}
33
34/// Worker lambda
35///
36/// Parameters:
37/// - `name`: override the function name
38/// - `queue_alias`: alias of the queue processed by the worker
39/// - `concurrency`: max number of concurrent workers
40/// - `fifo`: set to true to enable FIFO processing
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}