Commit Graph

64 Commits

Author SHA1 Message Date
Travis Reeder
a67d5a6290 Drop viper dependency (#550)
* Removed viper dependency.

* removed from glide files
2017-11-28 15:46:17 -08:00
Reed Allman
2d8c528b48 S3 loggyloo (#511)
* add minio-go dep, update deps

* add minio s3 client

minio has an s3 compatible api and is an open source project and, notably, is
not amazon, so it seems best to use their client (fwiw the aws-sdk-go is a
giant hair ball of things we don't need, too). it was pretty easy and seems
to work, so rolling with it. also, minio is a totally feasible option for fn
installs in prod / for demos / for local.

* adds 's3' package for s3 compatible log storage api, for use with storing
logs from calls and retrieving them.
* removes DELETE /v1/apps/:app/calls/:call/log endpoint
* removes internal log deletion api
* changes the GetLog API to use an io.Reader, which is a backwards step atm
due to the json api for logs, I have another branch lined up to make a plain
text log API and this will be much more efficient (also want to gzip)
* hooked up minio to the test suite and fixed up the test suite
* add how to run minio docs and point fn at it docs

some notes: notably we aren't cleaning up these logs. there is a ticket
already to make a Mr. Clean who wakes up periodically and nukes old stuff, so
am punting any api design around some kind of TTL deletion of logs. there are
a lot of options really for Mr. Clean, we can notably defer to him when apps
are deleted, too, so that app deletion is fast and then Mr. Clean will just
clean them up later (seems like a good option).

have not tested against BMC object store, which has an s3 compatible API. but
in theory it 'just works' (the reason for doing this). in any event, that's
part of the service land to figure out.

closes #481
closes #473

* add log not found error to minio land
2017-11-20 17:39:45 -08:00
Alexander Bransby-Sharples
c5ec0cc41e Add CORS support to fn api (#455)
The Gin middleware is being used if one or more Origins are specified. Default setup for each Origin is as follows:

- GET,POST, PUT, HEAD methods allowed
- Credentials share disabled
- Preflight requests cached for 12 hours

Which are the defaults gin-contrib/cors comes with out of the box.

Gin-cors will return a 403 if it gets a request with an Origin header that isn't on its' list. If no Origin header is specified then it will just return the servers response.

Start fn with CORS enabled:

`API_CORS="http://localhost:4000, http://localhost:3000" make run`
2017-11-16 15:37:26 +00:00
Reed Allman
61b416a9b5 automagic sql db migrations (#461)
* adds migrations

closes #57

migrations only run if the database is not brand new. brand new
databases will contain all the right fields when CREATE TABLE is called,
this is for readability mostly more than efficiency (do not want to have
to go through all of the database migrations to ascertain what columns a table
has). upon startup of a new database, the migrations will be analyzed and the
highest version set, so that future migrations will be run. this should also
avoid running through all the migrations, which could bork db's easily enough
(if the user just exits from impatience, say).

otherwise, all migrations that a db has not yet seen will be run against it
upon startup, this should be seamless to the user whether they had a db that
had 0 migrations run on it before or N. this means users will not have to
explicitly run any migrations on their dbs nor see any errors when we upgrade
the db (so long as things go well). if migrations do not go so well, users
will have to manually repair dbs (this is the intention of the `migrate`
library and it seems sane), this should be rare, and I'm unsure myself how
best to resolve not having gone through this myself, I would assume it will
require running down migrations and then manually updating the migration
field; in any case, docs once one of us has to go through this.

migrations are written to files and checked into version control, and then use
go-bindata to generate those files into go code and compiled in to be consumed
by the migrate library (so that we don't have to put migration files on any
servers) -- this is also in vcs. this seems to work ok. I don't like having to
use the separate go-bindata tool but it wasn't really hard to install and then
go generate takes care of the args. adding migrations should be relatively
rare anyway, but tried to make it pretty painless.

1 migration to add created_at to the route is done here as an example of how
to do migrations, as well as testing these things ;) -- `created_at` will be
`0001-01-01T00:00:00.000Z` for any existing routes after a user runs this
version. could spend the extra time adding 'today's date to any outstanding
records, but that's not really accurate, the main thing is nobody will have to
nuke their db with the migrations in place & we don't have any prod clusters
really to worry about. all future routes will correctly have `created_at` set,
and plan to add other timestamps but wanted to keep this patch as small as
possible so only did routes.created_at.

there are tests that a spankin new db will work as expected as well as a db
after running all down & up migrations works. the latter tests only run on mysql
and postgres, since sqlite3 does not like ALTER TABLE DROP COLUMN; up
migrations will need to be tested manually for sqlite3 only, but in theory if
they are simple and work on postgres and mysql, there is a good likelihood of
success; the new migration from this patch works on sqlite3 fine.

for now, we need to use `github.com/rdallman/migrate` to move forward, as
getting integrated into upstream is proving difficult due to
`github.com/go-sql-driver/mysql` being broken on master (yay dependencies).
Fortunately for us, we vendor a version of the `mysql` bindings that actually
works, thus, we are capable of using the `mattes/migrate` library with success
due to that. this also will require go1.9 to use the new `database/sql.Conn`
type, CI has been updated accordingly.

some doc fixes too from testing.. and of course updated all deps.

anyway, whew. this should let us add fields to the db without busting
everybody's dbs. open to feedback on better ways, but this was overall pretty
simple despite futzing with mysql.

* add migrate pkg to deps, update deps

use rdallman/migrate until we resolve in mattes land

* add README in migrations package

* add ref to mattes lib
2017-11-14 12:54:33 -08:00
Reed Allman
1a55c8050e rollback mysql driver
this https://github.com/go-sql-driver/mysql/pull/302 seems to have pretty much
crippled the ability to use mysql, so we need to lock a version before that
until that issue gets fixed.
2017-09-19 14:14:42 -07:00
Travis Reeder
3aecebdf48 Finally rid of capital Sirupsen?? 2017-09-18 23:33:47 -07:00
Travis Reeder
9f87b1ead0 Client generator update (#262)
* Generated a bunch of clients.

* Builds go client.

* Removed test line.

* Changed dependencies to fnproject/fn_go

* Fix tests.
2017-09-14 10:57:22 -07:00
Reed Allman
27e43c5d94 remove ccirrelo/supervisor, update
everything seems to work even though sirupsen is upper case?

:cyfap:
2017-09-05 11:36:47 -07:00
Travis Reeder
d7bf64bf66 Big dependency update, all lowercase sirupsen's for all dependencies. 2017-08-23 19:52:56 -07:00
Denis Makogon
60da1c5f65 Updating functions_go to 0.1.37 2017-08-18 21:40:11 +03:00
James
f46ea14760 Update dependencies 2017-08-16 11:15:14 -07:00
Reed Allman
2c2e07ba04 fix bad runner import, remove envconfig & bytefmt 2017-08-03 03:59:19 -07:00
Reed Allman
30f3c45dbc update vendor/ dir to latest w/o heroku, moby
had to lock a lot of things in place
2017-08-03 03:52:14 -07:00
James
38a2b86184 glide update 2017-07-28 07:25:52 -07:00
Reed Allman
dc5e67b6d2 add opentracing spans for metrics 2017-07-25 08:55:22 -07:00
Travis Reeder
c3630eaa41 Expiring cache 2017-07-20 08:44:56 -07:00
Travis Reeder
053c7cb0e6 Added gomega and updated deps. 2017-07-17 13:01:00 -07:00
Travis Reeder
1dcc93b32b Updated dependencies 2017-07-12 14:18:01 -07:00
Travis Reeder
98539fba8a Updated deps 2017-07-12 14:08:59 -07:00
Reed Allman
eed8555da6 add sqlite3 dep 2017-07-07 01:31:11 -07:00
Reed Allman
cc0f7cfb14 add sqlx package 2017-07-06 19:46:28 -07:00
Reed Allman
c9c7950d0f add funcy/functions_go & update docker/distribution 2017-06-30 11:22:56 -07:00
Reed Allman
6ee9c1fa0a remove dep files, update glide top to ignore fn/ 2017-06-11 02:03:02 -07:00
Reed Allman
c6e4aa1a63 hack logrus sirupsen name change
:'( not sure how to fix dep tool... punting (maybe we should remove it so that
nobody else will try to use it?)

https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437
2017-06-06 16:45:45 -07:00
James Jeffrey
79f1dab007 Deploy sh 2017-06-09 13:42:59 -07:00
Denis Makogon
1a2a805740 Update functions_{lang} tool to recent git source 2017-06-06 19:50:33 +03:00
Travis Reeder
9c67c5024f Added glides files just in case. 2017-06-01 14:30:09 -07:00
Travis Reeder
10f3178ae9 Switching to new dep tool (#616)
* making things work

* #506 - Add ability to login to a private docker registry

* Rolling back "make things work" to test them out more.

* Rolling back "make things work" to test them out more.

* credentials from docker/config.json if ENV is missing

* should get docker auth info just in the init

* update glide lock

* update glide

* Switched to new go dep tool, glide is too frikin annoying.

* Updated circle builds to use dep

* Added GOPATH/bin to path.

* Added GOPATH/bin to path.

* Using regular make test, instead of docker one (not sure why it was using the docker one?).
2017-04-07 11:22:08 -07:00
Martin Pinto-Bazurco Mendieta
e4b3105d92 Fix #418 Added MySQL as DB storage layer. (#575)
* Fix #418 Added MySQL as DB storage layer.

* Make the mysql stuff work

* Make the mysql stuff work

* Make the mysql stuff work

* Make the mysql stuff work

* small fixes

* Switch to Go 1.8 installation inside CI (#589)

* Switch to Go 1.8 installation inside CI

Partially Addresses: #588

* Use url.Hostname() instead of custom method

* Added PR review changes.

* Added missing check for error.

* Changed * with name, config

* Removed unused import.

* Added check for NoRows

* Merged changes with HEAD

* Added documentation to mysql.go

* update mysql to be on par with postgres
2017-03-21 20:01:17 +01:00
Travis Reeder
6119f07007 Fixes some route creation and updating bugs. (#526)
* Fixes some route creation and updating bugs.

* Updated README

* Added more info the quickstart

* Updated based on PR comments.

* Fixed based on comments.

* Updated per comments.
2017-02-24 16:04:04 -08:00
Seif Lotfy سيف لطفي
ee398f0d7d Add initial load balancer (#487)
* lb: library for creation of load balancer

* lb: library for creation of load balancer

* Add balance subcommand to fn

* make fnlb its own command

* Update Changelogg

* Add Makefile for fnlb
2017-01-19 03:11:39 +01:00
C Cirello
1dc3145045 functions: upgrade runner to latest (#434)
* functions: upgrade runner

* functions: update to latest runner

Supercedes and fixes #433
2016-12-14 00:10:24 +01:00
C Cirello
4bb32abba8 functions: upgrade runner (#385) 2016-12-05 20:40:08 +01:00
C Cirello
f6d19c3cc9 functions: performance improvements - LRU & singleflight DB calls (#322)
* functions: add cache and singleflight to ease database load

* runner: upgrade

* deps: upgrade glide files

* license: add third party notifications

* functions: fix handling of implicitly created apps

* functions: code deduplication

* functions: fix missing variable
2016-11-21 19:48:11 +01:00
Pedro Nasser
d98d54b1a8 remove unnecessary dep (#323)
Remove unnecessary dependency from glide
2016-11-20 13:05:22 -02:00
Travis Reeder
4421c151c5 Docs on writing functions and the functions format. (#203)
* WIP on writing functions and the functions format.

* Added more docs on writing functions.

* Running on windows docs.

* Linked README to writing.md

* Minor fixes from PR feedback.
2016-11-03 10:53:36 -07:00
Travis Reeder
41c06644d9 Docs related to running in production. (#174)
* Fixed up api.md, removed Titan references.

* Adding more documentation on running in production.

* Update deps for ironmq.
2016-10-17 11:31:58 -07:00
Travis Reeder
fcde29802e Swagger client generator. (#166) 2016-10-14 11:40:20 -07:00
C Cirello
6b7886721d Fix supervisor dependency (#167)
Fixes #164
2016-10-14 13:17:34 +02:00
C Cirello
df3d5b48ce Fix race condition during initialization (#163)
Currently, async workers are started before HTTP interface is available
to get their requests. It fixes by ensuring that async workers are
started after HTTP interface is up.

Essentially we are getting rid of an error message during bootstrap:

        ERRO[0000] Could not fetch task error=Get http://127.0.0.1:8080/tasks: dial tcp 127.0.0.1:8080: getsockopt: connection refused
2016-10-13 22:56:34 +02:00
Pedro Nasser
2e12e2c700 Fix input async tasks + tests (#137) 2016-10-12 22:23:34 +02:00
Travis Reeder
32f91e83ea Fixes issues with dependencies. 2016-10-12 19:15:39 +02:00
Travis Reeder
042bccb2e6 Fixes issues with dependencies. 2016-10-11 18:18:06 -07:00
Seif Lotfy سيف لطفي
064d597b60 Fix runner changes (#135)
* Upgrade iron-io/runner to 165c16a9

* fix support for Stdin to work
2016-10-07 21:17:40 +02:00
Pedro Nasser
52f78eb601 fix runner changes (#132)
Fix runner changes
2016-10-07 18:49:16 +02:00
Seif Lotfy سيف لطفي
52cab30056 Change PAYLOAD input to STDIN (#111)
* change to iron-io/runner dependency
* Fix runner dependency
* Change PAYLOAD input to STDIN, fixes #40
2016-10-06 18:44:58 -03:00
Seif Lotfy سيف لطفي
fbcec6bf40 Depend on iron-io/runner instead of iron-io/worker (#124) 2016-10-05 20:42:12 +02:00
Seif Lotfy
54f66c7b09 update glide 2016-09-26 12:59:18 +02:00
Seif Lotfy
b623fc27e4 Initial work on async functions 2016-09-24 10:06:51 +02:00
Pedro Nasser
b061f8db41 update glide.lock 2016-09-20 21:50:46 -03:00