Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ld
go-ld-prime
Commits
4671c928
Commit
4671c928
authored
Mar 13, 2019
by
Eric Myhre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'integration'
parents
a64d28cd
06628466
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
35 deletions
+37
-35
repose/repose.go
repose/repose.go
+7
-30
traversal/fns.go
traversal/fns.go
+25
-2
traversal/selector/selector.go
traversal/selector/selector.go
+5
-3
No files found.
repose/repose.go
View file @
4671c928
...
...
@@ -12,36 +12,13 @@ import (
multihash
"github.com/multiformats/go-multihash"
)
// An example use of LinkContext in LinkLoader logic might be inspecting the
// LinkNode, and if it's using the type system, inspecting its Type property;
// then deciding on whether or not we want to load objects of that Type.
// This might be used to do a traversal which looks at all directory objects,
// but not file contents, for example.
type
LinkContext
struct
{
LinkPath
traversal
.
Path
// whoops, nice cycle
LinkNode
ipld
.
Node
// has the cid again, but also might have type info // always zero for writing new nodes, for obvi reasons.
ParentNode
ipld
.
Node
}
type
LinkLoader
func
(
context
.
Context
,
cid
.
Cid
,
LinkContext
)
(
ipld
.
Node
,
error
)
// One presumes implementations will also *save* the content somewhere.
// The LinkContext parameter is a nod to this -- none of those parameters
// are relevant to the generation of the Cid itself, but perhaps one might
// want to use them when deciding where to store some files, etc.
type
LinkBuilder
func
(
ctx
context
.
Context
,
node
ipld
.
Node
,
lnkCtx
LinkContext
,
multicodecType
uint64
,
multihashType
uint64
,
multihashLength
int
,
)
(
cid
.
Cid
,
error
)
func
ComposeLinkLoader
(
actualLoader
ActualLoader
,
nodeBuilderChooser
NodeBuilderChooser
,
multicodecTable
MulticodecDecodeTable
,
// there is no multihashTable, because those are effectively hardcoded in advance.
)
LinkLoader
{
return
func
(
ctx
context
.
Context
,
lnk
cid
.
Cid
,
lnkCtx
LinkContext
)
(
ipld
.
Node
,
error
)
{
)
traversal
.
LinkLoader
{
return
func
(
ctx
context
.
Context
,
lnk
cid
.
Cid
,
lnkCtx
traversal
.
LinkContext
)
(
ipld
.
Node
,
error
)
{
// Pick what kind of ipld.Node implementation we want to produce.
// (In some cases, this may be a nearly constant choice; in case of use
// with schema types, this might return complex information based on
...
...
@@ -87,18 +64,18 @@ func ComposeLinkLoader(
}
}
type
NodeBuilderChooser
func
(
context
.
Context
,
LinkContext
)
(
ipld
.
NodeBuilder
,
error
)
type
NodeBuilderChooser
func
(
context
.
Context
,
traversal
.
LinkContext
)
(
ipld
.
NodeBuilder
,
error
)
type
ActualLoader
func
(
context
.
Context
,
cid
.
Cid
,
LinkContext
)
(
io
.
Reader
,
error
)
type
ActualLoader
func
(
context
.
Context
,
cid
.
Cid
,
traversal
.
LinkContext
)
(
io
.
Reader
,
error
)
func
ComposeLinkBuilder
(
actualStorer
ActualStorer
,
multicodecTable
MulticodecEncodeTable
,
// there is no multihashTable, because those are effectively hardcoded in advance.
)
LinkBuilder
{
)
traversal
.
LinkBuilder
{
return
func
(
ctx
context
.
Context
,
node
ipld
.
Node
,
lnkCtx
LinkContext
,
node
ipld
.
Node
,
lnkCtx
traversal
.
LinkContext
,
multicodecType
uint64
,
multihashType
uint64
,
multihashLength
int
,
)
(
cid
.
Cid
,
error
)
{
// Open the byte writer.
...
...
@@ -128,6 +105,6 @@ func ComposeLinkBuilder(
}
}
type
ActualStorer
func
(
context
.
Context
,
LinkContext
)
(
io
.
Writer
,
StoreCommitter
,
error
)
type
ActualStorer
func
(
context
.
Context
,
traversal
.
LinkContext
)
(
io
.
Writer
,
StoreCommitter
,
error
)
type
StoreCommitter
func
(
cid
.
Cid
)
error
traversal/fns.go
View file @
4671c928
...
...
@@ -7,6 +7,29 @@ import (
ipld
"github.com/ipld/go-ipld-prime"
)
// An example use of LinkContext in LinkLoader logic might be inspecting the
// LinkNode, and if it's using the type system, inspecting its Type property;
// then deciding on whether or not we want to load objects of that Type.
// This might be used to do a traversal which looks at all directory objects,
// but not file contents, for example.
type
LinkContext
struct
{
LinkPath
Path
// whoops, nice cycle
LinkNode
ipld
.
Node
// has the cid again, but also might have type info // always zero for writing new nodes, for obvi reasons.
ParentNode
ipld
.
Node
}
type
LinkLoader
func
(
context
.
Context
,
cid
.
Cid
,
LinkContext
)
(
ipld
.
Node
,
error
)
// One presumes implementations will also *save* the content somewhere.
// The LinkContext parameter is a nod to this -- none of those parameters
// are relevant to the generation of the Cid itself, but perhaps one might
// want to use them when deciding where to store some files, etc.
type
LinkBuilder
func
(
ctx
context
.
Context
,
node
ipld
.
Node
,
lnkCtx
LinkContext
,
multicodecType
uint64
,
multihashType
uint64
,
multihashLength
int
,
)
(
cid
.
Cid
,
error
)
// VisitFn is a read-only visitor.
type
VisitFn
func
(
TraversalProgress
,
ipld
.
Node
)
error
...
...
@@ -29,7 +52,7 @@ type TraversalProgress struct {
}
type
TraversalConfig
struct
{
Ctx
context
.
Context
// Context carried through a traversal. Optional; use it if you need cancellation.
// `l
inkLoader
func(Context, CID, Path, parent Node) (Node, error)` probably belongs here.
Ctx
context
.
Context
// Context carried through a traversal. Optional; use it if you need cancellation.
L
inkLoader
LinkLoader
// `blockWriter func(Context, Node, multicodec(?)) (CID, error)` probably belongs here.
}
traversal/selector/selector.go
View file @
4671c928
package
selector
import
(
ipld
"github.com/ipld/go-ipld-prime"
)
import
ipld
"github.com/ipld/go-ipld-prime"
type
Selector
interface
{
Explore
(
ipld
.
Node
)
(
ipld
.
KeyIterator
,
Selector
)
Decide
(
ipld
.
Node
)
bool
}
func
ReifySelector
(
cidRootedSelector
ipld
.
Node
)
(
Selector
,
error
)
{
return
nil
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment