Commit Graph

8 Commits

Author SHA1 Message Date
Torin Sandall 76a3ef3c0e Add storage.MakeDir helper function
It's often useful to be able to create a hierarchical structure in one
shot in storage. Previously this functionality was implemented in the
server, but it's better off implemented in the storage package.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-04-10 13:58:36 -07:00
Torin Sandall c786fc9d33 Add support for concurrent r/w txns
These changes update the storage layer to support
multi-reader/single-writer txns:

- Writers can read their own writes
- Writers can rollback changes
- Readers only see writes after a successful commit
- Readers can progress during a write txn and only block during a commit

These changes also refactor the trigger interface to better support
transactions.
2017-06-23 13:18:15 -07:00
Torin Sandall 10f22906b5 Refactor storage layer interfaces
This is a large change set that contains a few backwards incompatible
changes. Summary of breaking changes:

- Remove storage.Storage in favour of storage.Store interface.
- Remove mount support.
- Remove storage of compiled policies.
- Modify storage.Store to support rollback.
- Modify storage.Store to support raw policy storage.
- Modify storage.Store to support indexing.
2017-06-23 13:18:15 -07:00
Torin Sandall 039c7bdd02 Update error codes and messages throughout
- Refactor error codes to use strings instead of ints.

- Simplify error messages throughout.

- Ensure location set on all expressions. There were a couple locations
  in the parser/compiler where locations were not being set.

- Fallback to rule location in topdown in case location not set. This
  ensures that users get useful locations for API requests with paths
  that refer to virtual docs exactly.

Also add Find function to ast.Value. Useful for extracting values
dynamically. Eventually can support JSON pointers.

Fixes #237
2017-02-16 10:29:57 -08:00
Torin Sandall 26cd8e59ec Updates to use new storage.Path type
These changes refactor the storage layer to use storage.Path instead of ast.Ref
for Read/Write/Begin/Unmount/Mount operations.

Previously, the storage layer used ast.Ref values to refer to locations in
storage. Use of ast.Ref introduced unnecessary complexity for storage plugins
as they had to be aware of various details (e.g., array indices specified as
ast.Number/float64 values, potentially nested references, etc.) that were
unnecessary given that ast.Ref values passed to the storage layer were
intended represent JSON pointers.

These changes also remove the need for storage plugins to be aware of where
they are mounted. That is, the paths passed to the read call will be relative
to the mount point.

The remaining dependencies on the ast package from the storage package are for
(1) indexing and (2) policy storage. It may be possible to further decouple
these packages by revisiting how indexing is done and treating policies as
blobs.

Fixes #159
2016-12-02 10:29:33 -08:00
Torin Sandall 5b743f3b4e Updates to allow PATCH and GET /data
This is small change that allows callers to issue GET /data and receive the
full extent of OPA's data. Secondly, this allows callers to set the data
in OPA with one request (e.g., for initialization).
2016-09-01 12:50:43 -07:00
Torin Sandall 247362606b Update storage interfaces to support writes 2016-08-24 11:30:45 -07:00
Torin Sandall 6ac8e1d2be Move storage errors into separate file 2016-08-23 14:05:55 -07:00