portkey 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
portkey 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
portkey 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 Readme
开发语言 JavaScript
操作系统 跨平台
软件类型 开源软件
所属分类 云计算Serverless 系统
开源组织
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-12-02

软件简介

Portkey

Live-coding the Cloud!

CircleCI

Portkey allows, at the REPL, to expose any function as an AWS Lambda.

Almost any inanimate object can be turned into a Portkey. Once bewitched, the object will transport anyone who grasps it to a pre-arranged destination.

The sensation of travelling by Portkey is universally agreed to be uncomfortable, if not downright unpleasant, and can lead to nausea, giddiness and worse.

(source)

Example

Live at the repl:

(defn flatter [name]
  (str name " is " (rand-nth ["incredible" "awesome" "fantastic"])))

(pk/mount! flatter "/hello?name={name}")
=> {:url "https://api-id.execute-api.region.amazonaws.com/hello"}

Go to "https://api-id.execute-api.region.amazonaws.com/hello?name=Rich" (and wait for the instance to start).

Usage

  1. Clone the repository and run lein install (portkey is still alpha so not on clojars yet).
  2. Add [portkey "0.1.0-SNAPSHOT"] to your project file.

Master plan

First steps:

  1. Borrow Ouroboros from Powderkeg (only class access matters, var tracking is irrelevant in a first time).
  2. Starting from a fn, serialize it using Kryo and a custom SerializerFactory to log all classes traversed during serialization. We also need to log all serialized vars.
  3. Serialize these vars values and keep going until there's no new var.
  4. Consider all classes encountered during steps 2 and 3.
  5. Visit their bytecode to find all references to other classes or vars.
  6. go to 3 until no new classes (somehow done but need to be smarter about common dynamicisms, provide good defaults)
  7. package them all
  8. send to the cloud!

Next steps:

  • Since we know the deps of the Lambda, we can redeploy it when a var change locally.
  • fdef specs could be leveraged to validate Lambda input.
  • var meta can provide hints for params naming.
  • support other backends than AWS Lambda
  • S3 buckets as Clojure references?
  • Track methods usage and narrow the deps graphs (bonus: remove unused methods from classes)
  • Once a fn is mounted we can automatically update it each time it or one of its direct or indirect deps change!
  • Add support for ring handlers

Requirements

The following AWS service actions are used by portkey, define them in for example an inline policy for a IAM user:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Resource": "*",
      "Action": [
        "lambda:GetPolicy",
        "lambda:GetFunction",
        "lambda:GetFunctionConfiguration",
        "lambda:AddPermission",
        "lambda:CreateFunction",
        "lambda:UpdateFunctionCode",
        "lambda:InvokeFunction",
        "lambda:UpdateFunctionConfiguration",
        "lambda:DeleteFunction",
        "apigateway:*",
        "iam:GetRole",
        "iam:CreateRole",
        "iam:PutRolePolicy",
        "iam:PassRole",
        "ec2:DescribeSubnets",
        "ec2:DescribeSecurityGroups",
        "ec2:DescribeVpcs",
        "s3:PutObject",
        "s3:GetObject"
        ]
    }
  ]
}

License

Copyright © 2017 Christophe Grand and Kimmo Koskinen

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

展开阅读全文

代码

评论

点击引领话题📣
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部