Skip to content

Commit

Permalink
Added docs and changed license.
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhirj committed May 18, 2020
1 parent 737d295 commit e3d9fb9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 703 deletions.
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

57 changes: 57 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# The Prosperity Public License 3.0.0

Contributor: Sudhir Jonathan

Source Code: https://github.com/sudhirj/redimo.go

## Purpose

This license allows you to use and share this software for noncommercial purposes for free and to try this software for commercial purposes for thirty days.

## Agreement

In order to receive this license, you have to agree to its rules. Those rules are both obligations under that agreement and conditions to your license. Don't do anything with this software that triggers a rule you can't or won't follow.

## Notices

Make sure everyone who gets a copy of any part of this software from you, with or without changes, also gets the text of this license and the contributor and source code lines above.

## Commercial Trial

Limit your use of this software for commercial purposes to a thirty-day trial period. If you use this software for work, your company gets one trial period for all personnel, not one trial per person.

## Contributions Back

Developing feedback, changes, or additions that you contribute back to the contributor on the terms of a standardized public software license such as [the Blue Oak Model License 1.0.0](https://blueoakcouncil.org/license/1.0.0), [the Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html), [the MIT license](https://spdx.org/licenses/MIT.html), or [the two-clause BSD license](https://spdx.org/licenses/BSD-2-Clause.html) doesn't count as use for a commercial purpose.

## Personal Uses

Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, doesn't count as use for a commercial purpose.

## Noncommercial Organizations

Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution doesn't count as use for a commercial purpose regardless of the source of funding or obligations resulting from the funding.

## Defense

Don't make any legal claim against anyone accusing this software, with or without changes, alone or with other technology, of infringing any patent.

## Copyright

The contributor licenses you to do everything with this software that would otherwise infringe their copyright in it.

## Patent

The contributor licenses you to do everything with this software that would otherwise infringe any patents they can license or become able to license.

## Reliability

The contributor can't revoke this license.

## Excuse

You're excused for unknowingly breaking [Notices](#notices) if you take all practical steps to comply within thirty days of learning you broke the rule.

## No Liability

***As far as the law allows, this software comes as is, without any warranty or condition, and the contributor won't be liable to anyone for any damages related to this software or this license, under any kind of legal claim.***
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ Redimo is a library that allows you to use the Redis API on DynamoDB. The Dynamo
Redimo is especially well suited to serverless environments, since there is no pool of connections to handle and DynamoDB is purpose-built for near-zero management use. But you can use it with regular servers well, especially when you want excellent horizontal scalability. See the section on [differences between Redis and DynamoDB](#differences-between-redis-and-dynamodb) below for more information.

### Licensing
The default license is the [GPL-3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)), which obligates you to release any software you write with this library under the same license. I'm also offering the following perpetual licenses:

* [PolyForm Noncommercial License 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/) ($9) for hobbyist / educational / charitable use
* [LGPL-3.0](https://tldrlegal.com/license/gnu-lesser-general-public-license-v3-(lgpl-3)) ($99) for commercial use - allows you to use the library without modifying it, without any obligations to release your code
* [Apache-2.0](https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)) ($999) - a permissive and enterprise-friendly license if you want to make changes to the library or redistribute code with almost no obligations.
* If you want a different or custom license you can contact me at [email protected] - but you'll need to bring a lawyer and be ready to pay for mine.

Please contact me at [email protected] and I'll send you an invoice. All licenses are 50% off until the v1 API freeze on the 1st of July. If you're from a developing country, I'm happy to adjust prices to your purchasing power based on the Big Mac Index, so let me know your country and currency.

All licenses are perpetual and last as long as you use the software. You only need one license per entity (person or company) that owns the code that uses the library. So whether you're an individual, company or consultant / agency, whoever legally owns the code buys one license for all the code they own.
The default license is the [Prosperity License](https://prosperitylicense.com/versions/3.0.0), which allows you to use the library for noncommercial purposes and trial it for commercial purposes for 30 days. Please contact me at [email protected] to purchase a commercial license.

### Roadmap
The library is currently in `v0`, so I'm asking for comments and feedback on the interface and data schema. I expect to freeze the API to `v1` on the 1st of July, after which all `v1` releases will be guaranteed not to break backwards compatibility and work on pre-existing `v1` DynamoDB tables without any data migrations. Will also be adding documentation for every method, linking to the corresponding Redis docs and detailing the differences in how they function and what their limitations are.
Expand Down
2 changes: 1 addition & 1 deletion lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (ln lNode) toAV() map[string]dynamodb.AttributeValue {
avm[sk] = StringValue{ln.address}.ToAV()
avm[skLeft] = StringValue{ln.left}.ToAV()
avm[skRight] = StringValue{ln.right}.ToAV()
avm[vk] = ln.value.AV
avm[vk] = ln.value.av

return avm
}
Expand Down
2 changes: 1 addition & 1 deletion redimo.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ type itemDef struct {

func (i itemDef) eav() map[string]dynamodb.AttributeValue {
eav := i.keyDef.toAV()
eav[vk] = i.val.AV
eav[vk] = i.val.av

return eav
}
Expand Down
44 changes: 27 additions & 17 deletions values.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import (
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
)

// Value allows you to store values of any type supported by DynamoDB, as long as they implement this interface and encode themselves into the dynamodb.AttributeValue returned by ToAV.
//
// Some common value wrappers are provided, like StringValue, FloatValue, IntValue and BytesValue.
// The output of most operations is a ReturnValue which has convenience methods to decode the data into these common types.
//
// You can implement the ToAV() method on any type that you would like to provide a custom encoding for.
// When you receive the data wrapped in a ReturnValue, the ToAV method can be used to access
// the raw dynamo.AttributeValue struct, allowing you to do custom deserialization.
type Value interface {
ToAV() dynamodb.AttributeValue
}
Expand Down Expand Up @@ -45,51 +53,53 @@ func (bv BytesValue) ToAV() dynamodb.AttributeValue {
return dynamodb.AttributeValue{B: bv.B}
}

// ReturnValue holds a value returned by Redimo. There are convenience methods used to coerce the held value into common types,
// but you can also retrieve the raw dynamodb.AttributeValue by calling ToAV if you would like to do custom decoding.
type ReturnValue struct {
AV dynamodb.AttributeValue
av dynamodb.AttributeValue
}

func (rv ReturnValue) ToAV() dynamodb.AttributeValue {
return rv.AV
return rv.av
}

func (rv ReturnValue) String() string {
return aws.StringValue(rv.AV.S)
return aws.StringValue(rv.av.S)
}

func (rv ReturnValue) Int() int64 {
f, _, _ := new(big.Float).Parse(aws.StringValue(rv.AV.N), 10)
f, _, _ := new(big.Float).Parse(aws.StringValue(rv.av.N), 10)
i, _ := f.Int64()

return i
}

func (rv ReturnValue) Float() float64 {
f, _ := strconv.ParseFloat(aws.StringValue(rv.AV.N), 64)
f, _ := strconv.ParseFloat(aws.StringValue(rv.av.N), 64)
return f
}

func (rv ReturnValue) Bytes() []byte {
return rv.AV.B
return rv.av.B
}

func (rv ReturnValue) Empty() bool {
return rv.AV.B == nil &&
rv.AV.BOOL == nil &&
rv.AV.BS == nil &&
rv.AV.L == nil &&
rv.AV.M == nil &&
rv.AV.N == nil &&
rv.AV.NS == nil &&
rv.AV.NULL == nil &&
rv.AV.S == nil &&
rv.AV.SS == nil
return rv.av.B == nil &&
rv.av.BOOL == nil &&
rv.av.BS == nil &&
rv.av.L == nil &&
rv.av.M == nil &&
rv.av.N == nil &&
rv.av.NS == nil &&
rv.av.NULL == nil &&
rv.av.S == nil &&
rv.av.SS == nil
}

func (rv ReturnValue) Present() bool {
return !rv.Empty()
}

func (rv ReturnValue) Equals(ov ReturnValue) bool {
return reflect.DeepEqual(rv.AV, ov.AV)
return reflect.DeepEqual(rv.av, ov.av)
}

0 comments on commit e3d9fb9

Please sign in to comment.