pREST – A fully RESTful API from any existing PostgreSQL database writting in Go
github.com
github.com
> There is the PostgREST written in haskell, keep a haskell software in production is not easy job, with this need that was born the pREST.
Have people faced operational difficulties with PostgREST? From what I hear it's pretty battle-tested and performant.
You are not supposed to change software?
If you want to contribute to and extend any of those projects you'll usually have to learn C, C++, or Java first if you don't already know them (or otherwise use the approved extension points if they have them, or link to them via some kind of FFI where available, etc, etc).
Which is exactly why I don't use software written in java, haskell, nodejs and prefer things written in python or go.
Given the choice between PostgREST or pREST I would chose pREST every time simply because if it breaks or ends up unmaintained I would have a chance in fixing it myself.
I'm sure there are many people who have the exact opposite stance, and that's fine too. This shouldn't be surprising to anyone.
edit: Point being every day you use a lot (i would say majority) of software which most probably it would be very hard for anyone to "change" and yet this seems to work. There's no point in making a decision to use some software by thinking "am i personally able to understand it's codebase". By this logic there is very little software one person should use, no one is able to know everything.
Let the experts (in that particular software) work on it, while you contribute to the things where you are an expert, everybody wins.
I remember an article here not long ago about the distinction between an expert and a smart person, interesting read.
But once the project is large and popular enough (and PostgREST arguably is), you don't maintain it yourself anymore. Keep in mind than in any case you're probably using PostgreSQL and Linux: major pieces of complex C code that you probably can't and won't maintain yourself.
To be clear, I do think being able to understand the source code for the system that you're running on and even submit patches or pull request is nice, but this is not what you pointed out as your reason, and it's also never going to be my #1 priority for a production system. For instance, PostgREST looks more mature than pREST and that's a pretty big consideration for a production system.
I also prefer Python and Go but to say I would not use the software because of the language it's written in just sounds silly to me. Heck, I really dislike PHP but would still use PHP-software when it suits my need.
You're talking about a massively different scale of thing here, especially in terms of lifecycle and long term support guarantee.
But talking about small things, and long term support. Remember when someone removed a package from npm and the (Node) world stopped for a second? Where is the long time support there and guarantee. But still, this is how all of it works. Take any language, build anything nontrivial, i bet you'll end up using libraries far less supported and much younger then PostgREST.
I have done all of these at one point or another in my career, as well as several others, and I have not been a contributor back to them. These were either know issues with separate fixes and consequences or very specific to the company I was working for at the time.
Do I know C or C++. The answer is not really... However C and C++ (and to some extent java) are pervasive. Haskel doesn't fall into that camp.
If your a Golang shop and you have a need for this, then it might be something you choose incase you need to support it, or tune it or mould it to your needs.
Beyond that, projects like this are GREAT for go. You have a well defined problem space, an existing tool and a reimplementation like this is only going to grow the authors knowledge and expand the Golang universe.
With regards to growing "the authors knowledge" -- contributing to PostgREST would have done a lot more for them there, since Haskell is quite different from Go.
Maybe, but reimplementations can evolve differently... This is why we have forks and distros, and to some extent linux.
> With regards to growing "the authors knowledge" -- contributing to PostgREST would have done a lot more for them there, since Haskell is quite different from Go.
Your making the mighty assumption that one wants to learn a language, or that the language is good (NOT taking a pot shot at haskell here) or that it makes sense in their environment.
I think you raise some important points however, that do need to be part of the decision to undertake reimplmentaion of something that already exists.
I am not making either of these assumptions at all -- I am only asserting that there is plenty to learn from a typed functional programming language, if it seems difficult at first. That doesn't mean it is good, nor that you want to learn it.
Wise men learn more from fools than fools learn from wise men. Some languages are bad but because they are significantly different from what I learned before, I learned a lot from them.
1. submitting an issue to the project's issue tracker, and waiting;
2. submitting an issue to the project's issue tracker, and becoming a project sponsor to expedite;
3. customizing the software using a scripting language it exposes;
4. using a third-party "plugin" for the project that someone else already developed to solve the problem;
5. developing such a plugin yourself, using the software's C FFI API to write your plugin library in your language of choice, rather than the language the software itself is written in;
6. wrapping the software in a single-purpose gateway that decorates or mutates its wire protocol/API with the new features.
In practice, actually modifying the server software itself is very rare. Needlessly rare, even. Some great, clean codebases (Postgres itself; Nginx) get strategies #3-#6 applied so often that there exists a whole ecosystem of features "around" them that really should be in their cores, because everyone was too afraid to touch them even when they're written in common languages.
Did you post on Functional Jobs, haskell-cafe, and r/haskell?
I was just confused by whether or not this project was inspired because it's difficult to extend PostgREST or because of operation issues with PostgREST itself. Seems like the former...though I'm not sure what this does that PostgREST doesn't.
For sure. Hence my business-oriented qualification "If an organization is going to be changing and maintaining software...".
> Developers (and orgs even more) should try and always expand their area of competence, not limit themselves to one area.
About developers: absolutely. Constant growth is a must.
About large and mature orgs: agree. That's what R&D budgets are for.
About startups: disagree. Invest only in what you need to ship product and gain differentiated competitive advantage. When there's an infinite queue of features to build and bugs to fix, not taking on unwarranted technical debt is key - and it's easiest to take on accidental technical debt when you don't have experience in a tool, language, or ecosystem.
I think a point expressed elsewhere in this thread is worth reiterating: language agnostic APIs (e.g. a HTTP API) mean that I don't have to care what language something is implemented in to use it. That's a Good Thing. Learn Erlang to hack on RabbitMQ? Sure, for fun. But if I'm putting it in prod for customers, I care more about how my application code - in a language I'm strong with - interfaces with it than the internals.
There is plenty of software that people use without direct competency in the underlying language -- for example, running Jenkins to do builds for a RoR shop does not require a Java programmer.
I know nothing about Haskell and that has not been an problem. I am always happy to see more open source software, though.
Currently the project supports more than 40+ API client generators (C#, Swift, C++, TS, JS, etc) and 20+ server stub generators (C# Nancy, Python Flask, etc). For a full list, please refer to the project README.
[1] https://github.com/swagger-api/swagger-codegen
Discloure: I'm a top contributor to the project.
This framework may simply be too "thin" - there needs to be a place to code business logic and access control, neither of which map neatly to how RDMS treat users and security permissions. In which case might as well use a framework like Django or Rails or Bottle or Laravel or any other of the dozens of mature systems available.
It's certainly to thin since it doesn't even leverage db-level RBAC, but, used fully, I think PostgreSQL roles and permissions are reasonably robust. (Particularly, all the specific examples, including row-level permissions, you point to are addressed by PostgreSQL roles and permissions.)
As someone said, people just don't read the manual of their database past page 100 :) and use "root" when connection to the database from their code.
https://blog.2ndquadrant.com/application-users-vs-row-level-...
The biggest issue with this is roles are identifiers, which means you can't use parameters for them.
Basically PostgREST translates cryptographically signed JWT claims from the client request into local SQL variables accessible by postgresql's "current_setting" function. The additional claims can identify the user beyond their db role. They can specify, for instance, the user's email address.
Row level security policies can use current_setting to refer to the extra claims. So multiple users can share a db role and connection pooling works fine.
> users are a connection level concept
That is not true. There are users in the db that do not have login privileges.
PostgREST connects in with only one user (authenticator), then for each authenticated request it does `set local role alice` within a transaction, where alice is a db user with no login privileges.
You might first make database views, and grant only those to users, not granting any user rights to a table. PostgreSQL lets you run an update to a view and then translates it to an update on the table. So reads and writes on a view would both work.
PostgreSQL now has security by column and row. So you could do it that way too.
But that's only if you can first connect to the database with a general-purpose client program, like psql or one of the GUIs. By default Postgres allows connections only from localhost. So even if you had a user account, you couldn't connect.
So how would something like this REST interface even work with accounts for each user? The REST program would have to be installed on the same server as Postgres, or you would have tell Postgres to allow network connections only from the server that the REST program is on. The REST program first connects with its own user account, say "resty". resty is a member of your account, say "jdoe" (users and groups are the same entity, and they're really called "roles", and one role can be a member of another role). If a role is member of another role, then it can become it, like this:
set role jdoe;
Now you been downgraded to the rights of jdoe.The REST program could pass through your username and password and relogin as you. Or it could trust that your web server authenticated the REMOTE_USER and just set itself to that variable.
But it's useful if what you want to do is create a simple API to access your data. If your use case includes buildinga CRUD app, or API, you basically get that out of the box.
If you have several components/clients (in different languages) which need to access your database it allows you keep a common interface instead of having to work with different specific libraries/frameworks for each language.
(PostgREST user)
It's not necessarily useful if you have trusted code running on your servers, it should just connect to the database. But if this works for you ... why not.
(At least that's how i think of it, others may use it in different ways)
This is a design flaw imho and should not be used as a reason to motivate the use of such projects. If your logic is in the frontend you should rather build a backend that captures the logic instead of just putting a rest layer on your DB and call it a day.
Read more in: https://github.com/nuveo/prest/issues/41
HAL gives you both links, so you can discover resources and transit between them, and URI templates, which are the controls to make the filtering stuff work.
I still cannot figure out why anyone would ever want to meet such a standard, other than to trick the ignorant.
I recommend you open issue on pREST and recommend MySQL support
Performance suffers, and transactionality is a non-starter.
Best to forego this style and instead go with more of an RPC system.
EDIT: actually, after a few minutes on their docs page, I'm still not sure "how it works" regarding perf, so this could be useful even for the not-so-lazy :-)