Documentation ¶
Overview ¶
Package consulfs implements a FUSE filesystem that is backed by a Consul Key-Value store.
API Usage --------- ConsulFS is implemented using the "bazil.org/fuse" package as a file system service. Refer to the fuse package for complete documentation on how to create a new FUSE connection that services a mount point. To have that mount point serve ConsulFS files, create a new instance of `ConsulFS` and pass it to the "bazil.org/fuse/fs".Server.Serve() method. The source code for the mounter at "github.com/bwester/consulfs/cmd/consulfs" gives a full example of how to perform the mounting.
The `ConsulFS` instance contains common configuration data and is referenced by all file and directory inodes. Notably, 'UID' and 'GID' set the uid and gid ownership of all files. The `Consul` option is used to perform all Consul HTTP RPCs. The `CancelConsulKV` struct is included in this package as a wrapper around the standard Consul APIs. It is vital for system stability that the file system not get into an uninteruptable sleep waiting for a remote RPC to complete, so CancelConsulKV will abandon requests when needed.
Index ¶
- Constants
- type CancelConsulKV
- func (cckv *CancelConsulKV) CAS(ctx context.Context, p *consul.KVPair, q *consul.WriteOptions) (bool, *consul.WriteMeta, error)
- func (cckv *CancelConsulKV) Delete(ctx context.Context, key string, w *consul.WriteOptions) (*consul.WriteMeta, error)
- func (cckv *CancelConsulKV) Get(ctx context.Context, key string, q *consul.QueryOptions) (*consul.KVPair, *consul.QueryMeta, error)
- func (cckv *CancelConsulKV) Keys(ctx context.Context, prefix string, separator string, q *consul.QueryOptions) ([]string, *consul.QueryMeta, error)
- func (cckv *CancelConsulKV) Put(ctx context.Context, p *consul.KVPair, q *consul.WriteOptions) (*consul.WriteMeta, error)
- type ConsulCanceler
- type ConsulFS
Constants ¶
const MaxWriteAttempts = 10
MaxWriteAttempts sets the number of time a write will be attempted before an error is returned.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancelConsulKV ¶ added in v0.1.1
type CancelConsulKV struct { // The Consul client to use for executing operations. Client *consul.Client // Logger gets all the logging messages Logger *logrus.Logger }
CancelConsulKV is the concrete implementation of ConsulCanceler. It takes a Consul `Client` object and performs all operations using that client.
func (*CancelConsulKV) CAS ¶ added in v0.1.1
func (cckv *CancelConsulKV) CAS( ctx context.Context, p *consul.KVPair, q *consul.WriteOptions, ) (bool, *consul.WriteMeta, error)
CAS performs a compare-and-swap on a key
func (*CancelConsulKV) Delete ¶ added in v0.1.1
func (cckv *CancelConsulKV) Delete( ctx context.Context, key string, w *consul.WriteOptions, ) (*consul.WriteMeta, error)
Delete removes a key and its data.
func (*CancelConsulKV) Get ¶ added in v0.1.1
func (cckv *CancelConsulKV) Get( ctx context.Context, key string, q *consul.QueryOptions, ) (*consul.KVPair, *consul.QueryMeta, error)
Get returns the current value of a key.
type ConsulCanceler ¶
type ConsulCanceler interface { CAS( ctx context.Context, p *consul.KVPair, q *consul.WriteOptions, ) (bool, *consul.WriteMeta, error) Delete( ctx context.Context, key string, w *consul.WriteOptions, ) (*consul.WriteMeta, error) Get( ctx context.Context, key string, q *consul.QueryOptions, ) (*consul.KVPair, *consul.QueryMeta, error) Keys( ctx context.Context, prefix string, separator string, q *consul.QueryOptions, ) ([]string, *consul.QueryMeta, error) Put( ctx context.Context, p *consul.KVPair, q *consul.WriteOptions, ) (*consul.WriteMeta, error) }
ConsulCanceler defines an API for accessing a Consul Key-Value store. It's mostly a clone of `github.com/hashicorp/consul/api.KV`, but it adds a parameter for a context to method signatures.
Using this interface is deprecated. As of v0.9.0, the official Consul API package allows API calls be canceled using a Context, making this interface unnecessary.
type ConsulFS ¶ added in v0.1.1
type ConsulFS struct { // Consul contains a referene to the ConsulCanceler that should be used for all operations. Consul ConsulCanceler // UID contains the UID that will own all the files in the file system. UID uint32 // GID contains the GID that will own all the files in the file system. GID uint32 // Perms sets the file permission flags for all files and directories. If zero, a // default of 0600 will be used. Perms os.FileMode // RootPath contains the path to the root of the filesystem in Consul. This // string will be prefixed to all paths requested from Consul. A path // separator will be added if needed. RootPath string // Messages will be sent to this logger Logger *logrus.Logger }
ConsulFS is the main file system object that represents a Consul Key-Value store.