Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interface for go-ipfs clients #176

Closed
jbenet opened this issue Oct 14, 2014 · 18 comments
Closed

interface for go-ipfs clients #176

jbenet opened this issue Oct 14, 2014 · 18 comments
Labels
exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue topic/core Topic core topic/docs-ipfs Topic docs-ipfs

Comments

@jbenet
Copy link
Member

jbenet commented Oct 14, 2014

Would be great to setup a very simple interface for programmatic go-ipfs clients.

Let's use this issue to outline what the interface below should look like

package ipfs

// maybe rebind things clients will need, so they dont have to import
// a ton of packages.
type Key u.Key
type Block blocks.Block
type Object mdag.Node
...

// Node is an IPFS Node
type Node interface {

   // blocks
   GetBlock(Key) (Block, error)
   PutBlock(Key, Block) error

   // objects
   GetObject(Key) (Object, error)
   PutObject(Object) error

   // etc.
}

And some nice functions that can setup a node for you, given certain specific types of workflows:

// when you have a directory locally
func NewNodeWithConfigDir(string) (ipfs.Node, error) { ... }

// when you create your own config
func NewNodeWithConfig(cfg config.Config) (ipfs.Node, error) { ... }

// creates new keys, memory only ds, etc...
func NewEphemeralNode() (ipfs.Node, error) { ... }

// etc.
@whyrusleeping
Copy link
Member

Huh, dhtHell would love to have this

@jbenet jbenet added help wanted Seeking public contribution on this issue and removed help wanted Seeking public contribution on this issue labels Oct 14, 2014
@ehmry
Copy link
Contributor

ehmry commented Oct 14, 2014

How about a convience Writer?

type ObjectWriter interface {
    // Object that represents everything written thus far
    Root() Object

    Write([]byte) (int, error) {

    // Flush the last chunk in the internal splitter and prevent further writes.
    Close() error
}

@whyrusleeping
Copy link
Member

ehmry, thats called the DagWriter, its in unixfs/io

@ehmry
Copy link
Contributor

ehmry commented Oct 14, 2014

heh, so it is.

@ehmry
Copy link
Contributor

ehmry commented Oct 16, 2014

Turns out if you make DAGService an interface, you can swap out the blockservice with RPC calls and reuse DagWriter/DagReader in a simple client.

https://github.com/ehmry/go-ipfs/compare/client

@whyrusleeping
Copy link
Member

i like that

@btc
Copy link
Contributor

btc commented Jan 15, 2015

hey @ehmry would you like to submit a PR for DAGService as an interface?

@ehmry
Copy link
Contributor

ehmry commented Jan 16, 2015

@briantigerchow Let me look and see what I got.

@jbenet jbenet added the topic/core Topic core label Mar 28, 2015
@ehmry
Copy link
Contributor

ehmry commented Apr 7, 2015

@ehmry
Copy link
Contributor

ehmry commented Apr 7, 2015

I'm confused, DAGService is an interface at master, and I know longer remember what I was working on.

@whyrusleeping
Copy link
Member

I think it was the distinction between mutable and immutable dag nodes. But i could be wrong

@whyrusleeping
Copy link
Member

i have a common interface here: https://github.com/whyrusleeping/fallback-ipfs-shell

that lets us have the same 'object' be either an http client or an embedded node. It needs some documentation work, but it's the direction I want to go with this.

@daviddias
Copy link
Member

Let's transform this issue into a documentation effort on how to use IPFS programatically in go, using:

  • HTTP API
  • Core (for embedding IPFS directly)

There is currently one example available at https://ipfs.io/ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D/example#/ipfs/QmQwAP9vFjbCtKvD8RkJdCvPHqLQjZfW7Mqbbqx18zd8j7/api/service/readme.md (would be good to verify that it still follows the current API)

@RichardLitt this would fit nicely into the API documentation efforts

@daviddias daviddias removed the icebox label Jan 2, 2016
@RichardLitt RichardLitt added exp/novice Someone with a little familiarity can pick up and removed difficulty: easy labels Feb 2, 2016
@novocodev
Copy link

novocodev commented Jun 7, 2016

I'd like to use IPFS embedded in my golang App, has the convenience API described at the top of this ticket been implemented or are there any further examples of how to access the current IPFS implementation programatically.

@ghost
Copy link

ghost commented Jun 7, 2016

@novocodev go-ipfs-api might get you some of what you need: https://github.com/ipfs/go-ipfs-api

@ghost
Copy link

ghost commented Jun 7, 2016

Eh nevermind sorry -- I misread that you want to embed go-ipfs.

@whyrusleeping
Copy link
Member

@lgierth can this be closed in favor of core api discussions?

@whyrusleeping whyrusleeping assigned ghost Dec 15, 2016
@ghost
Copy link

ghost commented Dec 18, 2016

Yes, closing this.

The follow up on this is that there's now a Core API (ipfs/interface-ipfs-core) which all IPFS implementations should implement. The go-ipfs implementation of this has only just started and currently lives in the core/coreapi package.

@ghost ghost closed this as completed Dec 18, 2016
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this issue Oct 23, 2021
@aschmahmann aschmahmann mentioned this issue Dec 1, 2021
80 tasks
Jorropo pushed a commit that referenced this issue May 30, 2023
Currently any clients created through `NewApiWithClient` will make a
HTTP request to the api, even if the multiaddress specifies TLS or (the
deprecated multiaddr option) https.

This commit addresses this by having NewApiWithClient iterate the
available protocols for the multiaddress, specifying the URL proto as
https if it finds TLS or HTTPS is specified. The default continues to be
http for those multiaddresses that do not specify these options.

Should resolve #176

This commit was moved from ipfs/go-ipfs-http-client@7e1de1f
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue topic/core Topic core topic/docs-ipfs Topic docs-ipfs
Projects
None yet
Development

No branches or pull requests

8 participants