portkey

Portkey: from REPL to Serverless in one call
baptiste-from-paris 2017-10-15T06:46:30.000027Z

1) set up an aws account

baptiste-from-paris 2017-10-15T06:47:04.000040Z

I am in the train today but I’ll send you examples at the end of the day

baptiste-from-paris 2017-10-15T06:47:29.000028Z

Dont Forget to add few € for your lambda

qqq 2017-10-15T06:59:34.000025Z

Oh, I have an AWS account with around 15k credit (due to a startup incubator.)

qqq 2017-10-15T06:59:46.000005Z

My copy of "AWS Lambda in Action" just arrived today.

baptiste-from-paris 2017-10-15T06:59:52.000022Z

Lol

qqq 2017-10-15T07:00:02.000185Z

I'm also familiar with EC2 / Beanstalk / AuroraDB ... it's just Lambda that I'm new to.

baptiste-from-paris 2017-10-15T07:00:08.000030Z

Then, just try the hello word example

baptiste-from-paris 2017-10-15T07:00:42.000011Z

defn a hello-word that send back the string

qqq 2017-10-15T07:00:45.000017Z

I guess I was hoping to see a "Lambda/Portkey cookbook" -- and see if I can turn my entire server side serverless.

baptiste-from-paris 2017-10-15T07:00:48.000052Z

And mount it

qqq 2017-10-15T07:01:10.000066Z

I can already drop websocket needs -- so in theory, lambda + Aurora + Dynamo + S3 should be all I need.

qqq 2017-10-15T07:01:56.000094Z

Also, want to hear the most badass first sentence intro to a book? (technically part of the 'Foreword'):

baptiste-from-paris 2017-10-15T07:02:01.000053Z

It will package everything needed to make it run on a lambda, you can also access it with the api-gateway url that the function returns

baptiste-from-paris 2017-10-15T07:03:04.000056Z

Lol, go on!

qqq 2017-10-15T07:03:12.000015Z

Alright, I guess your suggestion is: 1. get the most basic hedllo world working 2. start porting app over 3. if something breaks, ask for help ?

qqq 2017-10-15T07:04:33.000017Z

Quote: Foreword: Page xv (first real sentence of the book) At some point in the next few years we're going to see the first billion-dollar startup with a single employee, the founder, and taht engineer will be using serverless technology. -- after that sentence, this became the first book where I read the foreword, preface, acknowledgement, and 'about this book' in great detail

baptiste-from-paris 2017-10-15T07:05:44.000014Z

Yes, get the hello world working, define what you want to do with your lambda, and really don’t hesitate to ping

qqq 2017-10-15T07:34:33.000051Z

@baptiste-from-paris: I have the following problem 1. I did lein install 2. I added "portkey-0.1.0-SNAPSHOT" to my boot.build 3. I can require portkey.ouroboros, but I can't require portkey.core (ns server.snip.aws (:require [portkey.ouroboros] #_ [portkey.core :as pk])) 4. When I try to require portkey.core, I get an error of:

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling portkey/core.clj at (1:1)

1. Caused by java.lang.Exception
   namespace 'portkey.ouroboros' not found

baptiste-from-paris 2017-10-15T07:41:03.000043Z

You don’t need to require ouroboros

baptiste-from-paris 2017-10-15T07:41:19.000037Z

If you try only portkey core?

qqq 2017-10-15T07:42:07.000008Z

yeah, it gives me the exact same error (which is way I tried to see if I could require portkey.ouroboros on my own)

qqq 2017-10-15T07:42:43.000030Z

(ns server.snip.aws
  (:require [portkey.core :as pk]))
results in error:
1. Caused by java.lang.Exception
   namespace 'portkey.ouroboros' not found

baptiste-from-paris 2017-10-15T07:43:05.000024Z

It shouldn’t change anything but can you try from a lein template ?

qqq 2017-10-15T07:44:37.000002Z

is there a way I can run directly from the github repo I cloned of portkey? I get that you want to test boot vs lein, but I happen to know little lein.

baptiste-from-paris 2017-10-15T07:45:32.000004Z

I think you could as long as ouriboros eat itself, but it will be only in the repl

qqq 2017-10-15T07:46:14.000069Z

I'm perfectly willingto run the test to see if it works in lein,

qqq 2017-10-15T07:46:27.000040Z

but I don't know how to setup a lein template, so I'm asking if there is som existing repo I can clone

qqq 2017-10-15T07:46:33.000019Z

to see if portkey+lein works on my mchine

baptiste-from-paris 2017-10-15T07:46:40.000002Z

Lein new app-name

baptiste-from-paris 2017-10-15T07:46:48.000011Z

Minimal template

baptiste-from-paris 2017-10-15T07:47:07.000002Z

Then in project.clj your dependencies

baptiste-from-paris 2017-10-15T07:47:11.000013Z

And that’s it

qqq 2017-10-15T07:48:12.000065Z

okay, running lein repl

qqq 2017-10-15T07:48:31.000032Z

user=> (require 'portkey.core)
Preparing for self instrumentation.
Ouroboros succesfully eating its own tail!
Instrumenting clojure.lang.Var... done!

CompilerException java.io.FileNotFoundException: Could not locate clojure/spec/alpha__init.class or clojure/spec/alpha.clj on classpath., compiling:(portkey/aws.clj:1:1) 

baptiste-from-paris 2017-10-15T07:49:09.000009Z

Try with clojure 1.9.

baptiste-from-paris 2017-10-15T07:49:14.000037Z

In your project template

baptiste-from-paris 2017-10-15T07:49:17.000026Z

Lein clean

baptiste-from-paris 2017-10-15T07:49:21.000034Z

Lein deps

qqq 2017-10-15T07:50:23.000036Z

should I change this liunein project.clj too? :dependencies [[org.clojure/clojure "1.8.0"]

baptiste-from-paris 2017-10-15T07:50:50.000066Z

That’s what I was trying to say ^_^

qqq 2017-10-15T07:50:50.000074Z

yeah, -alpha17

qqq 2017-10-15T07:51:21.000039Z

user=> (require 'portkey.core)
Preparing for self instrumentation.
Ouroboros succesfully eating its own tail!
Instrumenting clojure.lang.Var... done!
WARNING: get-method already refers to: #'clojure.core/get-method in namespace: portkey.aws.apigateway, being replaced by: #'portkey.aws.apigateway/get-method
nil

qqq 2017-10-15T07:51:28.000049Z

I think that means require portkey.core success ?

qqq 2017-10-15T07:52:01.000020Z

trying from boot repl:

(require 'portkey.core)
                    java.lang.Exception: namespace 'portkey.ouroboros' not found
clojure.lang.Compiler$CompilerException: java.lang.Exception: namespace 'portkey.ouroboros' not found, compiling:(portkey/core.clj:1:1)

baptiste-from-paris 2017-10-15T07:52:54.000052Z

Yes, it should be good

qqq 2017-10-15T07:53:11.000005Z

=== this makes no sense ===

boot.user> (require 'portkey.ouroboros)
nil
boot.user> (require 'portkey.core)
                    java.lang.Exception: namespace 'portkey.ouroboros' not found
clojure.lang.Compiler$CompilerException: java.lang.Exception: namespace 'portkey.ouroboros' not found, compiling:(portkey/core.clj:1:1)
boot.user> 
if I reuiqre portkey.ouroboros manually, it works fine, but if I require portkey.core, there's an error loading portkey.ouroboros

qqq 2017-10-15T07:57:24.000036Z

what is ouroboros anyway? I'm googling, and it sounds like a JVM in a JVM ?

baptiste-from-paris 2017-10-15T07:59:44.000067Z

It creates an agent that is attached to the current running VM in order to do some instrumentation of bytecode

baptiste-from-paris 2017-10-15T08:00:16.000011Z

Have you got the hello world running with lein ?

qqq 2017-10-15T08:01:25.000014Z

no, I was hoping to get portkey.core working in boot first

qqq 2017-10-15T08:01:33.000007Z

I don't have AWS IAM setup either yet.

baptiste-from-paris 2017-10-15T08:01:37.000069Z

Ok

viesti 2017-10-15T14:27:39.000023Z

I remember that we have an issue for getting started https://github.com/portkey-cloud/portkey/issues/30