id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
141,200
goadesign/gorma
dsl/runner.go
buildSourceDefinition
func buildSourceDefinition(failIfNotSD bool) (*gorma.BuildSource, bool) { a, ok := dslengine.CurrentDefinition().(*gorma.BuildSource) if !ok && failIfNotSD { dslengine.IncompatibleDSL() } return a, ok }
go
func buildSourceDefinition(failIfNotSD bool) (*gorma.BuildSource, bool) { a, ok := dslengine.CurrentDefinition().(*gorma.BuildSource) if !ok && failIfNotSD { dslengine.IncompatibleDSL() } return a, ok }
[ "func", "buildSourceDefinition", "(", "failIfNotSD", "bool", ")", "(", "*", "gorma", ".", "BuildSource", ",", "bool", ")", "{", "a", ",", "ok", ":=", "dslengine", ".", "CurrentDefinition", "(", ")", ".", "(", "*", "gorma", ".", "BuildSource", ")", "\n", ...
// buildSourceDefinition returns true and current context if it is an BuildSource // nil and false otherwise.
[ "buildSourceDefinition", "returns", "true", "and", "current", "context", "if", "it", "is", "an", "BuildSource", "nil", "and", "false", "otherwise", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/dsl/runner.go#L56-L62
141,201
goadesign/gorma
dsl/runner.go
attributeDefinition
func attributeDefinition(failIfNotSD bool) (*design.AttributeDefinition, bool) { a, ok := dslengine.CurrentDefinition().(*design.AttributeDefinition) if !ok && failIfNotSD { dslengine.IncompatibleDSL() } return a, ok }
go
func attributeDefinition(failIfNotSD bool) (*design.AttributeDefinition, bool) { a, ok := dslengine.CurrentDefinition().(*design.AttributeDefinition) if !ok && failIfNotSD { dslengine.IncompatibleDSL() } return a, ok }
[ "func", "attributeDefinition", "(", "failIfNotSD", "bool", ")", "(", "*", "design", ".", "AttributeDefinition", ",", "bool", ")", "{", "a", ",", "ok", ":=", "dslengine", ".", "CurrentDefinition", "(", ")", ".", "(", "*", "design", ".", "AttributeDefinition",...
// attributeDefinition returns true and current context if it is an AttributeDefinition // nil and false otherwise.
[ "attributeDefinition", "returns", "true", "and", "current", "context", "if", "it", "is", "an", "AttributeDefinition", "nil", "and", "false", "otherwise", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/dsl/runner.go#L66-L72
141,202
goadesign/gorma
validate.go
Validate
func (a *StorageGroupDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validating Group") verr := new(dslengine.ValidationErrors) if a.Name == "" { verr.Add(a, "storage group name not defined") } a.IterateStores(func(store *RelationalStoreDefinition) error { verr.Merge(store.Validate()) retur...
go
func (a *StorageGroupDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validating Group") verr := new(dslengine.ValidationErrors) if a.Name == "" { verr.Add(a, "storage group name not defined") } a.IterateStores(func(store *RelationalStoreDefinition) error { verr.Merge(store.Validate()) retur...
[ "func", "(", "a", "*", "StorageGroupDefinition", ")", "Validate", "(", ")", "*", "dslengine", ".", "ValidationErrors", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "verr", ":=", "new", "(", "dslengine", ".", "ValidationErrors", ")", "\n", "if"...
// Validate tests whether the StorageGroup definition is consistent.
[ "Validate", "tests", "whether", "the", "StorageGroup", "definition", "is", "consistent", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/validate.go#L10-L22
141,203
goadesign/gorma
validate.go
Validate
func (a *RelationalStoreDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validating Store") verr := new(dslengine.ValidationErrors) if a.Name == "" { verr.Add(a, "store name not defined") } if a.Parent == nil { verr.Add(a, "missing storage group parent") } a.IterateModels(func(model *Relatio...
go
func (a *RelationalStoreDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validating Store") verr := new(dslengine.ValidationErrors) if a.Name == "" { verr.Add(a, "store name not defined") } if a.Parent == nil { verr.Add(a, "missing storage group parent") } a.IterateModels(func(model *Relatio...
[ "func", "(", "a", "*", "RelationalStoreDefinition", ")", "Validate", "(", ")", "*", "dslengine", ".", "ValidationErrors", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "verr", ":=", "new", "(", "dslengine", ".", "ValidationErrors", ")", "\n", "...
// Validate tests whether the RelationalStore definition is consistent.
[ "Validate", "tests", "whether", "the", "RelationalStore", "definition", "is", "consistent", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/validate.go#L25-L40
141,204
goadesign/gorma
validate.go
Validate
func (a *RelationalModelDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validating Model") verr := new(dslengine.ValidationErrors) if a.ModelName == "" { verr.Add(a, "model name not defined") } if a.Parent == nil { verr.Add(a, "missing relational store parent") } a.IterateFields(func(field ...
go
func (a *RelationalModelDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validating Model") verr := new(dslengine.ValidationErrors) if a.ModelName == "" { verr.Add(a, "model name not defined") } if a.Parent == nil { verr.Add(a, "missing relational store parent") } a.IterateFields(func(field ...
[ "func", "(", "a", "*", "RelationalModelDefinition", ")", "Validate", "(", ")", "*", "dslengine", ".", "ValidationErrors", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "verr", ":=", "new", "(", "dslengine", ".", "ValidationErrors", ")", "\n", "...
// Validate tests whether the RelationalModel definition is consistent.
[ "Validate", "tests", "whether", "the", "RelationalModel", "definition", "is", "consistent", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/validate.go#L43-L58
141,205
goadesign/gorma
validate.go
Validate
func (field *RelationalFieldDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validing Field") verr := new(dslengine.ValidationErrors) if field.Parent == nil { verr.Add(field, "missing relational model parent") } if field.FieldName == "" { verr.Add(field, "field name not defined") } return v...
go
func (field *RelationalFieldDefinition) Validate() *dslengine.ValidationErrors { fmt.Println("Validing Field") verr := new(dslengine.ValidationErrors) if field.Parent == nil { verr.Add(field, "missing relational model parent") } if field.FieldName == "" { verr.Add(field, "field name not defined") } return v...
[ "func", "(", "field", "*", "RelationalFieldDefinition", ")", "Validate", "(", ")", "*", "dslengine", ".", "ValidationErrors", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "verr", ":=", "new", "(", "dslengine", ".", "ValidationErrors", ")", "\n\n...
// Validate tests whether the RelationalField definition is consistent.
[ "Validate", "tests", "whether", "the", "RelationalField", "definition", "is", "consistent", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/validate.go#L61-L72
141,206
goadesign/gorma
storagegroup.go
IterateStores
func (sd *StorageGroupDefinition) IterateStores(it StoreIterator) error { if sd == nil { return nil } if sd.RelationalStores != nil { names := make([]string, len(sd.RelationalStores)) i := 0 for n := range sd.RelationalStores { names[i] = n i++ } sort.Strings(names) for _, n := range names { i...
go
func (sd *StorageGroupDefinition) IterateStores(it StoreIterator) error { if sd == nil { return nil } if sd.RelationalStores != nil { names := make([]string, len(sd.RelationalStores)) i := 0 for n := range sd.RelationalStores { names[i] = n i++ } sort.Strings(names) for _, n := range names { i...
[ "func", "(", "sd", "*", "StorageGroupDefinition", ")", "IterateStores", "(", "it", "StoreIterator", ")", "error", "{", "if", "sd", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "sd", ".", "RelationalStores", "!=", "nil", "{", "names", ":=", ...
// IterateStores runs an iterator function once per Relational Store in the // StorageGroup's Store list.
[ "IterateStores", "runs", "an", "iterator", "function", "once", "per", "Relational", "Store", "in", "the", "StorageGroup", "s", "Store", "list", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/storagegroup.go#L22-L41
141,207
goadesign/gorma
storagegroup.go
DependsOn
func (sd *StorageGroupDefinition) DependsOn() []dslengine.Root { return []dslengine.Root{design.Design, design.GeneratedMediaTypes} }
go
func (sd *StorageGroupDefinition) DependsOn() []dslengine.Root { return []dslengine.Root{design.Design, design.GeneratedMediaTypes} }
[ "func", "(", "sd", "*", "StorageGroupDefinition", ")", "DependsOn", "(", ")", "[", "]", "dslengine", ".", "Root", "{", "return", "[", "]", "dslengine", ".", "Root", "{", "design", ".", "Design", ",", "design", ".", "GeneratedMediaTypes", "}", "\n", "}" ]
// DependsOn return the DSL roots the Gorma DSL root depends on, that's the goa API DSL.
[ "DependsOn", "return", "the", "DSL", "roots", "the", "Gorma", "DSL", "root", "depends", "on", "that", "s", "the", "goa", "API", "DSL", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/storagegroup.go#L71-L73
141,208
goadesign/gorma
relationalfield.go
FieldDefinition
func (f *RelationalFieldDefinition) FieldDefinition() string { var comment string if f.Description != "" { comment = "// " + f.Description } def := fmt.Sprintf("%s\t%s %s %s\n", f.FieldName, goDatatype(f, true), tags(f), comment) return def }
go
func (f *RelationalFieldDefinition) FieldDefinition() string { var comment string if f.Description != "" { comment = "// " + f.Description } def := fmt.Sprintf("%s\t%s %s %s\n", f.FieldName, goDatatype(f, true), tags(f), comment) return def }
[ "func", "(", "f", "*", "RelationalFieldDefinition", ")", "FieldDefinition", "(", ")", "string", "{", "var", "comment", "string", "\n", "if", "f", ".", "Description", "!=", "\"", "\"", "{", "comment", "=", "\"", "\"", "+", "f", ".", "Description", "\n", ...
// FieldDefinition returns the field's struct definition.
[ "FieldDefinition", "returns", "the", "field", "s", "struct", "definition", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/relationalfield.go#L47-L54
141,209
goadesign/gorma
relationalfield.go
Underscore
func (f *RelationalFieldDefinition) Underscore() string { runes := []rune(f.FieldName) length := len(runes) var out []rune for i := 0; i < length; i++ { if i > 0 && unicode.IsUpper(runes[i]) && ((i+1 < length && unicode.IsLower(runes[i+1])) || unicode.IsLower(runes[i-1])) { out = append(out, '_') } out = ...
go
func (f *RelationalFieldDefinition) Underscore() string { runes := []rune(f.FieldName) length := len(runes) var out []rune for i := 0; i < length; i++ { if i > 0 && unicode.IsUpper(runes[i]) && ((i+1 < length && unicode.IsLower(runes[i+1])) || unicode.IsLower(runes[i-1])) { out = append(out, '_') } out = ...
[ "func", "(", "f", "*", "RelationalFieldDefinition", ")", "Underscore", "(", ")", "string", "{", "runes", ":=", "[", "]", "rune", "(", "f", ".", "FieldName", ")", "\n", "length", ":=", "len", "(", "runes", ")", "\n\n", "var", "out", "[", "]", "rune", ...
// Underscore returns the field name as a lowercase string in snake case.
[ "Underscore", "returns", "the", "field", "name", "as", "a", "lowercase", "string", "in", "snake", "case", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/relationalfield.go#L67-L80
141,210
goadesign/gorma
relationalstore.go
IterateModels
func (sd *RelationalStoreDefinition) IterateModels(it ModelIterator) error { names := make([]string, len(sd.RelationalModels)) i := 0 for n := range sd.RelationalModels { names[i] = n i++ } sort.Strings(names) for _, n := range names { if err := it(sd.RelationalModels[n]); err != nil { return err } } ...
go
func (sd *RelationalStoreDefinition) IterateModels(it ModelIterator) error { names := make([]string, len(sd.RelationalModels)) i := 0 for n := range sd.RelationalModels { names[i] = n i++ } sort.Strings(names) for _, n := range names { if err := it(sd.RelationalModels[n]); err != nil { return err } } ...
[ "func", "(", "sd", "*", "RelationalStoreDefinition", ")", "IterateModels", "(", "it", "ModelIterator", ")", "error", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "sd", ".", "RelationalModels", ")", ")", "\n", "i", ":=", "0", "\...
// IterateModels runs an iterator function once per Model in the Store's model list.
[ "IterateModels", "runs", "an", "iterator", "function", "once", "per", "Model", "in", "the", "Store", "s", "model", "list", "." ]
0c763c6f61bb451947875a3eec66926760a17db0
https://github.com/goadesign/gorma/blob/0c763c6f61bb451947875a3eec66926760a17db0/relationalstore.go#L42-L56
141,211
lytics/cloudstorage
sftp/store.go
NewClientFromConfig
func NewClientFromConfig(clientCtx context.Context, conf *cloudstorage.Config) (*Client, error) { var sshConfig *ssh.ClientConfig var err error switch conf.AuthMethod { case AuthUserKey: //"userkey" sshConfig, err = ConfigUserKey(conf.Settings.String(ConfKeyUser), conf.Settings.String(ConfKeyPrivateKey)) if e...
go
func NewClientFromConfig(clientCtx context.Context, conf *cloudstorage.Config) (*Client, error) { var sshConfig *ssh.ClientConfig var err error switch conf.AuthMethod { case AuthUserKey: //"userkey" sshConfig, err = ConfigUserKey(conf.Settings.String(ConfKeyUser), conf.Settings.String(ConfKeyPrivateKey)) if e...
[ "func", "NewClientFromConfig", "(", "clientCtx", "context", ".", "Context", ",", "conf", "*", "cloudstorage", ".", "Config", ")", "(", "*", "Client", ",", "error", ")", "{", "var", "sshConfig", "*", "ssh", ".", "ClientConfig", "\n", "var", "err", "error", ...
// NewClientFromConfig validates configuration then creates new client from token
[ "NewClientFromConfig", "validates", "configuration", "then", "creates", "new", "client", "from", "token" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L103-L129
141,212
lytics/cloudstorage
sftp/store.go
NewClient
func NewClient(clientCtx context.Context, conf *cloudstorage.Config, host string, port int, folder string, config *ssh.ClientConfig) (*Client, error) { //u.Debugf("new sftp host=%q port=%d folder=%q", host, port, folder) target, err := sftpAddr(host, port) if err != nil { gou.WarnCtx(clientCtx, "failed creating a...
go
func NewClient(clientCtx context.Context, conf *cloudstorage.Config, host string, port int, folder string, config *ssh.ClientConfig) (*Client, error) { //u.Debugf("new sftp host=%q port=%d folder=%q", host, port, folder) target, err := sftpAddr(host, port) if err != nil { gou.WarnCtx(clientCtx, "failed creating a...
[ "func", "NewClient", "(", "clientCtx", "context", ".", "Context", ",", "conf", "*", "cloudstorage", ".", "Config", ",", "host", "string", ",", "port", "int", ",", "folder", "string", ",", "config", "*", "ssh", ".", "ClientConfig", ")", "(", "*", "Client"...
// NewClient returns a new SFTP Client // Make sure to close SFTP connection when done
[ "NewClient", "returns", "a", "new", "SFTP", "Client", "Make", "sure", "to", "close", "SFTP", "connection", "when", "done" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L133-L172
141,213
lytics/cloudstorage
sftp/store.go
NewObject
func (m *Client) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := m.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } cf := cloudstorage.CachePathObj(m.cachepat...
go
func (m *Client) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := m.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } cf := cloudstorage.CachePathObj(m.cachepat...
[ "func", "(", "m", "*", "Client", ")", "NewObject", "(", "objectname", "string", ")", "(", "cloudstorage", ".", "Object", ",", "error", ")", "{", "obj", ",", "err", ":=", "m", ".", "Get", "(", "context", ".", "Background", "(", ")", ",", "objectname",...
// NewObject create a new object with given name. Will not write to remote // sftp until Close is called.
[ "NewObject", "create", "a", "new", "object", "with", "given", "name", ".", "Will", "not", "write", "to", "remote", "sftp", "until", "Close", "is", "called", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L249-L268
141,214
lytics/cloudstorage
sftp/store.go
Get
func (m *Client) Get(ctx context.Context, name string) (cloudstorage.Object, error) { if !m.Exists(name) { return nil, cloudstorage.ErrObjectNotFound } get := Concat(m.bucket, name) //gou.DebugCtx(m.clientCtx, "getting file %s", get) f, err := m.client.Stat(get) if err != nil { return nil, err } return newO...
go
func (m *Client) Get(ctx context.Context, name string) (cloudstorage.Object, error) { if !m.Exists(name) { return nil, cloudstorage.ErrObjectNotFound } get := Concat(m.bucket, name) //gou.DebugCtx(m.clientCtx, "getting file %s", get) f, err := m.client.Stat(get) if err != nil { return nil, err } return newO...
[ "func", "(", "m", "*", "Client", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "(", "cloudstorage", ".", "Object", ",", "error", ")", "{", "if", "!", "m", ".", "Exists", "(", "name", ")", "{", "return", "nil", ","...
// Get opens a file for read or writing
[ "Get", "opens", "a", "file", "for", "read", "or", "writing" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L271-L282
141,215
lytics/cloudstorage
sftp/store.go
Delete
func (m *Client) Delete(ctx context.Context, filename string) error { if !m.Exists(filename) { gou.Warnf("does not exist????? %q", filename) return os.ErrNotExist } r := Concat(m.bucket, filename) //gou.InfoCtx(m.clientCtx, "removing file %q", r) return m.client.Remove(r) }
go
func (m *Client) Delete(ctx context.Context, filename string) error { if !m.Exists(filename) { gou.Warnf("does not exist????? %q", filename) return os.ErrNotExist } r := Concat(m.bucket, filename) //gou.InfoCtx(m.clientCtx, "removing file %q", r) return m.client.Remove(r) }
[ "func", "(", "m", "*", "Client", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "filename", "string", ")", "error", "{", "if", "!", "m", ".", "Exists", "(", "filename", ")", "{", "gou", ".", "Warnf", "(", "\"", "\"", ",", "filename", ...
// Delete deletes a file
[ "Delete", "deletes", "a", "file" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L304-L312
141,216
lytics/cloudstorage
sftp/store.go
List
func (m *Client) List(ctx context.Context, q cloudstorage.Query) (*cloudstorage.ObjectsResponse, error) { objs := &cloudstorage.ObjectsResponse{ Objects: make(cloudstorage.Objects, 0), } err := m.listFiles(ctx, q, objs, m.bucket) if err != nil { gou.Warnf("fetch listFiles error %v", err) return nil, err } ...
go
func (m *Client) List(ctx context.Context, q cloudstorage.Query) (*cloudstorage.ObjectsResponse, error) { objs := &cloudstorage.ObjectsResponse{ Objects: make(cloudstorage.Objects, 0), } err := m.listFiles(ctx, q, objs, m.bucket) if err != nil { gou.Warnf("fetch listFiles error %v", err) return nil, err } ...
[ "func", "(", "m", "*", "Client", ")", "List", "(", "ctx", "context", ".", "Context", ",", "q", "cloudstorage", ".", "Query", ")", "(", "*", "cloudstorage", ".", "ObjectsResponse", ",", "error", ")", "{", "objs", ":=", "&", "cloudstorage", ".", "Objects...
// List lists files in a directory
[ "List", "lists", "files", "in", "a", "directory" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L383-L396
141,217
lytics/cloudstorage
sftp/store.go
NewReader
func (m *Client) NewReader(o string) (io.ReadCloser, error) { return m.NewReaderWithContext(context.Background(), o) }
go
func (m *Client) NewReader(o string) (io.ReadCloser, error) { return m.NewReaderWithContext(context.Background(), o) }
[ "func", "(", "m", "*", "Client", ")", "NewReader", "(", "o", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "return", "m", ".", "NewReaderWithContext", "(", "context", ".", "Background", "(", ")", ",", "o", ")", "\n", "}" ]
// NewReader create file reader.
[ "NewReader", "create", "file", "reader", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L531-L533
141,218
lytics/cloudstorage
sftp/store.go
upload
func (o *object) upload(body io.Reader) (int64, error) { o.client.ensureDir(o.name) name := Concat(o.client.bucket, o.name) //gou.Infof("upload %q", name) if o.file != nil { if err := o.file.Close(); err != nil { gou.Warnf("error closing %q %v", name, err) } // TODO: Should we rename? two-phase commi...
go
func (o *object) upload(body io.Reader) (int64, error) { o.client.ensureDir(o.name) name := Concat(o.client.bucket, o.name) //gou.Infof("upload %q", name) if o.file != nil { if err := o.file.Close(); err != nil { gou.Warnf("error closing %q %v", name, err) } // TODO: Should we rename? two-phase commi...
[ "func", "(", "o", "*", "object", ")", "upload", "(", "body", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "o", ".", "client", ".", "ensureDir", "(", "o", ".", "name", ")", "\n\n", "name", ":=", "Concat", "(", "o", ".", "clien...
// Upload copies reader body bytes into underlying sftp file
[ "Upload", "copies", "reader", "body", "bytes", "into", "underlying", "sftp", "file" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L635-L676
141,219
lytics/cloudstorage
sftp/store.go
Delete
func (o *object) Delete() error { // this should be path/name ?? // gou.Debugf("Delete name=%q sftp.Name()=%q", o.name, o.fi.Name()) return o.client.Delete(context.Background(), o.name) }
go
func (o *object) Delete() error { // this should be path/name ?? // gou.Debugf("Delete name=%q sftp.Name()=%q", o.name, o.fi.Name()) return o.client.Delete(context.Background(), o.name) }
[ "func", "(", "o", "*", "object", ")", "Delete", "(", ")", "error", "{", "// this should be path/name ??", "// gou.Debugf(\"Delete name=%q sftp.Name()=%q\", o.name, o.fi.Name())", "return", "o", ".", "client", ".", "Delete", "(", "context", ".", "Background", "(", ")"...
// Delete delete the underlying object from ftp server.
[ "Delete", "delete", "the", "underlying", "object", "from", "ftp", "server", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L768-L772
141,220
lytics/cloudstorage
sftp/store.go
sftpAddr
func sftpAddr(host string, port int) (string, error) { // remove things like ftp:// if i := strings.Index(host, "://"); i >= 0 { host = host[(i + 3):] } // remove trailing :host if i := strings.Index(host, ":"); i >= 0 { host = host[:i] } if host == "" { return "", fmt.Errorf("host name not recognized %s...
go
func sftpAddr(host string, port int) (string, error) { // remove things like ftp:// if i := strings.Index(host, "://"); i >= 0 { host = host[(i + 3):] } // remove trailing :host if i := strings.Index(host, ":"); i >= 0 { host = host[:i] } if host == "" { return "", fmt.Errorf("host name not recognized %s...
[ "func", "sftpAddr", "(", "host", "string", ",", "port", "int", ")", "(", "string", ",", "error", ")", "{", "// remove things like ftp://", "if", "i", ":=", "strings", ".", "Index", "(", "host", ",", "\"", "\"", ")", ";", "i", ">=", "0", "{", "host", ...
// sftpAddr build sftp address
[ "sftpAddr", "build", "sftp", "address" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/sftp/store.go#L984-L1004
141,221
lytics/cloudstorage
awss3/store.go
NewObject
func (f *FS) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := f.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } cf := cloudstorage.CachePathObj(f.cachepath, o...
go
func (f *FS) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := f.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } cf := cloudstorage.CachePathObj(f.cachepath, o...
[ "func", "(", "f", "*", "FS", ")", "NewObject", "(", "objectname", "string", ")", "(", "cloudstorage", ".", "Object", ",", "error", ")", "{", "obj", ",", "err", ":=", "f", ".", "Get", "(", "context", ".", "Background", "(", ")", ",", "objectname", "...
// NewObject of Type s3.
[ "NewObject", "of", "Type", "s3", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/awss3/store.go#L198-L216
141,222
lytics/cloudstorage
awss3/store.go
Objects
func (f *FS) Objects(ctx context.Context, q cloudstorage.Query) (cloudstorage.ObjectIterator, error) { return cloudstorage.NewObjectPageIterator(ctx, f, q), nil }
go
func (f *FS) Objects(ctx context.Context, q cloudstorage.Query) (cloudstorage.ObjectIterator, error) { return cloudstorage.NewObjectPageIterator(ctx, f, q), nil }
[ "func", "(", "f", "*", "FS", ")", "Objects", "(", "ctx", "context", ".", "Context", ",", "q", "cloudstorage", ".", "Query", ")", "(", "cloudstorage", ".", "ObjectIterator", ",", "error", ")", "{", "return", "cloudstorage", ".", "NewObjectPageIterator", "("...
// Objects returns an iterator over the objects in the s3 bucket that match the Query q. // If q is nil, no filtering is done.
[ "Objects", "returns", "an", "iterator", "over", "the", "objects", "in", "the", "s3", "bucket", "that", "match", "the", "Query", "q", ".", "If", "q", "is", "nil", "no", "filtering", "is", "done", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/awss3/store.go#L319-L321
141,223
lytics/cloudstorage
awss3/store.go
Sync
func (o *object) Sync() error { if !o.opened { return fmt.Errorf("object isn't opened object:%s", o.name) } if o.readonly { return fmt.Errorf("trying to Sync a readonly object:%s", o.name) } cachedcopy, err := os.OpenFile(o.cachepath, os.O_RDWR, 0664) if err != nil { return fmt.Errorf("couldn't open local...
go
func (o *object) Sync() error { if !o.opened { return fmt.Errorf("object isn't opened object:%s", o.name) } if o.readonly { return fmt.Errorf("trying to Sync a readonly object:%s", o.name) } cachedcopy, err := os.OpenFile(o.cachepath, os.O_RDWR, 0664) if err != nil { return fmt.Errorf("couldn't open local...
[ "func", "(", "o", "*", "object", ")", "Sync", "(", ")", "error", "{", "if", "!", "o", ".", "opened", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "o", ".", "name", ")", "\n", "}", "\n", "if", "o", ".", "readonly", "{", "return",...
// Sync syncs any changes in file up to s3.
[ "Sync", "syncs", "any", "changes", "in", "file", "up", "to", "s3", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/awss3/store.go#L637-L670
141,224
lytics/cloudstorage
awss3/store.go
Close
func (o *object) Close() error { if !o.opened { return nil } defer func() { os.Remove(o.cachepath) o.cachedcopy = nil o.opened = false }() if !o.readonly { err := o.cachedcopy.Sync() if err != nil { return err } } err := o.cachedcopy.Close() if err != nil { if !strings.Contains(err.Error(),...
go
func (o *object) Close() error { if !o.opened { return nil } defer func() { os.Remove(o.cachepath) o.cachedcopy = nil o.opened = false }() if !o.readonly { err := o.cachedcopy.Sync() if err != nil { return err } } err := o.cachedcopy.Close() if err != nil { if !strings.Contains(err.Error(),...
[ "func", "(", "o", "*", "object", ")", "Close", "(", ")", "error", "{", "if", "!", "o", ".", "opened", "{", "return", "nil", "\n", "}", "\n", "defer", "func", "(", ")", "{", "os", ".", "Remove", "(", "o", ".", "cachepath", ")", "\n", "o", ".",...
// Close this object
[ "Close", "this", "object" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/awss3/store.go#L673-L705
141,225
lytics/cloudstorage
awss3/store.go
Release
func (o *object) Release() error { if o.cachedcopy != nil { gou.Infof("release %q vs %q", o.cachedcopy.Name(), o.cachepath) o.cachedcopy.Close() return os.Remove(o.cachepath) } os.Remove(o.cachepath) return nil }
go
func (o *object) Release() error { if o.cachedcopy != nil { gou.Infof("release %q vs %q", o.cachedcopy.Name(), o.cachepath) o.cachedcopy.Close() return os.Remove(o.cachepath) } os.Remove(o.cachepath) return nil }
[ "func", "(", "o", "*", "object", ")", "Release", "(", ")", "error", "{", "if", "o", ".", "cachedcopy", "!=", "nil", "{", "gou", ".", "Infof", "(", "\"", "\"", ",", "o", ".", "cachedcopy", ".", "Name", "(", ")", ",", "o", ".", "cachepath", ")", ...
// Release this object, cleanup cached copy.
[ "Release", "this", "object", "cleanup", "cached", "copy", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/awss3/store.go#L708-L716
141,226
lytics/cloudstorage
google/store.go
NewGCSStore
func NewGCSStore(gcs *storage.Client, bucket, cachepath string, pagesize int) (*GcsFS, error) { err := os.MkdirAll(path.Dir(cachepath), 0775) if err != nil { return nil, fmt.Errorf("unable to create path. path=%s err=%v", cachepath, err) } uid := uuid.NewUUID().String() uid = strings.Replace(uid, "-", "", -1) ...
go
func NewGCSStore(gcs *storage.Client, bucket, cachepath string, pagesize int) (*GcsFS, error) { err := os.MkdirAll(path.Dir(cachepath), 0775) if err != nil { return nil, fmt.Errorf("unable to create path. path=%s err=%v", cachepath, err) } uid := uuid.NewUUID().String() uid = strings.Replace(uid, "-", "", -1) ...
[ "func", "NewGCSStore", "(", "gcs", "*", "storage", ".", "Client", ",", "bucket", ",", "cachepath", "string", ",", "pagesize", "int", ")", "(", "*", "GcsFS", ",", "error", ")", "{", "err", ":=", "os", ".", "MkdirAll", "(", "path", ".", "Dir", "(", "...
// NewGCSStore Create Google Cloud Storage Store.
[ "NewGCSStore", "Create", "Google", "Cloud", "Storage", "Store", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/store.go#L54-L70
141,227
lytics/cloudstorage
google/store.go
NewObject
func (g *GcsFS) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := g.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } cf := cloudstorage.CachePathObj(g.cachepath...
go
func (g *GcsFS) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := g.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } cf := cloudstorage.CachePathObj(g.cachepath...
[ "func", "(", "g", "*", "GcsFS", ")", "NewObject", "(", "objectname", "string", ")", "(", "cloudstorage", ".", "Object", ",", "error", ")", "{", "obj", ",", "err", ":=", "g", ".", "Get", "(", "context", ".", "Background", "(", ")", ",", "objectname", ...
// NewObject of Type GCS.
[ "NewObject", "of", "Type", "GCS", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/store.go#L92-L110
141,228
lytics/cloudstorage
google/store.go
Get
func (g *GcsFS) Get(ctx context.Context, objectpath string) (cloudstorage.Object, error) { gobj, err := g.gcsb().Object(objectpath).Attrs(context.Background()) // .Objects(context.Background(), q) if err != nil { if strings.Contains(err.Error(), "doesn't exist") { return nil, cloudstorage.ErrObjectNotFound } ...
go
func (g *GcsFS) Get(ctx context.Context, objectpath string) (cloudstorage.Object, error) { gobj, err := g.gcsb().Object(objectpath).Attrs(context.Background()) // .Objects(context.Background(), q) if err != nil { if strings.Contains(err.Error(), "doesn't exist") { return nil, cloudstorage.ErrObjectNotFound } ...
[ "func", "(", "g", "*", "GcsFS", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "objectpath", "string", ")", "(", "cloudstorage", ".", "Object", ",", "error", ")", "{", "gobj", ",", "err", ":=", "g", ".", "gcsb", "(", ")", ".", "Object", ...
// Get Gets a single File Object
[ "Get", "Gets", "a", "single", "File", "Object" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/store.go#L113-L128
141,229
lytics/cloudstorage
google/store.go
Move
func (g *GcsFS) Move(ctx context.Context, src, des cloudstorage.Object) error { srcgcs, ok := src.(*object) if !ok { return fmt.Errorf("Move source file expected GCS but got %T", src) } desgcs, ok := des.(*object) if !ok { return fmt.Errorf("Move destination expected GCS but got %T", des) } oh := srcgcs.gc...
go
func (g *GcsFS) Move(ctx context.Context, src, des cloudstorage.Object) error { srcgcs, ok := src.(*object) if !ok { return fmt.Errorf("Move source file expected GCS but got %T", src) } desgcs, ok := des.(*object) if !ok { return fmt.Errorf("Move destination expected GCS but got %T", des) } oh := srcgcs.gc...
[ "func", "(", "g", "*", "GcsFS", ")", "Move", "(", "ctx", "context", ".", "Context", ",", "src", ",", "des", "cloudstorage", ".", "Object", ")", "error", "{", "srcgcs", ",", "ok", ":=", "src", ".", "(", "*", "object", ")", "\n", "if", "!", "ok", ...
// Move which is a Copy & Delete
[ "Move", "which", "is", "a", "Copy", "&", "Delete" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/store.go#L194-L213
141,230
lytics/cloudstorage
google/store.go
NewReader
func (g *GcsFS) NewReader(o string) (io.ReadCloser, error) { return g.NewReaderWithContext(context.Background(), o) }
go
func (g *GcsFS) NewReader(o string) (io.ReadCloser, error) { return g.NewReaderWithContext(context.Background(), o) }
[ "func", "(", "g", "*", "GcsFS", ")", "NewReader", "(", "o", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "return", "g", ".", "NewReaderWithContext", "(", "context", ".", "Background", "(", ")", ",", "o", ")", "\n", "}" ]
// NewReader create GCS file reader.
[ "NewReader", "create", "GCS", "file", "reader", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/store.go#L216-L218
141,231
lytics/cloudstorage
google/store.go
NewReaderWithContext
func (g *GcsFS) NewReaderWithContext(ctx context.Context, o string) (io.ReadCloser, error) { rc, err := g.gcsb().Object(o).NewReader(ctx) if err == storage.ErrObjectNotExist { return rc, cloudstorage.ErrObjectNotFound } return rc, err }
go
func (g *GcsFS) NewReaderWithContext(ctx context.Context, o string) (io.ReadCloser, error) { rc, err := g.gcsb().Object(o).NewReader(ctx) if err == storage.ErrObjectNotExist { return rc, cloudstorage.ErrObjectNotFound } return rc, err }
[ "func", "(", "g", "*", "GcsFS", ")", "NewReaderWithContext", "(", "ctx", "context", ".", "Context", ",", "o", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "rc", ",", "err", ":=", "g", ".", "gcsb", "(", ")", ".", "Object", ...
// NewReaderWithContext create new GCS File reader with context.
[ "NewReaderWithContext", "create", "new", "GCS", "File", "reader", "with", "context", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/store.go#L221-L227
141,232
lytics/cloudstorage
google/store.go
NewWriter
func (g *GcsFS) NewWriter(o string, metadata map[string]string) (io.WriteCloser, error) { return g.NewWriterWithContext(context.Background(), o, metadata) }
go
func (g *GcsFS) NewWriter(o string, metadata map[string]string) (io.WriteCloser, error) { return g.NewWriterWithContext(context.Background(), o, metadata) }
[ "func", "(", "g", "*", "GcsFS", ")", "NewWriter", "(", "o", "string", ",", "metadata", "map", "[", "string", "]", "string", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "return", "g", ".", "NewWriterWithContext", "(", "context", ".", "...
// NewWriter create GCS Object Writer.
[ "NewWriter", "create", "GCS", "Object", "Writer", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/store.go#L230-L232
141,233
lytics/cloudstorage
google/storeutils/get.go
GetObject
func GetObject(gc *storage.Client, bucket, name string) (*bytes.Buffer, error) { rc, err := gc.Bucket(bucket).Object(name).NewReader(context.Background()) if err != nil { if err == storage.ErrObjectNotExist { return nil, cloudstorage.ErrObjectNotFound } return nil, err } by, err := ioutil.ReadAll(rc) if ...
go
func GetObject(gc *storage.Client, bucket, name string) (*bytes.Buffer, error) { rc, err := gc.Bucket(bucket).Object(name).NewReader(context.Background()) if err != nil { if err == storage.ErrObjectNotExist { return nil, cloudstorage.ErrObjectNotFound } return nil, err } by, err := ioutil.ReadAll(rc) if ...
[ "func", "GetObject", "(", "gc", "*", "storage", ".", "Client", ",", "bucket", ",", "name", "string", ")", "(", "*", "bytes", ".", "Buffer", ",", "error", ")", "{", "rc", ",", "err", ":=", "gc", ".", "Bucket", "(", "bucket", ")", ".", "Object", "(...
// GetObject Gets a single object's bytes based on bucket and name parameters
[ "GetObject", "Gets", "a", "single", "object", "s", "bytes", "based", "on", "bucket", "and", "name", "parameters" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/storeutils/get.go#L14-L28
141,234
lytics/cloudstorage
google/apistore.go
NewAPIStore
func NewAPIStore(conf *cloudstorage.Config) (*APIStore, error) { googleClient, err := NewGoogleClient(conf) if err != nil { return nil, err } service, err := storage.New(googleClient.Client()) if err != nil { return nil, err } return &APIStore{service: service, project: conf.Project}, nil }
go
func NewAPIStore(conf *cloudstorage.Config) (*APIStore, error) { googleClient, err := NewGoogleClient(conf) if err != nil { return nil, err } service, err := storage.New(googleClient.Client()) if err != nil { return nil, err } return &APIStore{service: service, project: conf.Project}, nil }
[ "func", "NewAPIStore", "(", "conf", "*", "cloudstorage", ".", "Config", ")", "(", "*", "APIStore", ",", "error", ")", "{", "googleClient", ",", "err", ":=", "NewGoogleClient", "(", "conf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",",...
// NewAPIStore create api store.
[ "NewAPIStore", "create", "api", "store", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/apistore.go#L15-L25
141,235
lytics/cloudstorage
google/apistore.go
BucketExists
func (c *APIStore) BucketExists(name string) bool { b, err := c.service.Buckets.Get(name).Do() if err != nil { return false } return b.Id != "" }
go
func (c *APIStore) BucketExists(name string) bool { b, err := c.service.Buckets.Get(name).Do() if err != nil { return false } return b.Id != "" }
[ "func", "(", "c", "*", "APIStore", ")", "BucketExists", "(", "name", "string", ")", "bool", "{", "b", ",", "err", ":=", "c", ".", "service", ".", "Buckets", ".", "Get", "(", "name", ")", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{",...
// BucketExists checks for the bucket name
[ "BucketExists", "checks", "for", "the", "bucket", "name" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/apistore.go#L28-L35
141,236
lytics/cloudstorage
google/apistore.go
CreateBucket
func (c *APIStore) CreateBucket(name string) error { bucket := &storage.Bucket{Name: name} _, err := c.service.Buckets.Insert(c.project, bucket).Do() return err }
go
func (c *APIStore) CreateBucket(name string) error { bucket := &storage.Bucket{Name: name} _, err := c.service.Buckets.Insert(c.project, bucket).Do() return err }
[ "func", "(", "c", "*", "APIStore", ")", "CreateBucket", "(", "name", "string", ")", "error", "{", "bucket", ":=", "&", "storage", ".", "Bucket", "{", "Name", ":", "name", "}", "\n", "_", ",", "err", ":=", "c", ".", "service", ".", "Buckets", ".", ...
// CreateBucket creates a new bucket in GCS
[ "CreateBucket", "creates", "a", "new", "bucket", "in", "GCS" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/apistore.go#L38-L42
141,237
lytics/cloudstorage
google/apistore.go
AddOwner
func (c *APIStore) AddOwner(bucket, object, entity string) error { ac := &storage.ObjectAccessControl{Entity: entity, Role: "OWNER"} _, err := c.service.ObjectAccessControls.Insert(bucket, object, ac).Do() return err }
go
func (c *APIStore) AddOwner(bucket, object, entity string) error { ac := &storage.ObjectAccessControl{Entity: entity, Role: "OWNER"} _, err := c.service.ObjectAccessControls.Insert(bucket, object, ac).Do() return err }
[ "func", "(", "c", "*", "APIStore", ")", "AddOwner", "(", "bucket", ",", "object", ",", "entity", "string", ")", "error", "{", "ac", ":=", "&", "storage", ".", "ObjectAccessControl", "{", "Entity", ":", "entity", ",", "Role", ":", "\"", "\"", "}", "\n...
// AddOwner adds entity as a owner of the object
[ "AddOwner", "adds", "entity", "as", "a", "owner", "of", "the", "object" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/apistore.go#L45-L49
141,238
lytics/cloudstorage
localfs/store.go
NewLocalStore
func NewLocalStore(storepath, cachepath string) (*LocalStore, error) { if storepath == "" { return nil, fmt.Errorf("storepath=%q cannot be empty", storepath) } if storepath == cachepath { return nil, fmt.Errorf("storepath=%q cannot be the same as cachepath=%q", storepath, cachepath) } pathCleaned := strings...
go
func NewLocalStore(storepath, cachepath string) (*LocalStore, error) { if storepath == "" { return nil, fmt.Errorf("storepath=%q cannot be empty", storepath) } if storepath == cachepath { return nil, fmt.Errorf("storepath=%q cannot be the same as cachepath=%q", storepath, cachepath) } pathCleaned := strings...
[ "func", "NewLocalStore", "(", "storepath", ",", "cachepath", "string", ")", "(", "*", "LocalStore", ",", "error", ")", "{", "if", "storepath", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "storepath", ")", ...
// NewLocalStore create local store from storage path on local filesystem, and cachepath.
[ "NewLocalStore", "create", "local", "store", "from", "storage", "path", "on", "local", "filesystem", "and", "cachepath", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/localfs/store.go#L55-L86
141,239
lytics/cloudstorage
localfs/store.go
NewObject
func (l *LocalStore) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := l.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } of := path.Join(l.storepath, objectnam...
go
func (l *LocalStore) NewObject(objectname string) (cloudstorage.Object, error) { obj, err := l.Get(context.Background(), objectname) if err != nil && err != cloudstorage.ErrObjectNotFound { return nil, err } else if obj != nil { return nil, cloudstorage.ErrObjectExists } of := path.Join(l.storepath, objectnam...
[ "func", "(", "l", "*", "LocalStore", ")", "NewObject", "(", "objectname", "string", ")", "(", "cloudstorage", ".", "Object", ",", "error", ")", "{", "obj", ",", "err", ":=", "l", ".", "Get", "(", "context", ".", "Background", "(", ")", ",", "objectna...
// NewObject create new object of given name.
[ "NewObject", "create", "new", "object", "of", "given", "name", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/localfs/store.go#L97-L118
141,240
lytics/cloudstorage
localfs/store.go
List
func (l *LocalStore) List(ctx context.Context, query cloudstorage.Query) (*cloudstorage.ObjectsResponse, error) { resp := cloudstorage.NewObjectsResponse() objects := make(map[string]*object) metadatas := make(map[string]map[string]string) spath := path.Join(l.storepath, query.Prefix) if !cloudstorage.Exists(spa...
go
func (l *LocalStore) List(ctx context.Context, query cloudstorage.Query) (*cloudstorage.ObjectsResponse, error) { resp := cloudstorage.NewObjectsResponse() objects := make(map[string]*object) metadatas := make(map[string]map[string]string) spath := path.Join(l.storepath, query.Prefix) if !cloudstorage.Exists(spa...
[ "func", "(", "l", "*", "LocalStore", ")", "List", "(", "ctx", "context", ".", "Context", ",", "query", "cloudstorage", ".", "Query", ")", "(", "*", "cloudstorage", ".", "ObjectsResponse", ",", "error", ")", "{", "resp", ":=", "cloudstorage", ".", "NewObj...
// List objects at Query location.
[ "List", "objects", "at", "Query", "location", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/localfs/store.go#L121-L181
141,241
lytics/cloudstorage
localfs/store.go
Objects
func (l *LocalStore) Objects(ctx context.Context, csq cloudstorage.Query) (cloudstorage.ObjectIterator, error) { resp, err := l.List(ctx, csq) if err != nil { return nil, err } return &objectIterator{objects: resp.Objects}, nil }
go
func (l *LocalStore) Objects(ctx context.Context, csq cloudstorage.Query) (cloudstorage.ObjectIterator, error) { resp, err := l.List(ctx, csq) if err != nil { return nil, err } return &objectIterator{objects: resp.Objects}, nil }
[ "func", "(", "l", "*", "LocalStore", ")", "Objects", "(", "ctx", "context", ".", "Context", ",", "csq", "cloudstorage", ".", "Query", ")", "(", "cloudstorage", ".", "ObjectIterator", ",", "error", ")", "{", "resp", ",", "err", ":=", "l", ".", "List", ...
// Objects returns an iterator over the objects in the local folder that match the Query q. // If q is nil, no filtering is done.
[ "Objects", "returns", "an", "iterator", "over", "the", "objects", "in", "the", "local", "folder", "that", "match", "the", "Query", "q", ".", "If", "q", "is", "nil", "no", "filtering", "is", "done", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/localfs/store.go#L185-L191
141,242
lytics/cloudstorage
localfs/store.go
Folders
func (l *LocalStore) Folders(ctx context.Context, csq cloudstorage.Query) ([]string, error) { spath := path.Join(l.storepath, csq.Prefix) if !cloudstorage.Exists(spath) { return nil, fmt.Errorf("That folder %q does not exist", spath) } select { case <-ctx.Done(): return nil, ctx.Err() default: } folders :=...
go
func (l *LocalStore) Folders(ctx context.Context, csq cloudstorage.Query) ([]string, error) { spath := path.Join(l.storepath, csq.Prefix) if !cloudstorage.Exists(spath) { return nil, fmt.Errorf("That folder %q does not exist", spath) } select { case <-ctx.Done(): return nil, ctx.Err() default: } folders :=...
[ "func", "(", "l", "*", "LocalStore", ")", "Folders", "(", "ctx", "context", ".", "Context", ",", "csq", "cloudstorage", ".", "Query", ")", "(", "[", "]", "string", ",", "error", ")", "{", "spath", ":=", "path", ".", "Join", "(", "l", ".", "storepat...
// Folders list of folders for given path query.
[ "Folders", "list", "of", "folders", "for", "given", "path", "query", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/localfs/store.go#L194-L213
141,243
lytics/cloudstorage
localfs/store.go
NewReader
func (l *LocalStore) NewReader(o string) (io.ReadCloser, error) { return l.NewReaderWithContext(context.Background(), o) }
go
func (l *LocalStore) NewReader(o string) (io.ReadCloser, error) { return l.NewReaderWithContext(context.Background(), o) }
[ "func", "(", "l", "*", "LocalStore", ")", "NewReader", "(", "o", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "return", "l", ".", "NewReaderWithContext", "(", "context", ".", "Background", "(", ")", ",", "o", ")", "\n", "}" ]
// NewReader create local file-system store reader.
[ "NewReader", "create", "local", "file", "-", "system", "store", "reader", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/localfs/store.go#L216-L218
141,244
lytics/cloudstorage
localfs/store.go
Delete
func (l *LocalStore) Delete(ctx context.Context, obj string) error { fo := path.Join(l.storepath, obj) os.Remove(fo) mf := fo + ".metadata" if cloudstorage.Exists(mf) { os.Remove(mf) } return nil }
go
func (l *LocalStore) Delete(ctx context.Context, obj string) error { fo := path.Join(l.storepath, obj) os.Remove(fo) mf := fo + ".metadata" if cloudstorage.Exists(mf) { os.Remove(mf) } return nil }
[ "func", "(", "l", "*", "LocalStore", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "obj", "string", ")", "error", "{", "fo", ":=", "path", ".", "Join", "(", "l", ".", "storepath", ",", "obj", ")", "\n", "os", ".", "Remove", "(", "fo"...
// Delete the object from underlying store.
[ "Delete", "the", "object", "from", "underlying", "store", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/localfs/store.go#L275-L283
141,245
lytics/cloudstorage
query.go
AddFilter
func (q *Query) AddFilter(f Filter) *Query { if q.Filters == nil { q.Filters = make([]Filter, 0) } q.Filters = append(q.Filters, f) return q }
go
func (q *Query) AddFilter(f Filter) *Query { if q.Filters == nil { q.Filters = make([]Filter, 0) } q.Filters = append(q.Filters, f) return q }
[ "func", "(", "q", "*", "Query", ")", "AddFilter", "(", "f", "Filter", ")", "*", "Query", "{", "if", "q", ".", "Filters", "==", "nil", "{", "q", ".", "Filters", "=", "make", "(", "[", "]", "Filter", ",", "0", ")", "\n", "}", "\n", "q", ".", ...
// AddFilter adds a post prefix query, that can be used to alter results set // from the prefix query.
[ "AddFilter", "adds", "a", "post", "prefix", "query", "that", "can", "be", "used", "to", "alter", "results", "set", "from", "the", "prefix", "query", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/query.go#L44-L50
141,246
lytics/cloudstorage
google/storeutils/transfer.go
NewTransferClient
func NewTransferClient(client *http.Client) (*Transferer, error) { st, err := storagetransfer.New(client) if err != nil { return nil, err } return &Transferer{storagetransfer.NewTransferJobsService(st)}, nil }
go
func NewTransferClient(client *http.Client) (*Transferer, error) { st, err := storagetransfer.New(client) if err != nil { return nil, err } return &Transferer{storagetransfer.NewTransferJobsService(st)}, nil }
[ "func", "NewTransferClient", "(", "client", "*", "http", ".", "Client", ")", "(", "*", "Transferer", ",", "error", ")", "{", "st", ",", "err", ":=", "storagetransfer", ".", "New", "(", "client", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ni...
// NewTransferClient creates a new Transferer using an authed http client
[ "NewTransferClient", "creates", "a", "new", "Transferer", "using", "an", "authed", "http", "client" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/storeutils/transfer.go#L36-L43
141,247
lytics/cloudstorage
google/storeutils/transfer.go
List
func (t *Transferer) List(project string, statuses ...Status) ([]*storagetransfer.TransferJob, error) { var jobs []*storagetransfer.TransferJob var token string body, err := json.Marshal(struct { ProjectID string `json:"project_id"` JobStatuses []Status `json:"job_statuses,omitempty"` }{ ProjectID: pro...
go
func (t *Transferer) List(project string, statuses ...Status) ([]*storagetransfer.TransferJob, error) { var jobs []*storagetransfer.TransferJob var token string body, err := json.Marshal(struct { ProjectID string `json:"project_id"` JobStatuses []Status `json:"job_statuses,omitempty"` }{ ProjectID: pro...
[ "func", "(", "t", "*", "Transferer", ")", "List", "(", "project", "string", ",", "statuses", "...", "Status", ")", "(", "[", "]", "*", "storagetransfer", ".", "TransferJob", ",", "error", ")", "{", "var", "jobs", "[", "]", "*", "storagetransfer", ".", ...
// List returns all of the transferJobs under a specific project. If the variadic argument "statuses" // is provided, only jobs with the listed statuses are returned
[ "List", "returns", "all", "of", "the", "transferJobs", "under", "a", "specific", "project", ".", "If", "the", "variadic", "argument", "statuses", "is", "provided", "only", "jobs", "with", "the", "listed", "statuses", "are", "returned" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/storeutils/transfer.go#L47-L84
141,248
lytics/cloudstorage
google/storeutils/transfer.go
GetJob
func (t *Transferer) GetJob(project, job string) (*storagetransfer.TransferJob, error) { resp, err := t.svc.Get(job).ProjectId(project).Do() if err != nil { return nil, err } return resp, nil }
go
func (t *Transferer) GetJob(project, job string) (*storagetransfer.TransferJob, error) { resp, err := t.svc.Get(job).ProjectId(project).Do() if err != nil { return nil, err } return resp, nil }
[ "func", "(", "t", "*", "Transferer", ")", "GetJob", "(", "project", ",", "job", "string", ")", "(", "*", "storagetransfer", ".", "TransferJob", ",", "error", ")", "{", "resp", ",", "err", ":=", "t", ".", "svc", ".", "Get", "(", "job", ")", ".", "...
// GetJob returns the transferJob with the specified project and job ID
[ "GetJob", "returns", "the", "transferJob", "with", "the", "specified", "project", "and", "job", "ID" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/storeutils/transfer.go#L87-L93
141,249
lytics/cloudstorage
google/storeutils/transfer.go
oneTimeJobSchedule
func oneTimeJobSchedule(ts time.Time) *storagetransfer.Schedule { date := toDate(ts) return &storagetransfer.Schedule{ ScheduleEndDate: date, ScheduleStartDate: date, } }
go
func oneTimeJobSchedule(ts time.Time) *storagetransfer.Schedule { date := toDate(ts) return &storagetransfer.Schedule{ ScheduleEndDate: date, ScheduleStartDate: date, } }
[ "func", "oneTimeJobSchedule", "(", "ts", "time", ".", "Time", ")", "*", "storagetransfer", ".", "Schedule", "{", "date", ":=", "toDate", "(", "ts", ")", "\n", "return", "&", "storagetransfer", ".", "Schedule", "{", "ScheduleEndDate", ":", "date", ",", "Sch...
// oneTimeJobSchedule returns a storagetransfer job schedule that will only be executed one
[ "oneTimeJobSchedule", "returns", "a", "storagetransfer", "job", "schedule", "that", "will", "only", "be", "executed", "one" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/storeutils/transfer.go#L117-L123
141,250
lytics/cloudstorage
google/storeutils/transfer.go
toDate
func toDate(ts time.Time) *storagetransfer.Date { return &storagetransfer.Date{ Day: int64(ts.Day()), Month: int64(ts.Month()), Year: int64(ts.Year()), } }
go
func toDate(ts time.Time) *storagetransfer.Date { return &storagetransfer.Date{ Day: int64(ts.Day()), Month: int64(ts.Month()), Year: int64(ts.Year()), } }
[ "func", "toDate", "(", "ts", "time", ".", "Time", ")", "*", "storagetransfer", ".", "Date", "{", "return", "&", "storagetransfer", ".", "Date", "{", "Day", ":", "int64", "(", "ts", ".", "Day", "(", ")", ")", ",", "Month", ":", "int64", "(", "ts", ...
// toDate converts a time into a storagetransfer friendly Date
[ "toDate", "converts", "a", "time", "into", "a", "storagetransfer", "friendly", "Date" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/storeutils/transfer.go#L126-L132
141,251
lytics/cloudstorage
google/storeutils/transfer.go
Job
func (t *TransferConfig) Job() (*storagetransfer.TransferJob, error) { if t.DestBucket == "" || t.Src == nil { return nil, ErrBadConfig } // Google returns an error if more than 20 inclusionary/exclusionary fields are included if len(t.IncludePrefixes) > MaxPrefix || len(t.ExcludePrefixes) > MaxPrefix { return...
go
func (t *TransferConfig) Job() (*storagetransfer.TransferJob, error) { if t.DestBucket == "" || t.Src == nil { return nil, ErrBadConfig } // Google returns an error if more than 20 inclusionary/exclusionary fields are included if len(t.IncludePrefixes) > MaxPrefix || len(t.ExcludePrefixes) > MaxPrefix { return...
[ "func", "(", "t", "*", "TransferConfig", ")", "Job", "(", ")", "(", "*", "storagetransfer", ".", "TransferJob", ",", "error", ")", "{", "if", "t", ".", "DestBucket", "==", "\"", "\"", "||", "t", ".", "Src", "==", "nil", "{", "return", "nil", ",", ...
// Job instantiates a Transfer job from the TransferConfig struct
[ "Job", "instantiates", "a", "Transfer", "job", "from", "the", "TransferConfig", "struct" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/storeutils/transfer.go#L225-L253
141,252
lytics/cloudstorage
csbufio/writer.go
NewWriter
func NewWriter(rc io.WriteCloser) io.WriteCloser { return bufWriteCloser{bufio.NewWriter(rc), rc} }
go
func NewWriter(rc io.WriteCloser) io.WriteCloser { return bufWriteCloser{bufio.NewWriter(rc), rc} }
[ "func", "NewWriter", "(", "rc", "io", ".", "WriteCloser", ")", "io", ".", "WriteCloser", "{", "return", "bufWriteCloser", "{", "bufio", ".", "NewWriter", "(", "rc", ")", ",", "rc", "}", "\n", "}" ]
// NewWriter is a io.WriteCloser.
[ "NewWriter", "is", "a", "io", ".", "WriteCloser", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/csbufio/writer.go#L25-L27
141,253
lytics/cloudstorage
iterator.go
ObjectsAll
func ObjectsAll(iter ObjectIterator) (Objects, error) { objs := make(Objects, 0) for { o, err := iter.Next() if err == iterator.Done { break } else if err != nil { return nil, err } objs = append(objs, o) } return objs, nil }
go
func ObjectsAll(iter ObjectIterator) (Objects, error) { objs := make(Objects, 0) for { o, err := iter.Next() if err == iterator.Done { break } else if err != nil { return nil, err } objs = append(objs, o) } return objs, nil }
[ "func", "ObjectsAll", "(", "iter", "ObjectIterator", ")", "(", "Objects", ",", "error", ")", "{", "objs", ":=", "make", "(", "Objects", ",", "0", ")", "\n", "for", "{", "o", ",", "err", ":=", "iter", ".", "Next", "(", ")", "\n", "if", "err", "=="...
// ObjectsAll get all objects for an iterator.
[ "ObjectsAll", "get", "all", "objects", "for", "an", "iterator", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/iterator.go#L13-L25
141,254
lytics/cloudstorage
iterator.go
ObjectResponseFromIter
func ObjectResponseFromIter(iter ObjectIterator) (*ObjectsResponse, error) { objs, err := ObjectsAll(iter) if err != nil { return nil, err } return &ObjectsResponse{Objects: objs}, nil }
go
func ObjectResponseFromIter(iter ObjectIterator) (*ObjectsResponse, error) { objs, err := ObjectsAll(iter) if err != nil { return nil, err } return &ObjectsResponse{Objects: objs}, nil }
[ "func", "ObjectResponseFromIter", "(", "iter", "ObjectIterator", ")", "(", "*", "ObjectsResponse", ",", "error", ")", "{", "objs", ",", "err", ":=", "ObjectsAll", "(", "iter", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// ObjectResponseFromIter get all objects for an iterator.
[ "ObjectResponseFromIter", "get", "all", "objects", "for", "an", "iterator", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/iterator.go#L28-L34
141,255
lytics/cloudstorage
iterator.go
NewObjectPageIterator
func NewObjectPageIterator(ctx context.Context, s Store, q Query) ObjectIterator { cancelCtx, cancel := context.WithCancel(ctx) return &ObjectPageIterator{ s: s, ctx: cancelCtx, cancel: cancel, q: q, } }
go
func NewObjectPageIterator(ctx context.Context, s Store, q Query) ObjectIterator { cancelCtx, cancel := context.WithCancel(ctx) return &ObjectPageIterator{ s: s, ctx: cancelCtx, cancel: cancel, q: q, } }
[ "func", "NewObjectPageIterator", "(", "ctx", "context", ".", "Context", ",", "s", "Store", ",", "q", "Query", ")", "ObjectIterator", "{", "cancelCtx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "return", "&", "ObjectPageIterato...
// NewObjectPageIterator create an iterator that wraps the store List interface.
[ "NewObjectPageIterator", "create", "an", "iterator", "that", "wraps", "the", "store", "List", "interface", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/iterator.go#L48-L57
141,256
lytics/cloudstorage
store.go
Copy
func Copy(ctx context.Context, s Store, src, des Object) error { // for Providers that offer fast path, and use the backend copier if src.StorageSource() == des.StorageSource() { if cp, ok := s.(StoreCopy); ok { return cp.Copy(ctx, src, des) } } // Slow path, open an io.Reader from the source and copy it to...
go
func Copy(ctx context.Context, s Store, src, des Object) error { // for Providers that offer fast path, and use the backend copier if src.StorageSource() == des.StorageSource() { if cp, ok := s.(StoreCopy); ok { return cp.Copy(ctx, src, des) } } // Slow path, open an io.Reader from the source and copy it to...
[ "func", "Copy", "(", "ctx", "context", ".", "Context", ",", "s", "Store", ",", "src", ",", "des", "Object", ")", "error", "{", "// for Providers that offer fast path, and use the backend copier", "if", "src", ".", "StorageSource", "(", ")", "==", "des", ".", "...
// Copy source to destination.
[ "Copy", "source", "to", "destination", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/store.go#L251-L283
141,257
lytics/cloudstorage
store.go
Move
func Move(ctx context.Context, s Store, src, des Object) error { // take the fast path, and use the store provided mover if available if src.StorageSource() == des.StorageSource() { if sm, ok := s.(StoreMove); ok { return sm.Move(ctx, src, des) } } if err := Copy(ctx, s, src, des); err != nil { // use Copy(...
go
func Move(ctx context.Context, s Store, src, des Object) error { // take the fast path, and use the store provided mover if available if src.StorageSource() == des.StorageSource() { if sm, ok := s.(StoreMove); ok { return sm.Move(ctx, src, des) } } if err := Copy(ctx, s, src, des); err != nil { // use Copy(...
[ "func", "Move", "(", "ctx", "context", ".", "Context", ",", "s", "Store", ",", "src", ",", "des", "Object", ")", "error", "{", "// take the fast path, and use the store provided mover if available", "if", "src", ".", "StorageSource", "(", ")", "==", "des", ".", ...
// Move source object to destination.
[ "Move", "source", "object", "to", "destination", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/store.go#L286-L303
141,258
lytics/cloudstorage
store.go
Validate
func (j *JwtConf) Validate() error { if j.PrivateKeyDeprecated != "" { j.PrivateKey = j.PrivateKeyDeprecated j.PrivateKeyDeprecated = "" } j.fixKey() if j.KeyTypeDeprecated != "" { j.Type = j.KeyTypeDeprecated j.KeyTypeDeprecated = "" } _, err := j.KeyBytes() if err != nil { return fmt.Errorf("Invalid ...
go
func (j *JwtConf) Validate() error { if j.PrivateKeyDeprecated != "" { j.PrivateKey = j.PrivateKeyDeprecated j.PrivateKeyDeprecated = "" } j.fixKey() if j.KeyTypeDeprecated != "" { j.Type = j.KeyTypeDeprecated j.KeyTypeDeprecated = "" } _, err := j.KeyBytes() if err != nil { return fmt.Errorf("Invalid ...
[ "func", "(", "j", "*", "JwtConf", ")", "Validate", "(", ")", "error", "{", "if", "j", ".", "PrivateKeyDeprecated", "!=", "\"", "\"", "{", "j", ".", "PrivateKey", "=", "j", ".", "PrivateKeyDeprecated", "\n", "j", ".", "PrivateKeyDeprecated", "=", "\"", ...
// Validate that this is a valid jwt conf set of tokens
[ "Validate", "that", "this", "is", "a", "valid", "jwt", "conf", "set", "of", "tokens" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/store.go#L315-L330
141,259
lytics/cloudstorage
file_helper.go
EnsureContextType
func EnsureContextType(o string, md map[string]string) string { ctype, ok := md[ContentTypeKey] if !ok { ext := filepath.Ext(o) if ctype == "" { ctype = mime.TypeByExtension(ext) if ctype == "" { ctype = "application/octet-stream" } } md[ContentTypeKey] = ctype } return ctype }
go
func EnsureContextType(o string, md map[string]string) string { ctype, ok := md[ContentTypeKey] if !ok { ext := filepath.Ext(o) if ctype == "" { ctype = mime.TypeByExtension(ext) if ctype == "" { ctype = "application/octet-stream" } } md[ContentTypeKey] = ctype } return ctype }
[ "func", "EnsureContextType", "(", "o", "string", ",", "md", "map", "[", "string", "]", "string", ")", "string", "{", "ctype", ",", "ok", ":=", "md", "[", "ContentTypeKey", "]", "\n", "if", "!", "ok", "{", "ext", ":=", "filepath", ".", "Ext", "(", "...
// EnsureContextType read Type of metadata
[ "EnsureContextType", "read", "Type", "of", "metadata" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/file_helper.go#L52-L65
141,260
lytics/cloudstorage
file_helper.go
CachePathObj
func CachePathObj(cachepath, oname, storeid string) string { obase := path.Base(oname) opath := path.Dir(oname) ext := path.Ext(oname) ext2 := fmt.Sprintf("%s.%s%s", ext, storeid, StoreCacheFileExt) var obase2 string if ext == "" { obase2 = obase + ext2 } else { obase2 = strings.Replace(obase, ext, ext2, 1) ...
go
func CachePathObj(cachepath, oname, storeid string) string { obase := path.Base(oname) opath := path.Dir(oname) ext := path.Ext(oname) ext2 := fmt.Sprintf("%s.%s%s", ext, storeid, StoreCacheFileExt) var obase2 string if ext == "" { obase2 = obase + ext2 } else { obase2 = strings.Replace(obase, ext, ext2, 1) ...
[ "func", "CachePathObj", "(", "cachepath", ",", "oname", ",", "storeid", "string", ")", "string", "{", "obase", ":=", "path", ".", "Base", "(", "oname", ")", "\n", "opath", ":=", "path", ".", "Dir", "(", "oname", ")", "\n", "ext", ":=", "path", ".", ...
// CachePathObj check the cache path.
[ "CachePathObj", "check", "the", "cache", "path", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/file_helper.go#L76-L88
141,261
lytics/cloudstorage
file_helper.go
EnsureDir
func EnsureDir(filename string) error { fdir := path.Dir(filename) if fdir != "" && fdir != filename { d, err := os.Stat(fdir) if err == nil { if !d.IsDir() { return fmt.Errorf("filename's dir exists but isn't' a directory: filename:%v dir:%v", filename, fdir) } } else if os.IsNotExist(err) { err :...
go
func EnsureDir(filename string) error { fdir := path.Dir(filename) if fdir != "" && fdir != filename { d, err := os.Stat(fdir) if err == nil { if !d.IsDir() { return fmt.Errorf("filename's dir exists but isn't' a directory: filename:%v dir:%v", filename, fdir) } } else if os.IsNotExist(err) { err :...
[ "func", "EnsureDir", "(", "filename", "string", ")", "error", "{", "fdir", ":=", "path", ".", "Dir", "(", "filename", ")", "\n", "if", "fdir", "!=", "\"", "\"", "&&", "fdir", "!=", "filename", "{", "d", ",", "err", ":=", "os", ".", "Stat", "(", "...
// EnsureDir ensure directory exists
[ "EnsureDir", "ensure", "directory", "exists" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/file_helper.go#L91-L107
141,262
lytics/cloudstorage
azure/store.go
Get
func (f *FS) Get(ctx context.Context, objectpath string) (cloudstorage.Object, error) { obj, err := f.getObject(ctx, objectpath) if err != nil { return nil, err } else if obj == nil { return nil, cloudstorage.ErrObjectNotFound } return obj, nil }
go
func (f *FS) Get(ctx context.Context, objectpath string) (cloudstorage.Object, error) { obj, err := f.getObject(ctx, objectpath) if err != nil { return nil, err } else if obj == nil { return nil, cloudstorage.ErrObjectNotFound } return obj, nil }
[ "func", "(", "f", "*", "FS", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "objectpath", "string", ")", "(", "cloudstorage", ".", "Object", ",", "error", ")", "{", "obj", ",", "err", ":=", "f", ".", "getObject", "(", "ctx", ",", "objectpa...
// Get a single File Object
[ "Get", "a", "single", "File", "Object" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/azure/store.go#L180-L190
141,263
lytics/cloudstorage
azure/store.go
newAzureWriteCloser
func newAzureWriteCloser(ctx context.Context, f *FS, obj *object) io.WriteCloser { pr, pw := io.Pipe() bw := bufio.NewWriter(pw) g, _ := errgroup.WithContext(ctx) g.Go(func() error { // Upload the file to azure. // Do a multipart upload err := f.uploadMultiPart(obj, pr) if err != nil { gou.Warnf("could...
go
func newAzureWriteCloser(ctx context.Context, f *FS, obj *object) io.WriteCloser { pr, pw := io.Pipe() bw := bufio.NewWriter(pw) g, _ := errgroup.WithContext(ctx) g.Go(func() error { // Upload the file to azure. // Do a multipart upload err := f.uploadMultiPart(obj, pr) if err != nil { gou.Warnf("could...
[ "func", "newAzureWriteCloser", "(", "ctx", "context", ".", "Context", ",", "f", "*", "FS", ",", "obj", "*", "object", ")", "io", ".", "WriteCloser", "{", "pr", ",", "pw", ":=", "io", ".", "Pipe", "(", ")", "\n", "bw", ":=", "bufio", ".", "NewWriter...
// azureWriteCloser is a io.WriteCloser that manages the azure connection pipe and when Close is called // it blocks until all data is flushed to azure via a background go routine call to uploadMultiPart.
[ "azureWriteCloser", "is", "a", "io", ".", "WriteCloser", "that", "manages", "the", "azure", "connection", "pipe", "and", "when", "Close", "is", "called", "it", "blocks", "until", "all", "data", "is", "flushed", "to", "azure", "via", "a", "background", "go", ...
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/azure/store.go#L402-L422
141,264
lytics/cloudstorage
azure/store.go
Write
func (bc azureWriteCloser) Write(p []byte) (nn int, err error) { return bc.wc.Write(p) }
go
func (bc azureWriteCloser) Write(p []byte) (nn int, err error) { return bc.wc.Write(p) }
[ "func", "(", "bc", "azureWriteCloser", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "nn", "int", ",", "err", "error", ")", "{", "return", "bc", ".", "wc", ".", "Write", "(", "p", ")", "\n", "}" ]
// Write writes data to our write buffer, which writes to the backing io pipe. // If an error is encountered while writting we may not see it here, my guess is // we wouldn't see it until someone calls close and the error is returned from the // error group.
[ "Write", "writes", "data", "to", "our", "write", "buffer", "which", "writes", "to", "the", "backing", "io", "pipe", ".", "If", "an", "error", "is", "encountered", "while", "writting", "we", "may", "not", "see", "it", "here", "my", "guess", "is", "we", ...
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/azure/store.go#L428-L430
141,265
lytics/cloudstorage
azure/store.go
Close
func (bc azureWriteCloser) Close() error { //Flush buffered data to the backing pipe writer. if err := bc.wc.Flush(); err != nil { return err } //Close the pipe writer so that the pipe reader will return EOF, // doing so will cause uploadMultiPart to complete and return. if err := bc.pw.Close(); err != nil { ...
go
func (bc azureWriteCloser) Close() error { //Flush buffered data to the backing pipe writer. if err := bc.wc.Flush(); err != nil { return err } //Close the pipe writer so that the pipe reader will return EOF, // doing so will cause uploadMultiPart to complete and return. if err := bc.pw.Close(); err != nil { ...
[ "func", "(", "bc", "azureWriteCloser", ")", "Close", "(", ")", "error", "{", "//Flush buffered data to the backing pipe writer.", "if", "err", ":=", "bc", ".", "wc", ".", "Flush", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", ...
// Close and block until we flush inflight data to azures
[ "Close", "and", "block", "until", "we", "flush", "inflight", "data", "to", "azures" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/azure/store.go#L433-L448
141,266
lytics/cloudstorage
azure/store.go
uploadMultiPart
func (f *FS) uploadMultiPart(o *object, r io.Reader) error { //chunkSize, err := calcBlockSize(size) // if err != nil { // return err // } var buf = make([]byte, initialChunkSize) var blocks []az.Block var rawID uint64 blob := f.client.GetContainerReference(f.bucket).GetBlobReference(o.name) // TODO: perf...
go
func (f *FS) uploadMultiPart(o *object, r io.Reader) error { //chunkSize, err := calcBlockSize(size) // if err != nil { // return err // } var buf = make([]byte, initialChunkSize) var blocks []az.Block var rawID uint64 blob := f.client.GetContainerReference(f.bucket).GetBlobReference(o.name) // TODO: perf...
[ "func", "(", "f", "*", "FS", ")", "uploadMultiPart", "(", "o", "*", "object", ",", "r", "io", ".", "Reader", ")", "error", "{", "//chunkSize, err := calcBlockSize(size)", "// if err != nil {", "// \treturn err", "// }", "var", "buf", "=", "make", "(", "[", "...
// uploadMultiPart start an upload
[ "uploadMultiPart", "start", "an", "upload" ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/azure/store.go#L464-L523
141,267
lytics/cloudstorage
cachecleaner.go
CleanupCacheFiles
func CleanupCacheFiles(maxage time.Duration, TmpDir string) (err error) { defer func() { if r := recover(); r != nil { gou.Errorf("CleanupOldStoreCacheFiles cleanup old files: panic recovery %v\n %s", r, gou.PrettyStack(12)) } }() cleanoldfiles := func(path string, f os.FileInfo, err error) error { if filep...
go
func CleanupCacheFiles(maxage time.Duration, TmpDir string) (err error) { defer func() { if r := recover(); r != nil { gou.Errorf("CleanupOldStoreCacheFiles cleanup old files: panic recovery %v\n %s", r, gou.PrettyStack(12)) } }() cleanoldfiles := func(path string, f os.FileInfo, err error) error { if filep...
[ "func", "CleanupCacheFiles", "(", "maxage", "time", ".", "Duration", ",", "TmpDir", "string", ")", "(", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "r", ":=", "recover", "(", ")", ";", "r", "!=", "nil", "{", "gou", ".", "Errorf"...
// CleanupCacheFiles cleans up old store cache files // if your process crashes all it's old cache files, the local copies of the cloudfiles, // will left behind. // This function is a convenience func to help clean up those old files. // // I suggest you call this behind a package var sync.Once struct, so its only cal...
[ "CleanupCacheFiles", "cleans", "up", "old", "store", "cache", "files", "if", "your", "process", "crashes", "all", "it", "s", "old", "cache", "files", "the", "local", "copies", "of", "the", "cloudfiles", "will", "left", "behind", ".", "This", "function", "is"...
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/cachecleaner.go#L18-L38
141,268
lytics/cloudstorage
google/client.go
BuildGoogleJWTTransporter
func BuildGoogleJWTTransporter(jwtConf *cloudstorage.JwtConf) (GoogleOAuthClient, error) { key, err := jwtConf.KeyBytes() if err != nil { return nil, err } conf := &jwt.Config{ Email: jwtConf.ClientEmail, PrivateKey: key, Scopes: jwtConf.Scopes, TokenURL: googleOauth2.JWTTokenURL, } client ...
go
func BuildGoogleJWTTransporter(jwtConf *cloudstorage.JwtConf) (GoogleOAuthClient, error) { key, err := jwtConf.KeyBytes() if err != nil { return nil, err } conf := &jwt.Config{ Email: jwtConf.ClientEmail, PrivateKey: key, Scopes: jwtConf.Scopes, TokenURL: googleOauth2.JWTTokenURL, } client ...
[ "func", "BuildGoogleJWTTransporter", "(", "jwtConf", "*", "cloudstorage", ".", "JwtConf", ")", "(", "GoogleOAuthClient", ",", "error", ")", "{", "key", ",", "err", ":=", "jwtConf", ".", "KeyBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// BuildGoogleJWTTransporter create a GoogleOAuthClient from jwt config.
[ "BuildGoogleJWTTransporter", "create", "a", "GoogleOAuthClient", "from", "jwt", "config", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/client.go#L59-L77
141,269
lytics/cloudstorage
google/client.go
BuildGoogleFileJWTTransporter
func BuildGoogleFileJWTTransporter(keyPath string, scope string) (GoogleOAuthClient, error) { jsonKey, err := ioutil.ReadFile(os.ExpandEnv(keyPath)) if err != nil { return nil, err } conf, err := googleOauth2.JWTConfigFromJSON(jsonKey, scope) if err != nil { return nil, err } client := conf.Client(oauth2.N...
go
func BuildGoogleFileJWTTransporter(keyPath string, scope string) (GoogleOAuthClient, error) { jsonKey, err := ioutil.ReadFile(os.ExpandEnv(keyPath)) if err != nil { return nil, err } conf, err := googleOauth2.JWTConfigFromJSON(jsonKey, scope) if err != nil { return nil, err } client := conf.Client(oauth2.N...
[ "func", "BuildGoogleFileJWTTransporter", "(", "keyPath", "string", ",", "scope", "string", ")", "(", "GoogleOAuthClient", ",", "error", ")", "{", "jsonKey", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "os", ".", "ExpandEnv", "(", "keyPath", ")", ")", ...
// BuildGoogleFileJWTTransporter creates a Google Storage Client using a JWT file for the jwt config.
[ "BuildGoogleFileJWTTransporter", "creates", "a", "Google", "Storage", "Client", "using", "a", "JWT", "file", "for", "the", "jwt", "config", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/client.go#L80-L96
141,270
lytics/cloudstorage
google/client.go
NewGoogleClient
func NewGoogleClient(conf *cloudstorage.Config) (client GoogleOAuthClient, err error) { switch conf.AuthMethod { case AuthGCEDefaultOAuthToken: // This token method uses the default OAuth token with GCS created by tools like gsutils, gcloud, etc... // See github.com/lytics/lio/src/ext_svcs/google/google_transpor...
go
func NewGoogleClient(conf *cloudstorage.Config) (client GoogleOAuthClient, err error) { switch conf.AuthMethod { case AuthGCEDefaultOAuthToken: // This token method uses the default OAuth token with GCS created by tools like gsutils, gcloud, etc... // See github.com/lytics/lio/src/ext_svcs/google/google_transpor...
[ "func", "NewGoogleClient", "(", "conf", "*", "cloudstorage", ".", "Config", ")", "(", "client", "GoogleOAuthClient", ",", "err", "error", ")", "{", "switch", "conf", ".", "AuthMethod", "{", "case", "AuthGCEDefaultOAuthToken", ":", "// This token method uses the defa...
// NewGoogleClient create new Google Storage Client.
[ "NewGoogleClient", "create", "new", "Google", "Storage", "Client", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/google/client.go#L152-L191
141,271
lytics/cloudstorage
registry.go
Register
func Register(storeType string, provider StoreProvider) { registryMu.Lock() defer registryMu.Unlock() if _, ok := storeProviders[storeType]; ok { panic(fmt.Sprintf("Cannot provide duplicate store %q", storeType)) } storeProviders[storeType] = provider }
go
func Register(storeType string, provider StoreProvider) { registryMu.Lock() defer registryMu.Unlock() if _, ok := storeProviders[storeType]; ok { panic(fmt.Sprintf("Cannot provide duplicate store %q", storeType)) } storeProviders[storeType] = provider }
[ "func", "Register", "(", "storeType", "string", ",", "provider", "StoreProvider", ")", "{", "registryMu", ".", "Lock", "(", ")", "\n", "defer", "registryMu", ".", "Unlock", "(", ")", "\n", "if", "_", ",", "ok", ":=", "storeProviders", "[", "storeType", "...
// Register adds a store type provider.
[ "Register", "adds", "a", "store", "type", "provider", "." ]
2045e02a7f7d1a26359afa551e08a9f493cea9fc
https://github.com/lytics/cloudstorage/blob/2045e02a7f7d1a26359afa551e08a9f493cea9fc/registry.go#L19-L26
141,272
timehop/apns
conn.go
Connect
func (c *Conn) Connect() error { // Make sure the existing connection is closed if c.NetConn != nil { c.NetConn.Close() } conn, err := net.Dial("tcp", c.gateway) if err != nil { return err } tlsConn := tls.Client(conn, c.Conf) err = tlsConn.Handshake() if err != nil { return err } c.NetConn = tlsCon...
go
func (c *Conn) Connect() error { // Make sure the existing connection is closed if c.NetConn != nil { c.NetConn.Close() } conn, err := net.Dial("tcp", c.gateway) if err != nil { return err } tlsConn := tls.Client(conn, c.Conf) err = tlsConn.Handshake() if err != nil { return err } c.NetConn = tlsCon...
[ "func", "(", "c", "*", "Conn", ")", "Connect", "(", ")", "error", "{", "// Make sure the existing connection is closed", "if", "c", ".", "NetConn", "!=", "nil", "{", "c", ".", "NetConn", ".", "Close", "(", ")", "\n", "}", "\n\n", "conn", ",", "err", ":...
// Connect actually creates the TLS connection
[ "Connect", "actually", "creates", "the", "TLS", "connection" ]
7dfe710e494f7a058c9a84b0dac547086e419ae9
https://github.com/timehop/apns/blob/7dfe710e494f7a058c9a84b0dac547086e419ae9/conn.go#L57-L76
141,273
timehop/apns
conn.go
Read
func (c *Conn) Read(p []byte) (int, error) { i, err := c.NetConn.Read(p) return i, err }
go
func (c *Conn) Read(p []byte) (int, error) { i, err := c.NetConn.Read(p) return i, err }
[ "func", "(", "c", "*", "Conn", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "i", ",", "err", ":=", "c", ".", "NetConn", ".", "Read", "(", "p", ")", "\n", "return", "i", ",", "err", "\n", "}" ]
// Read reads data from the connection
[ "Read", "reads", "data", "from", "the", "connection" ]
7dfe710e494f7a058c9a84b0dac547086e419ae9
https://github.com/timehop/apns/blob/7dfe710e494f7a058c9a84b0dac547086e419ae9/conn.go#L87-L90
141,274
timehop/apns
conn.go
Write
func (c *Conn) Write(p []byte) (int, error) { return c.NetConn.Write(p) }
go
func (c *Conn) Write(p []byte) (int, error) { return c.NetConn.Write(p) }
[ "func", "(", "c", "*", "Conn", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "c", ".", "NetConn", ".", "Write", "(", "p", ")", "\n", "}" ]
// Write writes data from the connection
[ "Write", "writes", "data", "from", "the", "connection" ]
7dfe710e494f7a058c9a84b0dac547086e419ae9
https://github.com/timehop/apns/blob/7dfe710e494f7a058c9a84b0dac547086e419ae9/conn.go#L93-L95
141,275
timehop/apns
feedback.go
Receive
func (f Feedback) Receive() <-chan FeedbackTuple { fc := make(chan FeedbackTuple) go f.receive(fc) return fc }
go
func (f Feedback) Receive() <-chan FeedbackTuple { fc := make(chan FeedbackTuple) go f.receive(fc) return fc }
[ "func", "(", "f", "Feedback", ")", "Receive", "(", ")", "<-", "chan", "FeedbackTuple", "{", "fc", ":=", "make", "(", "chan", "FeedbackTuple", ")", "\n", "go", "f", ".", "receive", "(", "fc", ")", "\n", "return", "fc", "\n", "}" ]
// Receive returns a read only channel for APNs feedback. The returned channel // will close when there is no more data to be read.
[ "Receive", "returns", "a", "read", "only", "channel", "for", "APNs", "feedback", ".", "The", "returned", "channel", "will", "close", "when", "there", "is", "no", "more", "data", "to", "be", "read", "." ]
7dfe710e494f7a058c9a84b0dac547086e419ae9
https://github.com/timehop/apns/blob/7dfe710e494f7a058c9a84b0dac547086e419ae9/feedback.go#L66-L70
141,276
timehop/apns
badge_number.go
Set
func (b *BadgeNumber) Set(number uint) { b.Number = number b.IsSet = true }
go
func (b *BadgeNumber) Set(number uint) { b.Number = number b.IsSet = true }
[ "func", "(", "b", "*", "BadgeNumber", ")", "Set", "(", "number", "uint", ")", "{", "b", ".", "Number", "=", "number", "\n", "b", ".", "IsSet", "=", "true", "\n", "}" ]
// Set will set the BadgeNumber value to // the number passed in, assuming it's >= 0. // If so, the BadgeNumber will also be marked valid
[ "Set", "will", "set", "the", "BadgeNumber", "value", "to", "the", "number", "passed", "in", "assuming", "it", "s", ">", "=", "0", ".", "If", "so", "the", "BadgeNumber", "will", "also", "be", "marked", "valid" ]
7dfe710e494f7a058c9a84b0dac547086e419ae9
https://github.com/timehop/apns/blob/7dfe710e494f7a058c9a84b0dac547086e419ae9/badge_number.go#L25-L28
141,277
timehop/apns
badge_number.go
UnmarshalJSON
func (b *BadgeNumber) UnmarshalJSON(data []byte) error { err := json.Unmarshal(data, &b.Number) if err != nil { return err } // Since the point of this type is to // allow proper inclusion of 0 for int // types while respecting omitempty, // assume that set==true if there is // a value to unmarshal b.IsSet ...
go
func (b *BadgeNumber) UnmarshalJSON(data []byte) error { err := json.Unmarshal(data, &b.Number) if err != nil { return err } // Since the point of this type is to // allow proper inclusion of 0 for int // types while respecting omitempty, // assume that set==true if there is // a value to unmarshal b.IsSet ...
[ "func", "(", "b", "*", "BadgeNumber", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "b", ".", "Number", ")", "\n", "if", "err", "!=", "nil", "{", "return", "e...
// UnmarshalJSON will take any non-nil value and // set BadgeNumber's numeric value to it. It assumes // that if the unmarshaller gets here, there is a // number to unmarshal and it's valid
[ "UnmarshalJSON", "will", "take", "any", "non", "-", "nil", "value", "and", "set", "BadgeNumber", "s", "numeric", "value", "to", "it", ".", "It", "assumes", "that", "if", "the", "unmarshaller", "gets", "here", "there", "is", "a", "number", "to", "unmarshal"...
7dfe710e494f7a058c9a84b0dac547086e419ae9
https://github.com/timehop/apns/blob/7dfe710e494f7a058c9a84b0dac547086e419ae9/badge_number.go#L40-L53
141,278
go-macaron/binding
errors.go
Add
func (e *Errors) Add(fieldNames []string, classification, message string) { *e = append(*e, Error{ FieldNames: fieldNames, Classification: classification, Message: message, }) }
go
func (e *Errors) Add(fieldNames []string, classification, message string) { *e = append(*e, Error{ FieldNames: fieldNames, Classification: classification, Message: message, }) }
[ "func", "(", "e", "*", "Errors", ")", "Add", "(", "fieldNames", "[", "]", "string", ",", "classification", ",", "message", "string", ")", "{", "*", "e", "=", "append", "(", "*", "e", ",", "Error", "{", "FieldNames", ":", "fieldNames", ",", "Classific...
// Add adds an error associated with the fields indicated // by fieldNames, with the given classification and message.
[ "Add", "adds", "an", "error", "associated", "with", "the", "fields", "indicated", "by", "fieldNames", "with", "the", "given", "classification", "and", "message", "." ]
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/errors.go#L74-L80
141,279
go-macaron/binding
errors.go
Has
func (e *Errors) Has(class string) bool { for _, err := range *e { if err.Kind() == class { return true } } return false }
go
func (e *Errors) Has(class string) bool { for _, err := range *e { if err.Kind() == class { return true } } return false }
[ "func", "(", "e", "*", "Errors", ")", "Has", "(", "class", "string", ")", "bool", "{", "for", "_", ",", "err", ":=", "range", "*", "e", "{", "if", "err", ".", "Kind", "(", ")", "==", "class", "{", "return", "true", "\n", "}", "\n", "}", "\n",...
// Has determines whether an Errors slice has an Error with // a given classification in it; it does not search on messages // or field names.
[ "Has", "determines", "whether", "an", "Errors", "slice", "has", "an", "Error", "with", "a", "given", "classification", "in", "it", ";", "it", "does", "not", "search", "on", "messages", "or", "field", "names", "." ]
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/errors.go#L90-L97
141,280
go-macaron/binding
binding.go
errorHandler
func errorHandler(errs Errors, rw http.ResponseWriter) { if len(errs) > 0 { rw.Header().Set("Content-Type", _JSON_CONTENT_TYPE) if errs.Has(ERR_DESERIALIZATION) { rw.WriteHeader(http.StatusBadRequest) } else if errs.Has(ERR_CONTENT_TYPE) { rw.WriteHeader(http.StatusUnsupportedMediaType) } else { rw.Wr...
go
func errorHandler(errs Errors, rw http.ResponseWriter) { if len(errs) > 0 { rw.Header().Set("Content-Type", _JSON_CONTENT_TYPE) if errs.Has(ERR_DESERIALIZATION) { rw.WriteHeader(http.StatusBadRequest) } else if errs.Has(ERR_CONTENT_TYPE) { rw.WriteHeader(http.StatusUnsupportedMediaType) } else { rw.Wr...
[ "func", "errorHandler", "(", "errs", "Errors", ",", "rw", "http", ".", "ResponseWriter", ")", "{", "if", "len", "(", "errs", ")", ">", "0", "{", "rw", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "_JSON_CONTENT_TYPE", ")", "\n", "if",...
// errorHandler simply counts the number of errors in the // context and, if more than 0, writes a response with an // error code and a JSON payload describing the errors. // The response will have a JSON content-type. // Middleware remaining on the stack will not even see the request // if, by this point, there are an...
[ "errorHandler", "simply", "counts", "the", "number", "of", "errors", "in", "the", "context", "and", "if", "more", "than", "0", "writes", "a", "response", "with", "an", "error", "code", "and", "a", "JSON", "payload", "describing", "the", "errors", ".", "The...
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L81-L95
141,281
go-macaron/binding
binding.go
Bind
func Bind(obj interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { bind(ctx, obj, ifacePtr...) if handler, ok := obj.(ErrorHandler); ok { ctx.Invoke(handler.Error) } else { ctx.Invoke(errorHandler) } } }
go
func Bind(obj interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { bind(ctx, obj, ifacePtr...) if handler, ok := obj.(ErrorHandler); ok { ctx.Invoke(handler.Error) } else { ctx.Invoke(errorHandler) } } }
[ "func", "Bind", "(", "obj", "interface", "{", "}", ",", "ifacePtr", "...", "interface", "{", "}", ")", "macaron", ".", "Handler", "{", "return", "func", "(", "ctx", "*", "macaron", ".", "Context", ")", "{", "bind", "(", "ctx", ",", "obj", ",", "ifa...
// Bind wraps up the functionality of the Form and Json middleware // according to the Content-Type and verb of the request. // A Content-Type is required for POST and PUT requests. // Bind invokes the ErrorHandler middleware to bail out if errors // occurred. If you want to perform your own error handling, use // Form...
[ "Bind", "wraps", "up", "the", "functionality", "of", "the", "Form", "and", "Json", "middleware", "according", "to", "the", "Content", "-", "Type", "and", "verb", "of", "the", "request", ".", "A", "Content", "-", "Type", "is", "required", "for", "POST", "...
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L105-L114
141,282
go-macaron/binding
binding.go
BindIgnErr
func BindIgnErr(obj interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { bind(ctx, obj, ifacePtr...) } }
go
func BindIgnErr(obj interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { bind(ctx, obj, ifacePtr...) } }
[ "func", "BindIgnErr", "(", "obj", "interface", "{", "}", ",", "ifacePtr", "...", "interface", "{", "}", ")", "macaron", ".", "Handler", "{", "return", "func", "(", "ctx", "*", "macaron", ".", "Context", ")", "{", "bind", "(", "ctx", ",", "obj", ",", ...
// BindIgnErr will do the exactly same thing as Bind but without any // error handling, which user has freedom to deal with them. // This allows user take advantages of validation.
[ "BindIgnErr", "will", "do", "the", "exactly", "same", "thing", "as", "Bind", "but", "without", "any", "error", "handling", "which", "user", "has", "freedom", "to", "deal", "with", "them", ".", "This", "allows", "user", "take", "advantages", "of", "validation...
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L119-L123
141,283
go-macaron/binding
binding.go
MultipartForm
func MultipartForm(formStruct interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { var errors Errors ensureNotPointer(formStruct) formStruct := reflect.New(reflect.TypeOf(formStruct)) // This if check is necessary due to https://github.com/martini-contrib/csrf/issues/6 ...
go
func MultipartForm(formStruct interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { var errors Errors ensureNotPointer(formStruct) formStruct := reflect.New(reflect.TypeOf(formStruct)) // This if check is necessary due to https://github.com/martini-contrib/csrf/issues/6 ...
[ "func", "MultipartForm", "(", "formStruct", "interface", "{", "}", ",", "ifacePtr", "...", "interface", "{", "}", ")", "macaron", ".", "Handler", "{", "return", "func", "(", "ctx", "*", "macaron", ".", "Context", ")", "{", "var", "errors", "Errors", "\n"...
// MultipartForm works much like Form, except it can parse multipart forms // and handle file uploads. Like the other deserialization middleware handlers, // you can pass in an interface to make the interface available for injection // into other handlers later.
[ "MultipartForm", "works", "much", "like", "Form", "except", "it", "can", "parse", "multipart", "forms", "and", "handle", "file", "uploads", ".", "Like", "the", "other", "deserialization", "middleware", "handlers", "you", "can", "pass", "in", "an", "interface", ...
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L162-L192
141,284
go-macaron/binding
binding.go
Json
func Json(jsonStruct interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { var errors Errors ensureNotPointer(jsonStruct) jsonStruct := reflect.New(reflect.TypeOf(jsonStruct)) if ctx.Req.Request.Body != nil { defer ctx.Req.Request.Body.Close() err := json.NewDecoder(...
go
func Json(jsonStruct interface{}, ifacePtr ...interface{}) macaron.Handler { return func(ctx *macaron.Context) { var errors Errors ensureNotPointer(jsonStruct) jsonStruct := reflect.New(reflect.TypeOf(jsonStruct)) if ctx.Req.Request.Body != nil { defer ctx.Req.Request.Body.Close() err := json.NewDecoder(...
[ "func", "Json", "(", "jsonStruct", "interface", "{", "}", ",", "ifacePtr", "...", "interface", "{", "}", ")", "macaron", ".", "Handler", "{", "return", "func", "(", "ctx", "*", "macaron", ".", "Context", ")", "{", "var", "errors", "Errors", "\n", "ensu...
// Json is middleware to deserialize a JSON payload from the request // into the struct that is passed in. The resulting struct is then // validated, but no error handling is actually performed here. // An interface pointer can be added as a second argument in order // to map the struct to a specific interface.
[ "Json", "is", "middleware", "to", "deserialize", "a", "JSON", "payload", "from", "the", "request", "into", "the", "struct", "that", "is", "passed", "in", ".", "The", "resulting", "struct", "is", "then", "validated", "but", "no", "error", "handling", "is", ...
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L199-L213
141,285
go-macaron/binding
binding.go
RawValidate
func RawValidate(obj interface{}) Errors { var errs Errors v := reflect.ValueOf(obj) k := v.Kind() if k == reflect.Interface || k == reflect.Ptr { v = v.Elem() k = v.Kind() } if k == reflect.Slice || k == reflect.Array { for i := 0; i < v.Len(); i++ { e := v.Index(i).Interface() errs = validateStruct(...
go
func RawValidate(obj interface{}) Errors { var errs Errors v := reflect.ValueOf(obj) k := v.Kind() if k == reflect.Interface || k == reflect.Ptr { v = v.Elem() k = v.Kind() } if k == reflect.Slice || k == reflect.Array { for i := 0; i < v.Len(); i++ { e := v.Index(i).Interface() errs = validateStruct(...
[ "func", "RawValidate", "(", "obj", "interface", "{", "}", ")", "Errors", "{", "var", "errs", "Errors", "\n", "v", ":=", "reflect", ".", "ValueOf", "(", "obj", ")", "\n", "k", ":=", "v", ".", "Kind", "(", ")", "\n", "if", "k", "==", "reflect", "."...
// RawValidate is same as Validate but does not require a HTTP context, // and can be used independently just for validation. // This function does not support Validator interface.
[ "RawValidate", "is", "same", "as", "Validate", "but", "does", "not", "require", "a", "HTTP", "context", "and", "can", "be", "used", "independently", "just", "for", "validation", ".", "This", "function", "does", "not", "support", "Validator", "interface", "." ]
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L218-L235
141,286
go-macaron/binding
binding.go
validateStruct
func validateStruct(errors Errors, obj interface{}) Errors { typ := reflect.TypeOf(obj) val := reflect.ValueOf(obj) if typ.Kind() == reflect.Ptr { typ = typ.Elem() val = val.Elem() } for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) // Allow ignored fields in the struct if field.Tag.Get("for...
go
func validateStruct(errors Errors, obj interface{}) Errors { typ := reflect.TypeOf(obj) val := reflect.ValueOf(obj) if typ.Kind() == reflect.Ptr { typ = typ.Elem() val = val.Elem() } for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) // Allow ignored fields in the struct if field.Tag.Get("for...
[ "func", "validateStruct", "(", "errors", "Errors", ",", "obj", "interface", "{", "}", ")", "Errors", "{", "typ", ":=", "reflect", ".", "TypeOf", "(", "obj", ")", "\n", "val", ":=", "reflect", ".", "ValueOf", "(", "obj", ")", "\n\n", "if", "typ", ".",...
// Performs required field checking on a struct
[ "Performs", "required", "field", "checking", "on", "a", "struct" ]
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L365-L395
141,287
go-macaron/binding
binding.go
validateAndMap
func validateAndMap(obj reflect.Value, ctx *macaron.Context, errors Errors, ifacePtr ...interface{}) { ctx.Invoke(Validate(obj.Interface())) errors = append(errors, getErrors(ctx)...) ctx.Map(errors) ctx.Map(obj.Elem().Interface()) if len(ifacePtr) > 0 { ctx.MapTo(obj.Elem().Interface(), ifacePtr[0]) } }
go
func validateAndMap(obj reflect.Value, ctx *macaron.Context, errors Errors, ifacePtr ...interface{}) { ctx.Invoke(Validate(obj.Interface())) errors = append(errors, getErrors(ctx)...) ctx.Map(errors) ctx.Map(obj.Elem().Interface()) if len(ifacePtr) > 0 { ctx.MapTo(obj.Elem().Interface(), ifacePtr[0]) } }
[ "func", "validateAndMap", "(", "obj", "reflect", ".", "Value", ",", "ctx", "*", "macaron", ".", "Context", ",", "errors", "Errors", ",", "ifacePtr", "...", "interface", "{", "}", ")", "{", "ctx", ".", "Invoke", "(", "Validate", "(", "obj", ".", "Interf...
// Performs validation and combines errors from validation // with errors from deserialization, then maps both the // resulting struct and the errors to the context.
[ "Performs", "validation", "and", "combines", "errors", "from", "validation", "with", "errors", "from", "deserialization", "then", "maps", "both", "the", "resulting", "struct", "and", "the", "errors", "to", "the", "context", "." ]
ac54ee249c27dca7e76fad851a4a04b73bd1b183
https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L728-L736
141,288
chzyer/logex
logex.go
DownLevel
func (l Logger) DownLevel(i int) Logger { return Logger{l.depth + i, l.reqid, l.Logger} }
go
func (l Logger) DownLevel(i int) Logger { return Logger{l.depth + i, l.reqid, l.Logger} }
[ "func", "(", "l", "Logger", ")", "DownLevel", "(", "i", "int", ")", "Logger", "{", "return", "Logger", "{", "l", ".", "depth", "+", "i", ",", "l", ".", "reqid", ",", "l", ".", "Logger", "}", "\n", "}" ]
// decide to show which level's stack
[ "decide", "to", "show", "which", "level", "s", "stack" ]
445be9e134b204a8c920a30fedad02b2f2ab1efd
https://github.com/chzyer/logex/blob/445be9e134b204a8c920a30fedad02b2f2ab1efd/logex.go#L104-L106
141,289
chzyer/logex
logex.go
Pretty
func (l Logger) Pretty(os ...interface{}) { content := "" for i := range os { if ret, err := json.MarshalIndent(os[i], "", "\t"); err == nil { content += string(ret) + "\n" } } l.Output(2, PRETTY+content) }
go
func (l Logger) Pretty(os ...interface{}) { content := "" for i := range os { if ret, err := json.MarshalIndent(os[i], "", "\t"); err == nil { content += string(ret) + "\n" } } l.Output(2, PRETTY+content) }
[ "func", "(", "l", "Logger", ")", "Pretty", "(", "os", "...", "interface", "{", "}", ")", "{", "content", ":=", "\"", "\"", "\n", "for", "i", ":=", "range", "os", "{", "if", "ret", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "os", "[", ...
// output objects to json format
[ "output", "objects", "to", "json", "format" ]
445be9e134b204a8c920a30fedad02b2f2ab1efd
https://github.com/chzyer/logex/blob/445be9e134b204a8c920a30fedad02b2f2ab1efd/logex.go#L109-L117
141,290
chzyer/logex
logex.go
Printf
func (l Logger) Printf(layout string, o ...interface{}) { l.Output(2, sprintf(layout, o)) }
go
func (l Logger) Printf(layout string, o ...interface{}) { l.Output(2, sprintf(layout, o)) }
[ "func", "(", "l", "Logger", ")", "Printf", "(", "layout", "string", ",", "o", "...", "interface", "{", "}", ")", "{", "l", ".", "Output", "(", "2", ",", "sprintf", "(", "layout", ",", "o", ")", ")", "\n", "}" ]
// just print by format
[ "just", "print", "by", "format" ]
445be9e134b204a8c920a30fedad02b2f2ab1efd
https://github.com/chzyer/logex/blob/445be9e134b204a8c920a30fedad02b2f2ab1efd/logex.go#L125-L127
141,291
NebulousLabs/go-upnp
goupnp/ssdp/ssdp.go
SSDPRawSearch
func SSDPRawSearch(httpu *httpu.HTTPUClient, searchTarget string, maxWaitSeconds int, numSends int) ([]*http.Response, error) { return SSDPRawSearchCtx(context.Background(), httpu, searchTarget, maxWaitSeconds, numSends) }
go
func SSDPRawSearch(httpu *httpu.HTTPUClient, searchTarget string, maxWaitSeconds int, numSends int) ([]*http.Response, error) { return SSDPRawSearchCtx(context.Background(), httpu, searchTarget, maxWaitSeconds, numSends) }
[ "func", "SSDPRawSearch", "(", "httpu", "*", "httpu", ".", "HTTPUClient", ",", "searchTarget", "string", ",", "maxWaitSeconds", "int", ",", "numSends", "int", ")", "(", "[", "]", "*", "http", ".", "Response", ",", "error", ")", "{", "return", "SSDPRawSearch...
// SSDPRawSearch is deprecated; use SSDPRawSearchCtx instead
[ "SSDPRawSearch", "is", "deprecated", ";", "use", "SSDPRawSearchCtx", "instead" ]
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/goupnp/ssdp/ssdp.go#L26-L28
141,292
NebulousLabs/go-upnp
upnp.go
IsForwardedTCP
func (d *IGD) IsForwardedTCP(port uint16) (bool, error) { return d.checkForward(port, "TCP") }
go
func (d *IGD) IsForwardedTCP(port uint16) (bool, error) { return d.checkForward(port, "TCP") }
[ "func", "(", "d", "*", "IGD", ")", "IsForwardedTCP", "(", "port", "uint16", ")", "(", "bool", ",", "error", ")", "{", "return", "d", ".", "checkForward", "(", "port", ",", "\"", "\"", ")", "\n", "}" ]
// IsForwardedTCP checks whether a specific TCP port is forwarded to this host
[ "IsForwardedTCP", "checks", "whether", "a", "specific", "TCP", "port", "is", "forwarded", "to", "this", "host" ]
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L61-L63
141,293
NebulousLabs/go-upnp
upnp.go
IsForwardedUDP
func (d *IGD) IsForwardedUDP(port uint16) (bool, error) { return d.checkForward(port, "UDP") }
go
func (d *IGD) IsForwardedUDP(port uint16) (bool, error) { return d.checkForward(port, "UDP") }
[ "func", "(", "d", "*", "IGD", ")", "IsForwardedUDP", "(", "port", "uint16", ")", "(", "bool", ",", "error", ")", "{", "return", "d", ".", "checkForward", "(", "port", ",", "\"", "\"", ")", "\n", "}" ]
// IsForwardedUDP checks whether a specific UDP port is forwarded to this host
[ "IsForwardedUDP", "checks", "whether", "a", "specific", "UDP", "port", "is", "forwarded", "to", "this", "host" ]
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L66-L68
141,294
NebulousLabs/go-upnp
upnp.go
checkForward
func (d *IGD) checkForward(port uint16, proto string) (bool, error) { time.Sleep(time.Millisecond) _, _, enabled, _, _, err := d.client.GetSpecificPortMappingEntry("", port, proto) if err != nil { // 714 "NoSuchEntryInArray" means that there is no such forwarding if strings.Contains(err.Error(), "<errorCode>714...
go
func (d *IGD) checkForward(port uint16, proto string) (bool, error) { time.Sleep(time.Millisecond) _, _, enabled, _, _, err := d.client.GetSpecificPortMappingEntry("", port, proto) if err != nil { // 714 "NoSuchEntryInArray" means that there is no such forwarding if strings.Contains(err.Error(), "<errorCode>714...
[ "func", "(", "d", "*", "IGD", ")", "checkForward", "(", "port", "uint16", ",", "proto", "string", ")", "(", "bool", ",", "error", ")", "{", "time", ".", "Sleep", "(", "time", ".", "Millisecond", ")", "\n", "_", ",", "_", ",", "enabled", ",", "_",...
// checkForward checks whether a specific TCP or UDP port is forwarded to this host
[ "checkForward", "checks", "whether", "a", "specific", "TCP", "or", "UDP", "port", "is", "forwarded", "to", "this", "host" ]
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L71-L84
141,295
NebulousLabs/go-upnp
upnp.go
Forward
func (d *IGD) Forward(port uint16, desc string) error { ip, err := d.getInternalIP() if err != nil { return err } time.Sleep(time.Millisecond) err = d.client.AddPortMapping("", port, "TCP", port, ip, true, desc, 0) if err != nil { return err } time.Sleep(time.Millisecond) return d.client.AddPortMapping("...
go
func (d *IGD) Forward(port uint16, desc string) error { ip, err := d.getInternalIP() if err != nil { return err } time.Sleep(time.Millisecond) err = d.client.AddPortMapping("", port, "TCP", port, ip, true, desc, 0) if err != nil { return err } time.Sleep(time.Millisecond) return d.client.AddPortMapping("...
[ "func", "(", "d", "*", "IGD", ")", "Forward", "(", "port", "uint16", ",", "desc", "string", ")", "error", "{", "ip", ",", "err", ":=", "d", ".", "getInternalIP", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", ...
// Forward forwards the specified port, and adds its description to the // router's port mapping table.
[ "Forward", "forwards", "the", "specified", "port", "and", "adds", "its", "description", "to", "the", "router", "s", "port", "mapping", "table", "." ]
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L88-L102
141,296
NebulousLabs/go-upnp
upnp.go
Clear
func (d *IGD) Clear(port uint16) error { time.Sleep(time.Millisecond) tcpErr := d.client.DeletePortMapping("", port, "TCP") time.Sleep(time.Millisecond) udpErr := d.client.DeletePortMapping("", port, "UDP") // only return an error if both deletions failed if tcpErr != nil && udpErr != nil { return tcpErr } r...
go
func (d *IGD) Clear(port uint16) error { time.Sleep(time.Millisecond) tcpErr := d.client.DeletePortMapping("", port, "TCP") time.Sleep(time.Millisecond) udpErr := d.client.DeletePortMapping("", port, "UDP") // only return an error if both deletions failed if tcpErr != nil && udpErr != nil { return tcpErr } r...
[ "func", "(", "d", "*", "IGD", ")", "Clear", "(", "port", "uint16", ")", "error", "{", "time", ".", "Sleep", "(", "time", ".", "Millisecond", ")", "\n", "tcpErr", ":=", "d", ".", "client", ".", "DeletePortMapping", "(", "\"", "\"", ",", "port", ",",...
// Clear un-forwards a port, removing it from the router's port mapping table.
[ "Clear", "un", "-", "forwards", "a", "port", "removing", "it", "from", "the", "router", "s", "port", "mapping", "table", "." ]
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L105-L116
141,297
NebulousLabs/go-upnp
upnp.go
getInternalIP
func (d *IGD) getInternalIP() (string, error) { host, _, _ := net.SplitHostPort(d.client.GetServiceClient().RootDevice.URLBase.Host) devIP := net.ParseIP(host) if devIP == nil { return "", errors.New("could not determine router's internal IP") } ifaces, err := net.Interfaces() if err != nil { return "", err ...
go
func (d *IGD) getInternalIP() (string, error) { host, _, _ := net.SplitHostPort(d.client.GetServiceClient().RootDevice.URLBase.Host) devIP := net.ParseIP(host) if devIP == nil { return "", errors.New("could not determine router's internal IP") } ifaces, err := net.Interfaces() if err != nil { return "", err ...
[ "func", "(", "d", "*", "IGD", ")", "getInternalIP", "(", ")", "(", "string", ",", "error", ")", "{", "host", ",", "_", ",", "_", ":=", "net", ".", "SplitHostPort", "(", "d", ".", "client", ".", "GetServiceClient", "(", ")", ".", "RootDevice", ".", ...
// getInternalIP returns the user's local IP.
[ "getInternalIP", "returns", "the", "user", "s", "local", "IP", "." ]
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L124-L150
141,298
NebulousLabs/go-upnp
upnp.go
DiscoverCtx
func DiscoverCtx(ctx context.Context) (*IGD, error) { // TODO: if more than one client is found, only return those on the same // subnet as the user? maxTries := 3 sleepTime := time.Millisecond * time.Duration(fastrand.Intn(5000)) for try := 0; try < maxTries; try++ { pppclients, _, _ := internetgateway1.NewWANP...
go
func DiscoverCtx(ctx context.Context) (*IGD, error) { // TODO: if more than one client is found, only return those on the same // subnet as the user? maxTries := 3 sleepTime := time.Millisecond * time.Duration(fastrand.Intn(5000)) for try := 0; try < maxTries; try++ { pppclients, _, _ := internetgateway1.NewWANP...
[ "func", "DiscoverCtx", "(", "ctx", "context", ".", "Context", ")", "(", "*", "IGD", ",", "error", ")", "{", "// TODO: if more than one client is found, only return those on the same", "// subnet as the user?", "maxTries", ":=", "3", "\n", "sleepTime", ":=", "time", "....
// DiscoverCtx scans the local network for routers and returns the first // UPnP-enabled router it encounters. It will try up to 3 times to find a // router, sleeping a random duration between each attempt. This is to // mitigate a race condition with many callers attempting to discover // simultaneously.
[ "DiscoverCtx", "scans", "the", "local", "network", "for", "routers", "and", "returns", "the", "first", "UPnP", "-", "enabled", "router", "it", "encounters", ".", "It", "will", "try", "up", "to", "3", "times", "to", "find", "a", "router", "sleeping", "a", ...
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L162-L184
141,299
NebulousLabs/go-upnp
upnp.go
Load
func Load(rawurl string) (*IGD, error) { loc, err := url.Parse(rawurl) if err != nil { return nil, err } pppclients, _ := internetgateway1.NewWANPPPConnection1ClientsByURL(loc) if len(pppclients) > 0 { return &IGD{pppclients[0]}, nil } ipclients, _ := internetgateway1.NewWANIPConnection1ClientsByURL(loc) if...
go
func Load(rawurl string) (*IGD, error) { loc, err := url.Parse(rawurl) if err != nil { return nil, err } pppclients, _ := internetgateway1.NewWANPPPConnection1ClientsByURL(loc) if len(pppclients) > 0 { return &IGD{pppclients[0]}, nil } ipclients, _ := internetgateway1.NewWANIPConnection1ClientsByURL(loc) if...
[ "func", "Load", "(", "rawurl", "string", ")", "(", "*", "IGD", ",", "error", ")", "{", "loc", ",", "err", ":=", "url", ".", "Parse", "(", "rawurl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "pppclie...
// Load connects to the router service specified by rawurl. This is much // faster than Discover. Generally, Load should only be called with values // returned by the IGD's Location method.
[ "Load", "connects", "to", "the", "router", "service", "specified", "by", "rawurl", ".", "This", "is", "much", "faster", "than", "Discover", ".", "Generally", "Load", "should", "only", "be", "called", "with", "values", "returned", "by", "the", "IGD", "s", "...
b32978b8ccbffe222d6f37a980e795074ac2ba74
https://github.com/NebulousLabs/go-upnp/blob/b32978b8ccbffe222d6f37a980e795074ac2ba74/upnp.go#L189-L203