npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-plugin-thrift

v1.7.0

Published

Serverless framework plugin to create RPC servers on serverless function

Downloads

2

Readme

Thrift RPC Serverless Framework Plugin

serverless semantic-release npm version Build Status

Serverless Framework plugin to enable thrift RPC events as function triggers

Installation

Install thrift and serverless-thrift

For Node.js functions:

npm install --save thrift serverless-thrift

For Python functions:

pip install thrift serverless-thrift

Install The Plugin

Using the Serverless Framework:

sls plugin install --name serverless-plugin-thrift

Or using NPM:

npm install --save-dev serverless-plugin-thrift

When installing with NPM, add the plugin to your serverless.yml file:

plugins:
  - serverless-plugin-thrift

For the best results, make sure this is the first plugin specified in your plugins list.

Basic Usage

To register an RPC handler as a function event, use the following when defining your function

functions:
  my-rpc-function:
    handler: handler.app  # handler should be the file containing your RPC handler.
                          # app should be an initialized RPC handler object, which should
                          # be registered to the processor
    rpc:
      service: path/to/service/file.ServiceName  # e.g. tutorial.Calculator for
                                                 # Calculator service in tutorial.thrift file

Client Generation

In order to generate clients for the service, define clients to the server:

functions:
  my-rpc-function:
    handler: handler.app
    rpc:
      service: path/to/service/file.ServiceName
      clients:
        - language: py  # one of the supported languages
          outputPath: path/to/client/generated/files

You can generate as many clients as you'd like for a single service.

Additional Commands

See sls rpc --help

Options

Service Level Options

These options are defined at the service level, under the custom.rpc member of your serverless.yml file. Any function level option will override options defined here. Available options:

  • includeDirs - Directories to include when generating thrift code. defaults to '.'.
  • outputPath - Path to store the generated server thrift files. defaults to '.'
  • generateClients - true if clients should be generated, false otherwise. defaults to true.
  • generateServer - true if server thrift should be generated, false otherwise. defaults to false. if this option is specified, outputPath different then '.' must be specified as well.
  • cleanServer - true if server thrift should be cleaned after packaging, false otherwise. defaults to true.
  • handlersDirName - Customize the name of the directory rpc stores its handlers in. Do not use this option unless you know what you are doing :)

Function Level Options

These options are defined at the function level, under the rpc member of your function in the serverless.yml file. Available options:

  • service - Path to the thrift service. contains the path to the file (without the .thrift) suffix, and then the implemented service name. For example if a Calculator service is defined in example/tutorial.thrift file, this member should be set to example/tutorial.Calculator
  • includeDirs - Directories to include when generating thrift code. defaults to '.'.
  • outputPath - Path to store the generated server thrift files. defaults to '.'
  • genOptions - Additional options to pass to the thrift compiler
  • clean - true if the generated server files should be cleaned after packaging, false otherwise. defaults to true
  • clients - a list of clients for which generations should occur:
    • language - the language in which the client should be generated (required)
    • clean - true if the generated client files should be cleaned after packaging, false otherwise. defaults to true (required)
    • outputPath - Path to store the generated client thrift files.
    • genOptions - Additional options to pass to the thrift compiler

FAQ

  • Does this plugin work with webpack?
    • Yes! you can use webpack or any serverless plugins utilizing webpack with this plugin. Just make sure to specify this plugin before any other plugin in your serverless.yml:
      plugins:
        - serverless-plugin-thrift
        - serverless-webpack
        - any-other-plugin
  • Unable to import module serverless_rpc_handlers error:
    • During deployment, the plugin creates serverless_rpc_handler/ dir to wrap the function. Please make sure this dir is not excluded somewhere.