Skip to content

Commit 035048e

Browse files
committed
Merge pull request #10 from penland365/turn_public
Turn public
2 parents a2a02de + f11dbe2 commit 035048e

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,111 @@
11
# roc
2+
[![PyPI](https://img.shields.io/pypi/l/Django.svg?style=plastic)]()
23
[![Circle CI](https://circleci.com/gh/penland365/roc/tree/master.svg?style=svg&circle-token=07305c9575ac3fcf0ab5bade8ae2f29921ac04c9)](https://circleci.com/gh/penland365/roc/tree/master)
4+
[![codecov.io](https://codecov.io/github/penland365/roc/coverage.svg?branch=master)](https://codecov.io/github/penland365/roc?branch=master)
5+
6+
roc is a modern [Finagle][finagle] [Postgresql][postgresql] [Client][finagle-client]. What's modern? A Client relying on a [6.x +][finagle-changelog] version of Finagle.
7+
8+
roc is currently under heavy development and is not being published with a current version of `0.0.1-ALPHA`.
9+
If you need a real driver right now you should absolutely use [finagle-postgres][finagle-postgresql-existing].
10+
11+
## tl;dr
12+
roc is not being published yet. You'll have to clone/fork this repository, then build locally.
13+
14+
Once built, open `sbt console` and insert the following
15+
```scala
16+
scala > :paste
17+
import com.twitter.util.Await
18+
import com.github.finagle.roc.Postgresql
19+
import com.github.finagle.roc.postgresql.{Request, Row}
20+
21+
val client = Postgresql.client
22+
.withCredentials([USER_NAME], Some([DATABASE]))
23+
.withPassword([PASSWORD])
24+
.newRichClient("localhost:5432")
25+
val req = new Request("SELECT * FROM states;")
26+
val result = Await.result(client.query(req))
27+
```
28+
A result contains two types, a list of columns detailing information about
29+
the result, and a list of rows returned from the database.
30+
```scala
31+
scala> result.columns
32+
33+
res1: List[com.github.finagle.roc.postgresql.Column] =
34+
List(Column(name='id, columnType=Int4, formatCode=Text),
35+
Column(name='name, columnType=VarChar, formatCode=Text), Column(name='abbrv, columnType=VarChar, formatCode=Text), Column(name='last_modified_at, columnType=TimestampWithTimezone, formatCode=Text),
36+
Column(name='inserted_at, columnType=TimestampWithTimezone, formatCode=Text)
37+
)
38+
39+
scala> :paste
40+
41+
val display = (r: Row) => {
42+
val id = r.get[Int]('id)
43+
val name = r.get[String]('name)
44+
val abbrv = r.get[String]('abbrv)
45+
val insertedAt = r.get[String]('inserted_at)
46+
val lastModifiedAt = r.get[String]('last_modified_at)
47+
println(s"Row $id, $name, $abbrv, $insertedAt, $lastModifiedAt")
48+
}
49+
// Exiting paste mode, now interpreting.
50+
51+
display: com.github.finagle.roc.postgresql.Row => Unit = <function1>
52+
53+
scala> result.rows.map(display(_))
54+
Row 1, North Dakota, ND, 2016-02-18 09:50:55.445246-06, 2016-02-18 09:50:55.445246-06
55+
res4: List[Unit] = List(())
56+
```
57+
At the moment, we can only return `Ints` and `Strings` (I told you it was `ALPHA`).
58+
The good news is that most `Postgresql` columns can be read as strings first, then transformed into the appropriate type
59+
( see the handling of Timestamps With TimeZone above).
60+
61+
## Motivation
62+
Why create your own when there is an existing implementation? Three reasons
63+
64+
1. The current [finagle-postgres][finagle-postgresql-existing] was developed pre [Finagle 6.x][finagle-changelog] and does not use modern finagle abstractions. These are core enough to require what amounts to a complete rewrite of the driver.
65+
2. Selfishly, I want to learn more about Finagle internals, and nothing is a better teacher than writing the code yourself.
66+
3. The current project lacks a true owner - Twitter decided to give the Open Source team a [long vacation][twitter-long-vacation] last fall, and since then only a handful of projects are being actively managed.
67+
68+
It is absolutely the goal of this project to become the reference implementation, and hopefully be moved into the [Finagle ecosystem][finagle-ecosystem].
69+
70+
71+
## What's in a name?
72+
roc (*Rokh* or *Rukh*) is named after the Persian mythological bird of prey [Roc][roc-wikipedia],
73+
which was based in part on the now extinct [elephant bird][elephant-bird-wikipedia]. Yes, that means we've hit the rare 4 point play with the name
74+
75+
76+
Goal |Status
77+
:-------------------------------:|:----:
78+
short name |✔️
79+
obligatory mythological reference|✔️
80+
bird reference for Twitter |✔️
81+
elephant reference for Postgresql|✔️
82+
83+
High fives for everyone!
84+
![Teenage Mutant Ninja Turtles High Fives](http://i.giphy.com/10LNj580n9OmiI.gif)
85+
86+
## Contributors and Participation
87+
88+
roc is currently maintained by [Jeffrey Davis][jeff-davis].
89+
90+
The circe project supports the [Typelevel][typelevel] [code of conduct][code-of-conduct] and wants
91+
all of its channels (GitHub, etc.) to be welcoming environments for everyone.
392

493
## License
594

695
Licensed under the **[BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause)**
796
(Revised BSD Liscense); you may not use this software except in compliance with the License.
897

998
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
99+
100+
[code-of-conduct]: http://typelevel.org/conduct.html
101+
[elephant-bird-wikipedia]: https://en.wikipedia.org/wiki/Elephant_bird
102+
[finagle]: http://twitter.github.io/finagle/guide/
103+
[finagle-changelog]: http://twitter.github.io/finagle/guide/changelog.html
104+
[finagle-client]: http://twitter.github.io/finagle/guide/Clients.html
105+
[finagle-ecosystem]: https://github.com/finagle
106+
[finagle-postgresql-existing]: https://github.com/finagle/finagle-postgres
107+
[jeff-davis]: https://twitter.com/penland365
108+
[postgresql]: http://www.postgresql.org/
109+
[roc-wikipedia]: https://en.wikipedia.org/wiki/Roc_(mythology)
110+
[twitter-long-vacation]: https://meta.plasm.us/posts/2015/10/13/goodbye-twitter/
111+
[typelevel]: http://typelevel.org/

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ lazy val baseSettings = Seq(
3535
scalacOptions in (Compile, console) := compilerOptions,
3636
libraryDependencies ++= testDependencies.map(_ % "test"),
3737
resolvers += Resolver.sonatypeRepo("snapshots"),
38+
coverageEnabled := true,
3839
resolvers += "Twitter Maven repo" at "http://maven.twttr.com/"
3940
)
4041

4142
lazy val allSettings = buildSettings ++ baseSettings
4243

43-
lazy val coreVersion = "0.1.1"
44+
lazy val coreVersion = "0.0.1-ALPHA"
4445

4546
lazy val catsVersion = "0.4.1"
4647

circle.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ test:
1414
post:
1515
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
1616
- find . -type f -regex ".*/core/target/test-reports/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
17+
- sbt coverageReport
18+
- bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5")

0 commit comments

Comments
 (0)