Commit Graph

660 Commits

Author SHA1 Message Date
Reed Allman
dc5e67b6d2 add opentracing spans for metrics 2017-07-25 08:55:22 -07:00
Denis Makogon
bdffa75762 Fixing tests 2017-07-25 08:57:37 +03:00
Denis Makogon
b3ba42e3b9 Fixing fmt 2017-07-25 08:57:37 +03:00
Denis Makogon
4f5197a1c2 Fixing tests and addressing comments 2017-07-25 08:57:37 +03:00
Denis Makogon
48484be608 Ensure app exists before listing its routes 2017-07-25 08:57:05 +03:00
Reed Allman
1cc1a5ad49 Merge branch 'rm-inspect' into 'master'
remove docker inspect container

See merge request !126
2017-07-24 15:44:44 -07:00
Reed Allman
c215dcf5dd remove docker inspect container
we had the inspect container here for 3 reasons:

1) get exit code
2) see if container is still running (debugging madness)
3) see if docker thinks it was an OOM

1) is something wait returns, but due to 2) and 3) we just delayed it until
inspection

2) was really just for debugging since we had 3)

3) seems unnecessary. to me, an OOM is an OOM is an OOM. so why have a whole
docker inspect call just to find out? (we could move this down, since it's a
sad path, and make the call only when necessary, but are we really getting any
value from this distinction anyway? i've never ran into it, myself)

inspect was actually causing tasks to time out, since the call to inspect
could put us over our task timeout, even though our container ran to
completion. we could have fixed this by checking the context earlier, but we
don't really need inspect either, which will reduce the docker calls we make,
which will make more unicorn puppers. now tasks should have more 'true'
timeouts.

tried to boy scout, but tracing patch also cleans this block up too.
2017-07-24 13:37:29 -07:00
James Jeffrey
1e74cd5c4c : 0.3.24 release [skip ci] 2017-07-24 13:30:08 -07:00
James Jeffrey
9f9c9cc40e Merge branch 'add_max_conns' into 'master'
Add max cons 1 if sqlite3

See merge request !124
2017-07-24 13:11:55 -07:00
James Jeffrey
9917815214 Add max cons 1 if sqlite3 2017-07-24 13:04:08 -07:00
Reed Allman
afcec04c24 remove the nanny
we finally graduated high school and can make our own ramen

we no longer need this since fn appears to have no concept of canceling tasks
through an api we need to watch, and the context is plumbed if the request is
canceled. since tasks are short, we may never need to do cancellation of
running tasks like we had with iron worker. this was an added docker call
that's unnecessary since we are doing force removal of the container at the
end anyway.
2017-07-24 11:56:58 -07:00
James Jeffrey
40f911c566 : 0.3.23 release [skip ci] 2017-07-24 08:33:43 -07:00
James Jeffrey
b9b87fc81f Kill the server if original context is canceled 2017-07-21 16:01:18 -07:00
James Jeffrey
5d3fd6bd98 : 0.3.22 release [skip ci] 2017-07-20 10:14:48 -07:00
Travis Reeder
c3630eaa41 Expiring cache 2017-07-20 08:44:56 -07:00
James Jeffrey
2be96689d4 : 0.3.21 release [skip ci] 2017-07-19 16:02:02 -07:00
James Jeffrey
cf2c3cf404 Use chi style middle ware 2017-07-19 13:44:26 -07:00
Denis Makogon
07b0fab720 Fix unexpected failure when trying to update route with exact the same attributes 2017-07-18 13:40:54 -07:00
Denis Makogon
fea44b0dbf Merge branch 'mask-errors' into 'master'
mask errors in api response, log real error

See merge request !108
2017-07-18 09:17:03 -07:00
Reed Allman
cb3464fcb1 increase max idle conns
we're routinely doing transactions which will hold up connections for some
time, it was pretty easy to run out of 30 conns from routine function
invocations. the 'right' thing is probably to add a config val to the url that
we can strip before passing into the db, but i'm not sure i want to have our
own query params in db urls, either.
2017-07-14 04:18:50 -07:00
Reed Allman
c0aed2fbb0 mask errors in api response, log real error
we had this _almost_ right, in that we were trying, but we weren't masking the
error from the user response for any error we don't intend to show. this also
adds a stack trace from any internal server errors, so that we might be able
to track them down in the future (looking at you, 'context deadline
exceeded'). in addition, this adds a new `models.APIError` interface which all
of the errors in `models` now implement, and can be caught easily / added to
easily.

the front end now does no status rewriting based on api errors, now when we
get a non-nil error we can call `handleResponse(c, err)` with it and if it's a
proper error, return it to the user with the right status code, otherwise log
a stack trace and return `internal server error`. this cleans up a lot of the
front end code.

also rewrites start task ctx deadline exceeded as timeout. with iw we had
async tasks so we could start the clock later and it didn't matter, but now
with sync tasks time out sometimes just making docker calls, and we want the
task status to show up as timed out. we may want to just catch all this above
in addition to this, but this seems like the right thing to do.

remove squishing together errors. this was weird, now we return the first
error for the purposes of using the new err interface.

removed a lot of 5xx errors that really should have been 4xx errors. changed
some of the 400 errors to 409 errors, since they are from sending in
conflicting info and not a malformed request.

removed unused errors / useless errors (many were used for logging, and didn't
provide any context. now with stack traces we don't need context as much in
the logs).
2017-07-14 03:44:16 -07:00
Travis Reeder
c605317250 More middleware updates. 2017-07-13 14:40:36 -07:00
Travis Reeder
6d2c503010 Updated middleware example to return error format that fn understands. 2017-07-13 10:21:02 -07:00
Travis Reeder
667c611fac Added functions to MiddlewareContext interface 2017-07-12 22:28:49 -07:00
Travis Reeder
86b93e27f7 Updated ctx to MiddlewareContext in various places. 2017-07-12 21:40:16 -07:00
Travis Reeder
7a81aa5761 Merge branch 'middleware-update' into 'master'
Allow setting values in middleware context like gin context.

See merge request !99
2017-07-12 15:05:13 -07:00
Travis Reeder
98539fba8a Updated deps 2017-07-12 14:08:59 -07:00
Reed Allman
8d669c202c Merge branch 'one-db' into 'master'
merge datastores into sqlx package

See merge request !101
2017-07-11 11:30:41 -07:00
Travis Reeder
0f83355f0a Merge branch 'fix-root-route-invocation' into 'master'
Allow calling root route on app

Closes #64

See merge request !91
2017-07-11 09:44:29 -07:00
Travis Reeder
e56ac42bc2 Using ctx logger in more places to get more context in the logs - ie: call_id 2017-07-10 16:13:51 -07:00
Travis Reeder
bd9c9c5202 WIP, setting values in middleware context like gin context. 2017-07-07 16:34:04 -07:00
Travis Reeder
130991819d functions: 0.3.20 release [skip ci] 2017-07-07 14:54:16 -07:00
James Jeffrey
fdd7ad929f : 0.3.19 release [skip ci] 2017-07-07 11:05:31 -07:00
James Jeffrey
81e39b210d Add go fmt 2017-07-07 10:14:08 -07:00
Reed Allman
4e52c595d2 merge datastores into sqlx package
replace default bolt option with sqlite3 option. the story here is that we
just need a working out of the box solution, and sqlite3 is just fine for that
(actually, likely better than bolt).

with sqlite3 supplanting bolt, we mostly have sql databases. so remove redis
and then we just have one package that has a `sql` implementation of the
`models.Datastore` and lean on sqlx to do query rewriting. this does mean
queries have to be formed a certain way and likely have to be ANSI-SQL (no
special features) but we weren't using them anyway and our base api is
basically done and we can easily extend this api as needed to only implement
certain methods in certain backends if we need to get cute.

* remove bolt & redis datastores (can still use as mqs)
* make sql queries work on all 3 (maybe?)
* remove bolt log store and use sqlite3
* shove the FnLog shit into the datastore shit for now (free pg/mysql logs...
just for demos, etc, not prod)
* fix up the docs to remove bolt references
* add sqlite3, sqlx dep
* fix up tests & mock stuff, make validator less insane
* remove put & get in datastore layer as nobody is using.

this passes tests which at least seem like they test all the different
backends. if we trust our tests then this seems to work great. (tests `make
docker-test-run-with-*` work now too)
2017-07-07 01:30:02 -07:00
Reed Allman
e9294c594e Merge branch 'resolves_issue_37' into 'master'
Resolves issue 37

Closes #37

See merge request !88
2017-07-06 14:10:31 -07:00
James Jeffrey
55239dbd80 Check both errors 2017-07-06 12:42:09 -07:00
James Jeffrey
7ebf8ab144 No nil errors on error 2017-07-06 12:23:44 -07:00
Reed Allman
c0466bd0cd Merge branch 'hot-lambda' into 'master'
Hot lambda

Closes #81

See merge request !90
2017-07-06 12:22:43 -07:00
James Jeffrey
61bd41f9b2 Error apps create not route 2017-07-06 12:22:03 -07:00
James Jeffrey
e5b1bb03ea Address more comments. Add docs and clean up comments 2017-07-06 12:19:48 -07:00
James Jeffrey
d3fb420be0 Move logging. Remove todo comment 2017-07-06 12:08:17 -07:00
James Jeffrey
77c5d38381 Update docs 2017-07-06 11:46:25 -07:00
James Jeffrey
021bb32a22 Refactor tests to use testRoute case struct. Use one method for tests. Fix logic for when to skipzero 2017-07-06 11:46:25 -07:00
James Jeffrey
a37abfd9d5 Add error validation to some cases that were missing it. 2017-07-06 11:46:25 -07:00
James Jeffrey
3087a12b83 Needs != for this. Do not try to test client for functions go if there 2017-07-06 11:46:25 -07:00
James Jeffrey
7f226bc96b Assign err. Fixes tests that were not working 2017-07-06 11:46:25 -07:00
James Jeffrey
b4d39c0f3c Refactor seperate out logic 2017-07-06 11:46:24 -07:00
James Jeffrey
4845ddb1d4 Only use 200 follows what others do. Less switching. Remove defense 2017-07-06 11:46:24 -07:00
James Jeffrey
c66a0d0cc4 Update swagger doc. Indicate to user if updated or created 2017-07-06 11:46:24 -07:00