Thursday, February 28, 2019

LAMBDA function on AWS

LAMBDA function on AWS


AWS Lambda is Amazon's serverless compute service to reduce the configuration of servers, OS etc.
You can use it in data pipelines or to respond to web requests.
You can run your code on it without having to manage servers or even containers. 


At the very begining we should specify a handler. There are 3 ways of creating such handler:

a.Implementing the RequestHandler interface
b.Creating a custom MethodHandler
c.Implementing the RequestStreamHandler interface


public class LRequestHandler
  implements RequestHandler {
    public String handleRequest(String input, Context context) {
        return "Hello World, " + input;
    }
}


public class LMethodHandler {
    public String handleRequest(String input, Context context) {
        return "Hello World, " + input;
    }
}


public class LRequestStreamHandler
  implements RequestStreamHandler {
    public void handleRequest(InputStream inputStream, 
      OutputStream outputStream, Context context) {
        outputStream.write(("Hello World").getBytes());
    }
}



1 comment:

Aryaasharma said...

Hey Thanks for sharing this blog its very helpful to implement in our work
Regards
Hire a hacker for review