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
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
4,200
uber-go/dosa
client.go
Remove
func (c *client) Remove(ctx context.Context, entity DomainObject) error { if !c.initialized { return &ErrNotInitialized{} } // lookup registered entity, the registrar will return error if it is not found re, err := c.registrar.Find(entity) if err != nil { return err } // translate entity field values to a map of primary key name/values pairs keyFieldValues := re.KeyFieldValues(entity) err = c.connector.Remove(ctx, re.EntityInfo(), keyFieldValues) return err }
go
func (c *client) Remove(ctx context.Context, entity DomainObject) error { if !c.initialized { return &ErrNotInitialized{} } // lookup registered entity, the registrar will return error if it is not found re, err := c.registrar.Find(entity) if err != nil { return err } // translate entity field values to a map of primary key name/values pairs keyFieldValues := re.KeyFieldValues(entity) err = c.connector.Remove(ctx, re.EntityInfo(), keyFieldValues) return err }
[ "func", "(", "c", "*", "client", ")", "Remove", "(", "ctx", "context", ".", "Context", ",", "entity", "DomainObject", ")", "error", "{", "if", "!", "c", ".", "initialized", "{", "return", "&", "ErrNotInitialized", "{", "}", "\n", "}", "\n\n", "// lookup registered entity, the registrar will return error if it is not found", "re", ",", "err", ":=", "c", ".", "registrar", ".", "Find", "(", "entity", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// translate entity field values to a map of primary key name/values pairs", "keyFieldValues", ":=", "re", ".", "KeyFieldValues", "(", "entity", ")", "\n\n", "err", "=", "c", ".", "connector", ".", "Remove", "(", "ctx", ",", "re", ".", "EntityInfo", "(", ")", ",", "keyFieldValues", ")", "\n", "return", "err", "\n", "}" ]
// Remove deletes an entity by primary key, The entity provided must contain // values for all components of its primary key for the operation to succeed.
[ "Remove", "deletes", "an", "entity", "by", "primary", "key", "The", "entity", "provided", "must", "contain", "values", "for", "all", "components", "of", "its", "primary", "key", "for", "the", "operation", "to", "succeed", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L461-L477
4,201
uber-go/dosa
client.go
RemoveRange
func (c *client) RemoveRange(ctx context.Context, r *RemoveRangeOp) error { if !c.initialized { return &ErrNotInitialized{} } // look up the entity in the registry re, err := c.registrar.Find(r.object) if err != nil { return errors.Wrap(err, "RemoveRange") } // now convert the client range columns to server side column conditions structure columnConditions, err := ConvertConditions(r.conditions, re.table) if err != nil { return errors.Wrap(err, "RemoveRange") } return errors.Wrap(c.connector.RemoveRange(ctx, re.EntityInfo(), columnConditions), "RemoveRange") }
go
func (c *client) RemoveRange(ctx context.Context, r *RemoveRangeOp) error { if !c.initialized { return &ErrNotInitialized{} } // look up the entity in the registry re, err := c.registrar.Find(r.object) if err != nil { return errors.Wrap(err, "RemoveRange") } // now convert the client range columns to server side column conditions structure columnConditions, err := ConvertConditions(r.conditions, re.table) if err != nil { return errors.Wrap(err, "RemoveRange") } return errors.Wrap(c.connector.RemoveRange(ctx, re.EntityInfo(), columnConditions), "RemoveRange") }
[ "func", "(", "c", "*", "client", ")", "RemoveRange", "(", "ctx", "context", ".", "Context", ",", "r", "*", "RemoveRangeOp", ")", "error", "{", "if", "!", "c", ".", "initialized", "{", "return", "&", "ErrNotInitialized", "{", "}", "\n", "}", "\n\n", "// look up the entity in the registry", "re", ",", "err", ":=", "c", ".", "registrar", ".", "Find", "(", "r", ".", "object", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// now convert the client range columns to server side column conditions structure", "columnConditions", ",", "err", ":=", "ConvertConditions", "(", "r", ".", "conditions", ",", "re", ".", "table", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "errors", ".", "Wrap", "(", "c", ".", "connector", ".", "RemoveRange", "(", "ctx", ",", "re", ".", "EntityInfo", "(", ")", ",", "columnConditions", ")", ",", "\"", "\"", ")", "\n", "}" ]
// RemoveRange removes all of the rows that fall within the range specified by the // given RemoveRangeOp.
[ "RemoveRange", "removes", "all", "of", "the", "rows", "that", "fall", "within", "the", "range", "specified", "by", "the", "given", "RemoveRangeOp", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L481-L499
4,202
uber-go/dosa
client.go
Range
func (c *client) Range(ctx context.Context, r *RangeOp) ([]DomainObject, string, error) { if !c.initialized { return nil, "", &ErrNotInitialized{} } // look up the entity in the registry re, err := c.registrar.Find(r.object) if err != nil { return nil, "", errors.Wrap(err, "Range") } // now convert the client range columns to server side column conditions structure columnConditions, err := ConvertConditions(r.conditions, re.table) if err != nil { return nil, "", errors.Wrap(err, "Range") } // convert the fieldsToRead to the server side equivalent fieldsToRead, err := re.ColumnNames(r.fieldsToRead) if err != nil { return nil, "", errors.Wrap(err, "Range") } // call the server side method values, token, err := c.connector.Range(ctx, re.EntityInfo(), columnConditions, fieldsToRead, r.token, r.limit) if err != nil { return nil, "", errors.Wrap(err, "Range") } objectArray := objectsFromValueArray(r.object, values, re, nil) return objectArray, token, nil }
go
func (c *client) Range(ctx context.Context, r *RangeOp) ([]DomainObject, string, error) { if !c.initialized { return nil, "", &ErrNotInitialized{} } // look up the entity in the registry re, err := c.registrar.Find(r.object) if err != nil { return nil, "", errors.Wrap(err, "Range") } // now convert the client range columns to server side column conditions structure columnConditions, err := ConvertConditions(r.conditions, re.table) if err != nil { return nil, "", errors.Wrap(err, "Range") } // convert the fieldsToRead to the server side equivalent fieldsToRead, err := re.ColumnNames(r.fieldsToRead) if err != nil { return nil, "", errors.Wrap(err, "Range") } // call the server side method values, token, err := c.connector.Range(ctx, re.EntityInfo(), columnConditions, fieldsToRead, r.token, r.limit) if err != nil { return nil, "", errors.Wrap(err, "Range") } objectArray := objectsFromValueArray(r.object, values, re, nil) return objectArray, token, nil }
[ "func", "(", "c", "*", "client", ")", "Range", "(", "ctx", "context", ".", "Context", ",", "r", "*", "RangeOp", ")", "(", "[", "]", "DomainObject", ",", "string", ",", "error", ")", "{", "if", "!", "c", ".", "initialized", "{", "return", "nil", ",", "\"", "\"", ",", "&", "ErrNotInitialized", "{", "}", "\n", "}", "\n", "// look up the entity in the registry", "re", ",", "err", ":=", "c", ".", "registrar", ".", "Find", "(", "r", ".", "object", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// now convert the client range columns to server side column conditions structure", "columnConditions", ",", "err", ":=", "ConvertConditions", "(", "r", ".", "conditions", ",", "re", ".", "table", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// convert the fieldsToRead to the server side equivalent", "fieldsToRead", ",", "err", ":=", "re", ".", "ColumnNames", "(", "r", ".", "fieldsToRead", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// call the server side method", "values", ",", "token", ",", "err", ":=", "c", ".", "connector", ".", "Range", "(", "ctx", ",", "re", ".", "EntityInfo", "(", ")", ",", "columnConditions", ",", "fieldsToRead", ",", "r", ".", "token", ",", "r", ".", "limit", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "objectArray", ":=", "objectsFromValueArray", "(", "r", ".", "object", ",", "values", ",", "re", ",", "nil", ")", "\n", "return", "objectArray", ",", "token", ",", "nil", "\n", "}" ]
// Range uses the connector to fetch DOSA entities for a given range.
[ "Range", "uses", "the", "connector", "to", "fetch", "DOSA", "entities", "for", "a", "given", "range", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L502-L532
4,203
uber-go/dosa
client.go
ScanEverything
func (c *client) ScanEverything(ctx context.Context, sop *ScanOp) ([]DomainObject, string, error) { if !c.initialized { return nil, "", &ErrNotInitialized{} } // look up the entity in the registry re, err := c.registrar.Find(sop.object) if err != nil { return nil, "", errors.Wrap(err, "failed to ScanEverything") } // convert the fieldsToRead to the server side equivalent fieldsToRead, err := re.ColumnNames(sop.fieldsToRead) if err != nil { return nil, "", errors.Wrap(err, "failed to ScanEverything") } // call the server side method values, token, err := c.connector.Scan(ctx, re.EntityInfo(), fieldsToRead, sop.token, sop.limit) if err != nil { return nil, "", err } objectArray := objectsFromValueArray(sop.object, values, re, nil) return objectArray, token, nil }
go
func (c *client) ScanEverything(ctx context.Context, sop *ScanOp) ([]DomainObject, string, error) { if !c.initialized { return nil, "", &ErrNotInitialized{} } // look up the entity in the registry re, err := c.registrar.Find(sop.object) if err != nil { return nil, "", errors.Wrap(err, "failed to ScanEverything") } // convert the fieldsToRead to the server side equivalent fieldsToRead, err := re.ColumnNames(sop.fieldsToRead) if err != nil { return nil, "", errors.Wrap(err, "failed to ScanEverything") } // call the server side method values, token, err := c.connector.Scan(ctx, re.EntityInfo(), fieldsToRead, sop.token, sop.limit) if err != nil { return nil, "", err } objectArray := objectsFromValueArray(sop.object, values, re, nil) return objectArray, token, nil }
[ "func", "(", "c", "*", "client", ")", "ScanEverything", "(", "ctx", "context", ".", "Context", ",", "sop", "*", "ScanOp", ")", "(", "[", "]", "DomainObject", ",", "string", ",", "error", ")", "{", "if", "!", "c", ".", "initialized", "{", "return", "nil", ",", "\"", "\"", ",", "&", "ErrNotInitialized", "{", "}", "\n", "}", "\n", "// look up the entity in the registry", "re", ",", "err", ":=", "c", ".", "registrar", ".", "Find", "(", "sop", ".", "object", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "// convert the fieldsToRead to the server side equivalent", "fieldsToRead", ",", "err", ":=", "re", ".", "ColumnNames", "(", "sop", ".", "fieldsToRead", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// call the server side method", "values", ",", "token", ",", "err", ":=", "c", ".", "connector", ".", "Scan", "(", "ctx", ",", "re", ".", "EntityInfo", "(", ")", ",", "fieldsToRead", ",", "sop", ".", "token", ",", "sop", ".", "limit", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "objectArray", ":=", "objectsFromValueArray", "(", "sop", ".", "object", ",", "values", ",", "re", ",", "nil", ")", "\n", "return", "objectArray", ",", "token", ",", "nil", "\n", "}" ]
// ScanEverything uses the connector to fetch all DOSA entities of the given type.
[ "ScanEverything", "uses", "the", "connector", "to", "fetch", "all", "DOSA", "entities", "of", "the", "given", "type", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L570-L592
4,204
uber-go/dosa
client.go
NewAdminClient
func NewAdminClient(conn Connector) AdminClient { return &adminClient{ scope: "default", dirs: []string{"."}, excludes: []string{"_test.go"}, connector: conn, } }
go
func NewAdminClient(conn Connector) AdminClient { return &adminClient{ scope: "default", dirs: []string{"."}, excludes: []string{"_test.go"}, connector: conn, } }
[ "func", "NewAdminClient", "(", "conn", "Connector", ")", "AdminClient", "{", "return", "&", "adminClient", "{", "scope", ":", "\"", "\"", ",", "dirs", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "excludes", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "connector", ":", "conn", ",", "}", "\n", "}" ]
// NewAdminClient returns a new DOSA admin client for the connector provided.
[ "NewAdminClient", "returns", "a", "new", "DOSA", "admin", "client", "for", "the", "connector", "provided", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L606-L613
4,205
uber-go/dosa
client.go
UpsertSchema
func (c *adminClient) UpsertSchema(ctx context.Context, namePrefix string) (*SchemaStatus, error) { defs, err := c.GetSchema() if err != nil { return nil, errors.Wrapf(err, "GetSchema failed") } status, err := c.connector.UpsertSchema(ctx, c.scope, namePrefix, defs) if err != nil { return nil, errors.Wrapf(err, "UpsertSchema failed, directories: %s, excludes: %s, scope: %s", c.dirs, c.excludes, c.scope) } return status, nil }
go
func (c *adminClient) UpsertSchema(ctx context.Context, namePrefix string) (*SchemaStatus, error) { defs, err := c.GetSchema() if err != nil { return nil, errors.Wrapf(err, "GetSchema failed") } status, err := c.connector.UpsertSchema(ctx, c.scope, namePrefix, defs) if err != nil { return nil, errors.Wrapf(err, "UpsertSchema failed, directories: %s, excludes: %s, scope: %s", c.dirs, c.excludes, c.scope) } return status, nil }
[ "func", "(", "c", "*", "adminClient", ")", "UpsertSchema", "(", "ctx", "context", ".", "Context", ",", "namePrefix", "string", ")", "(", "*", "SchemaStatus", ",", "error", ")", "{", "defs", ",", "err", ":=", "c", ".", "GetSchema", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "status", ",", "err", ":=", "c", ".", "connector", ".", "UpsertSchema", "(", "ctx", ",", "c", ".", "scope", ",", "namePrefix", ",", "defs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "c", ".", "dirs", ",", "c", ".", "excludes", ",", "c", ".", "scope", ")", "\n", "}", "\n", "return", "status", ",", "nil", "\n", "}" ]
// UpsertSchema creates or updates the schema for entities in the given // namespace. See CheckSchema for more detail about scope and namePrefix.
[ "UpsertSchema", "creates", "or", "updates", "the", "schema", "for", "entities", "in", "the", "given", "namespace", ".", "See", "CheckSchema", "for", "more", "detail", "about", "scope", "and", "namePrefix", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L668-L678
4,206
uber-go/dosa
client.go
Error
func (ee *EntityErrors) Error() string { var str bytes.Buffer if _, err := io.WriteString(&str, "The following entities had warnings/errors:"); err != nil { // for linting, WriteString will never return error return "could not write errors to output buffer" } for _, err := range ee.warns { str.WriteByte('\n') if _, err := io.WriteString(&str, err.Error()); err != nil { // for linting, WriteString will never return error return "could not write errors to output buffer" } } return str.String() }
go
func (ee *EntityErrors) Error() string { var str bytes.Buffer if _, err := io.WriteString(&str, "The following entities had warnings/errors:"); err != nil { // for linting, WriteString will never return error return "could not write errors to output buffer" } for _, err := range ee.warns { str.WriteByte('\n') if _, err := io.WriteString(&str, err.Error()); err != nil { // for linting, WriteString will never return error return "could not write errors to output buffer" } } return str.String() }
[ "func", "(", "ee", "*", "EntityErrors", ")", "Error", "(", ")", "string", "{", "var", "str", "bytes", ".", "Buffer", "\n", "if", "_", ",", "err", ":=", "io", ".", "WriteString", "(", "&", "str", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "// for linting, WriteString will never return error", "return", "\"", "\"", "\n", "}", "\n", "for", "_", ",", "err", ":=", "range", "ee", ".", "warns", "{", "str", ".", "WriteByte", "(", "'\\n'", ")", "\n", "if", "_", ",", "err", ":=", "io", ".", "WriteString", "(", "&", "str", ",", "err", ".", "Error", "(", ")", ")", ";", "err", "!=", "nil", "{", "// for linting, WriteString will never return error", "return", "\"", "\"", "\n", "}", "\n", "}", "\n", "return", "str", ".", "String", "(", ")", "\n", "}" ]
// Error makes parse errors discernable to end-user.
[ "Error", "makes", "parse", "errors", "discernable", "to", "end", "-", "user", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L727-L741
4,207
uber-go/dosa
client.go
CreateScope
func (c *adminClient) CreateScope(ctx context.Context, md *ScopeMetadata) error { return c.connector.CreateScope(ctx, md) }
go
func (c *adminClient) CreateScope(ctx context.Context, md *ScopeMetadata) error { return c.connector.CreateScope(ctx, md) }
[ "func", "(", "c", "*", "adminClient", ")", "CreateScope", "(", "ctx", "context", ".", "Context", ",", "md", "*", "ScopeMetadata", ")", "error", "{", "return", "c", ".", "connector", ".", "CreateScope", "(", "ctx", ",", "md", ")", "\n", "}" ]
// CreateScope creates a new scope
[ "CreateScope", "creates", "a", "new", "scope" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L744-L746
4,208
uber-go/dosa
client.go
TruncateScope
func (c *adminClient) TruncateScope(ctx context.Context, s string) error { return c.connector.TruncateScope(ctx, s) }
go
func (c *adminClient) TruncateScope(ctx context.Context, s string) error { return c.connector.TruncateScope(ctx, s) }
[ "func", "(", "c", "*", "adminClient", ")", "TruncateScope", "(", "ctx", "context", ".", "Context", ",", "s", "string", ")", "error", "{", "return", "c", ".", "connector", ".", "TruncateScope", "(", "ctx", ",", "s", ")", "\n", "}" ]
// TruncateScope keeps the scope and the schemas, but drops the data associated with the scope
[ "TruncateScope", "keeps", "the", "scope", "and", "the", "schemas", "but", "drops", "the", "data", "associated", "with", "the", "scope" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/client.go#L749-L751
4,209
uber-go/dosa
range_conditions.go
NormalizeConditions
func NormalizeConditions(columnConditions map[string][]*Condition) []*ColumnCondition { var cc []*ColumnCondition for column, conds := range columnConditions { for _, cond := range conds { cc = append(cc, &ColumnCondition{ Name: column, Condition: cond}) } } sort.Sort(sortedColumnCondition(cc)) return cc }
go
func NormalizeConditions(columnConditions map[string][]*Condition) []*ColumnCondition { var cc []*ColumnCondition for column, conds := range columnConditions { for _, cond := range conds { cc = append(cc, &ColumnCondition{ Name: column, Condition: cond}) } } sort.Sort(sortedColumnCondition(cc)) return cc }
[ "func", "NormalizeConditions", "(", "columnConditions", "map", "[", "string", "]", "[", "]", "*", "Condition", ")", "[", "]", "*", "ColumnCondition", "{", "var", "cc", "[", "]", "*", "ColumnCondition", "\n\n", "for", "column", ",", "conds", ":=", "range", "columnConditions", "{", "for", "_", ",", "cond", ":=", "range", "conds", "{", "cc", "=", "append", "(", "cc", ",", "&", "ColumnCondition", "{", "Name", ":", "column", ",", "Condition", ":", "cond", "}", ")", "\n", "}", "\n", "}", "\n\n", "sort", ".", "Sort", "(", "sortedColumnCondition", "(", "cc", ")", ")", "\n", "return", "cc", "\n", "}" ]
// NormalizeConditions takes a set of conditions for columns and returns a sorted, denormalized view of the conditions.
[ "NormalizeConditions", "takes", "a", "set", "of", "conditions", "for", "columns", "and", "returns", "a", "sorted", "denormalized", "view", "of", "the", "conditions", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range_conditions.go#L63-L76
4,210
uber-go/dosa
connectors/routing/routing_config.go
NewRule
func NewRule(scope, namePrefix, connector string) (*Rule, error) { if namePrefix == "" { return nil, errors.New("namePrefix could not be empty, should be defined in yaml file") } if scope == "" { return nil, errors.New("scope could not be empty, should be defined in yaml file") } if strings.HasPrefix(namePrefix, "*") && len(namePrefix) != 1 { // we don't support name like '*.service.v1' return nil, errors.Errorf( "namePrefix like %v is not supported, cannot put * at the beginning of namePrefix.", namePrefix) } globMatch := glob.MustCompile(namePrefix) return &Rule{NamePrefix: namePrefix, Scope: scope, Connector: connector, GlobMatch: globMatch}, nil }
go
func NewRule(scope, namePrefix, connector string) (*Rule, error) { if namePrefix == "" { return nil, errors.New("namePrefix could not be empty, should be defined in yaml file") } if scope == "" { return nil, errors.New("scope could not be empty, should be defined in yaml file") } if strings.HasPrefix(namePrefix, "*") && len(namePrefix) != 1 { // we don't support name like '*.service.v1' return nil, errors.Errorf( "namePrefix like %v is not supported, cannot put * at the beginning of namePrefix.", namePrefix) } globMatch := glob.MustCompile(namePrefix) return &Rule{NamePrefix: namePrefix, Scope: scope, Connector: connector, GlobMatch: globMatch}, nil }
[ "func", "NewRule", "(", "scope", ",", "namePrefix", ",", "connector", "string", ")", "(", "*", "Rule", ",", "error", ")", "{", "if", "namePrefix", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "scope", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "strings", ".", "HasPrefix", "(", "namePrefix", ",", "\"", "\"", ")", "&&", "len", "(", "namePrefix", ")", "!=", "1", "{", "// we don't support name like '*.service.v1'", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "namePrefix", ")", "\n", "}", "\n\n", "globMatch", ":=", "glob", ".", "MustCompile", "(", "namePrefix", ")", "\n\n", "return", "&", "Rule", "{", "NamePrefix", ":", "namePrefix", ",", "Scope", ":", "scope", ",", "Connector", ":", "connector", ",", "GlobMatch", ":", "globMatch", "}", ",", "nil", "\n", "}" ]
// NewRule initializes Rule
[ "NewRule", "initializes", "Rule" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/routing_config.go#L40-L58
4,211
uber-go/dosa
connectors/routing/routing_config.go
RouteTo
func (r *Rule) RouteTo(scope string, namePrefix string) bool { // scope should be an exact match if r.Scope != scope { return false } // namePrefix could be glob match, but first check if there's an exact match if r.NamePrefix == namePrefix { return true } if r.GlobMatch.Match(namePrefix) { return true } return false }
go
func (r *Rule) RouteTo(scope string, namePrefix string) bool { // scope should be an exact match if r.Scope != scope { return false } // namePrefix could be glob match, but first check if there's an exact match if r.NamePrefix == namePrefix { return true } if r.GlobMatch.Match(namePrefix) { return true } return false }
[ "func", "(", "r", "*", "Rule", ")", "RouteTo", "(", "scope", "string", ",", "namePrefix", "string", ")", "bool", "{", "// scope should be an exact match", "if", "r", ".", "Scope", "!=", "scope", "{", "return", "false", "\n", "}", "\n\n", "// namePrefix could be glob match, but first check if there's an exact match", "if", "r", ".", "NamePrefix", "==", "namePrefix", "{", "return", "true", "\n", "}", "\n\n", "if", "r", ".", "GlobMatch", ".", "Match", "(", "namePrefix", ")", "{", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// RouteTo implements the method to choose the matched connector
[ "RouteTo", "implements", "the", "method", "to", "choose", "the", "matched", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/routing_config.go#L61-L77
4,212
uber-go/dosa
schema/uql/uql.go
ToUQL
func ToUQL(e *dosa.EntityDefinition) (string, error) { if err := e.EnsureValid(); err != nil { return "", errors.Wrap(err, "EntityDefinition is invalid") } var buf bytes.Buffer if err := tmpl.Execute(&buf, e); err != nil { // shouldn't happen unless we have a bug in our code return "", errors.Wrap(err, "failed to execute UQL template; this is most likely a DOSA bug") } return buf.String(), nil }
go
func ToUQL(e *dosa.EntityDefinition) (string, error) { if err := e.EnsureValid(); err != nil { return "", errors.Wrap(err, "EntityDefinition is invalid") } var buf bytes.Buffer if err := tmpl.Execute(&buf, e); err != nil { // shouldn't happen unless we have a bug in our code return "", errors.Wrap(err, "failed to execute UQL template; this is most likely a DOSA bug") } return buf.String(), nil }
[ "func", "ToUQL", "(", "e", "*", "dosa", ".", "EntityDefinition", ")", "(", "string", ",", "error", ")", "{", "if", "err", ":=", "e", ".", "EnsureValid", "(", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "var", "buf", "bytes", ".", "Buffer", "\n", "if", "err", ":=", "tmpl", ".", "Execute", "(", "&", "buf", ",", "e", ")", ";", "err", "!=", "nil", "{", "// shouldn't happen unless we have a bug in our code", "return", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "buf", ".", "String", "(", ")", ",", "nil", "\n", "}" ]
// ToUQL translates an entity definition to UQL string of create table stmt.
[ "ToUQL", "translates", "an", "entity", "definition", "to", "UQL", "string", "of", "create", "table", "stmt", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/schema/uql/uql.go#L58-L69
4,213
uber-go/dosa
names.go
NormalizeName
func NormalizeName(name string) (string, error) { lowercaseName := strings.ToLower(strings.TrimSpace(name)) if err := IsValidName(lowercaseName); err != nil { return "", errors.Wrapf(err, "failed to normalize to a valid name for %s", name) } return lowercaseName, nil }
go
func NormalizeName(name string) (string, error) { lowercaseName := strings.ToLower(strings.TrimSpace(name)) if err := IsValidName(lowercaseName); err != nil { return "", errors.Wrapf(err, "failed to normalize to a valid name for %s", name) } return lowercaseName, nil }
[ "func", "NormalizeName", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "lowercaseName", ":=", "strings", ".", "ToLower", "(", "strings", ".", "TrimSpace", "(", "name", ")", ")", "\n", "if", "err", ":=", "IsValidName", "(", "lowercaseName", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "return", "lowercaseName", ",", "nil", "\n", "}" ]
// NormalizeName normalizes names to a canonical representation by lowercase everything. // It returns error if the resultant canonical name is invalid.
[ "NormalizeName", "normalizes", "names", "to", "a", "canonical", "representation", "by", "lowercase", "everything", ".", "It", "returns", "error", "if", "the", "resultant", "canonical", "name", "is", "invalid", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/names.go#L86-L92
4,214
uber-go/dosa
cmd/dosa/schema.go
Execute
func (c *SchemaCheck) Execute(args []string) error { return c.doSchemaOp(schemaCheck, dosa.AdminClient.CanUpsertSchema, c.Args.Paths) }
go
func (c *SchemaCheck) Execute(args []string) error { return c.doSchemaOp(schemaCheck, dosa.AdminClient.CanUpsertSchema, c.Args.Paths) }
[ "func", "(", "c", "*", "SchemaCheck", ")", "Execute", "(", "args", "[", "]", "string", ")", "error", "{", "return", "c", ".", "doSchemaOp", "(", "schemaCheck", ",", "dosa", ".", "AdminClient", ".", "CanUpsertSchema", ",", "c", ".", "Args", ".", "Paths", ")", "\n", "}" ]
// Execute executes a schema check command
[ "Execute", "executes", "a", "schema", "check", "command" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/cmd/dosa/schema.go#L219-L221
4,215
uber-go/dosa
cmd/dosa/schema.go
Execute
func (c *SchemaUpsert) Execute(args []string) error { return c.doSchemaOp(schemaUpsert, dosa.AdminClient.UpsertSchema, c.Args.Paths) }
go
func (c *SchemaUpsert) Execute(args []string) error { return c.doSchemaOp(schemaUpsert, dosa.AdminClient.UpsertSchema, c.Args.Paths) }
[ "func", "(", "c", "*", "SchemaUpsert", ")", "Execute", "(", "args", "[", "]", "string", ")", "error", "{", "return", "c", ".", "doSchemaOp", "(", "schemaUpsert", ",", "dosa", ".", "AdminClient", ".", "UpsertSchema", ",", "c", ".", "Args", ".", "Paths", ")", "\n", "}" ]
// Execute executes a schema upsert command
[ "Execute", "executes", "a", "schema", "upsert", "command" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/cmd/dosa/schema.go#L240-L242
4,216
uber-go/dosa
cmd/dosa/schema.go
Execute
func (c *SchemaStatus) Execute(args []string) error { if c.Verbose { fmt.Printf("executing schema status with %v\n", args) fmt.Printf("options are %+v\n", *c) fmt.Printf("global options are %+v\n", options) } // TODO(eculver): use options/configurator pattern to apply defaults if options.ServiceName == "" { options.ServiceName = _defServiceName } client, err := c.provideClient(options) if err != nil { return err } defer shutdownAdminClient(client) if c.Scope.String() != "" { client.Scope(c.Scope.String()) } ctx, cancel := context.WithTimeout(context.Background(), options.Timeout.Duration()) defer cancel() var prefix string if prefix, err = getNamePrefix(c.NamePrefix, c.Prefix); err != nil { return err } status, err := client.CheckSchemaStatus(ctx, prefix, c.Version) if err != nil { if c.Verbose { fmt.Printf("detail:%+v\n", err) } fmt.Println("Status: NOT OK") return err } fmt.Printf("Version: %d\n", status.Version) fmt.Printf("Status: %s\n", status.Status) return nil }
go
func (c *SchemaStatus) Execute(args []string) error { if c.Verbose { fmt.Printf("executing schema status with %v\n", args) fmt.Printf("options are %+v\n", *c) fmt.Printf("global options are %+v\n", options) } // TODO(eculver): use options/configurator pattern to apply defaults if options.ServiceName == "" { options.ServiceName = _defServiceName } client, err := c.provideClient(options) if err != nil { return err } defer shutdownAdminClient(client) if c.Scope.String() != "" { client.Scope(c.Scope.String()) } ctx, cancel := context.WithTimeout(context.Background(), options.Timeout.Duration()) defer cancel() var prefix string if prefix, err = getNamePrefix(c.NamePrefix, c.Prefix); err != nil { return err } status, err := client.CheckSchemaStatus(ctx, prefix, c.Version) if err != nil { if c.Verbose { fmt.Printf("detail:%+v\n", err) } fmt.Println("Status: NOT OK") return err } fmt.Printf("Version: %d\n", status.Version) fmt.Printf("Status: %s\n", status.Status) return nil }
[ "func", "(", "c", "*", "SchemaStatus", ")", "Execute", "(", "args", "[", "]", "string", ")", "error", "{", "if", "c", ".", "Verbose", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "args", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "*", "c", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "options", ")", "\n", "}", "\n\n", "// TODO(eculver): use options/configurator pattern to apply defaults", "if", "options", ".", "ServiceName", "==", "\"", "\"", "{", "options", ".", "ServiceName", "=", "_defServiceName", "\n", "}", "\n\n", "client", ",", "err", ":=", "c", ".", "provideClient", "(", "options", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "shutdownAdminClient", "(", "client", ")", "\n\n", "if", "c", ".", "Scope", ".", "String", "(", ")", "!=", "\"", "\"", "{", "client", ".", "Scope", "(", "c", ".", "Scope", ".", "String", "(", ")", ")", "\n", "}", "\n\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "options", ".", "Timeout", ".", "Duration", "(", ")", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "var", "prefix", "string", "\n", "if", "prefix", ",", "err", "=", "getNamePrefix", "(", "c", ".", "NamePrefix", ",", "c", ".", "Prefix", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "status", ",", "err", ":=", "client", ".", "CheckSchemaStatus", "(", "ctx", ",", "prefix", ",", "c", ".", "Version", ")", "\n", "if", "err", "!=", "nil", "{", "if", "c", ".", "Verbose", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "}", "\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "status", ".", "Version", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "status", ".", "Status", ")", "\n", "return", "nil", "\n", "}" ]
// Execute executes a schema status command
[ "Execute", "executes", "a", "schema", "status", "command" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/cmd/dosa/schema.go#L259-L299
4,217
uber-go/dosa
cmd/dosa/schema.go
Execute
func (c *SchemaDump) Execute(args []string) error { if c.Verbose { fmt.Printf("executing schema dump with %v\n", args) fmt.Printf("options are %+v\n", *c) fmt.Printf("global options are %+v\n", options) } if c.JarPath != "" { if _, err := os.Stat(javaclient); os.IsNotExist(err) { downloadJar() } c.doSchemaDumpInJavaClient() return nil } // no connection necessary client := dosa.NewAdminClient(&devnull.Connector{}) if len(c.Args.Paths) != 0 { dirs, err := expandDirectories(c.Args.Paths) if err != nil { return errors.Wrap(err, "could not expand directories") } client.Directories(dirs) } if len(c.Excludes) != 0 { client.Excludes(c.Excludes) } // try to parse entities in each directory defs, err := client.GetSchema() if err != nil { return err } // for each of those entities, format it in the specified way for _, d := range defs { switch c.Format { case "cql": fmt.Println(cql.ToCQL(d)) case "uql": fmt.Println(uql.ToUQL(d)) case "avro": s, err := avro.ToAvro("TODO", d) fmt.Println(string(s), err) } } return nil }
go
func (c *SchemaDump) Execute(args []string) error { if c.Verbose { fmt.Printf("executing schema dump with %v\n", args) fmt.Printf("options are %+v\n", *c) fmt.Printf("global options are %+v\n", options) } if c.JarPath != "" { if _, err := os.Stat(javaclient); os.IsNotExist(err) { downloadJar() } c.doSchemaDumpInJavaClient() return nil } // no connection necessary client := dosa.NewAdminClient(&devnull.Connector{}) if len(c.Args.Paths) != 0 { dirs, err := expandDirectories(c.Args.Paths) if err != nil { return errors.Wrap(err, "could not expand directories") } client.Directories(dirs) } if len(c.Excludes) != 0 { client.Excludes(c.Excludes) } // try to parse entities in each directory defs, err := client.GetSchema() if err != nil { return err } // for each of those entities, format it in the specified way for _, d := range defs { switch c.Format { case "cql": fmt.Println(cql.ToCQL(d)) case "uql": fmt.Println(uql.ToUQL(d)) case "avro": s, err := avro.ToAvro("TODO", d) fmt.Println(string(s), err) } } return nil }
[ "func", "(", "c", "*", "SchemaDump", ")", "Execute", "(", "args", "[", "]", "string", ")", "error", "{", "if", "c", ".", "Verbose", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "args", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "*", "c", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "options", ")", "\n", "}", "\n\n", "if", "c", ".", "JarPath", "!=", "\"", "\"", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "javaclient", ")", ";", "os", ".", "IsNotExist", "(", "err", ")", "{", "downloadJar", "(", ")", "\n", "}", "\n", "c", ".", "doSchemaDumpInJavaClient", "(", ")", "\n", "return", "nil", "\n", "}", "\n\n", "// no connection necessary", "client", ":=", "dosa", ".", "NewAdminClient", "(", "&", "devnull", ".", "Connector", "{", "}", ")", "\n", "if", "len", "(", "c", ".", "Args", ".", "Paths", ")", "!=", "0", "{", "dirs", ",", "err", ":=", "expandDirectories", "(", "c", ".", "Args", ".", "Paths", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "client", ".", "Directories", "(", "dirs", ")", "\n", "}", "\n", "if", "len", "(", "c", ".", "Excludes", ")", "!=", "0", "{", "client", ".", "Excludes", "(", "c", ".", "Excludes", ")", "\n", "}", "\n\n", "// try to parse entities in each directory", "defs", ",", "err", ":=", "client", ".", "GetSchema", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// for each of those entities, format it in the specified way", "for", "_", ",", "d", ":=", "range", "defs", "{", "switch", "c", ".", "Format", "{", "case", "\"", "\"", ":", "fmt", ".", "Println", "(", "cql", ".", "ToCQL", "(", "d", ")", ")", "\n", "case", "\"", "\"", ":", "fmt", ".", "Println", "(", "uql", ".", "ToUQL", "(", "d", ")", ")", "\n", "case", "\"", "\"", ":", "s", ",", "err", ":=", "avro", ".", "ToAvro", "(", "\"", "\"", ",", "d", ")", "\n", "fmt", ".", "Println", "(", "string", "(", "s", ")", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Execute executes a schema dump command
[ "Execute", "executes", "a", "schema", "dump", "command" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/cmd/dosa/schema.go#L313-L361
4,218
uber-go/dosa
connectors/base/base.go
Read
func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue, minimumFields []string) (map[string]dosa.FieldValue, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.Read(ctx, ei, values, minimumFields) }
go
func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue, minimumFields []string) (map[string]dosa.FieldValue, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.Read(ctx, ei, values, minimumFields) }
[ "func", "(", "c", "*", "Connector", ")", "Read", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "minimumFields", "[", "]", "string", ")", "(", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "error", ")", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "nil", ",", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "Read", "(", "ctx", ",", "ei", ",", "values", ",", "minimumFields", ")", "\n", "}" ]
// Read calls Next
[ "Read", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L67-L72
4,219
uber-go/dosa
connectors/base/base.go
Upsert
func (c *Connector) Upsert(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.Upsert(ctx, ei, values) }
go
func (c *Connector) Upsert(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.Upsert(ctx, ei, values) }
[ "func", "(", "c", "*", "Connector", ")", "Upsert", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "error", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "Upsert", "(", "ctx", ",", "ei", ",", "values", ")", "\n", "}" ]
// Upsert calls Next
[ "Upsert", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L83-L88
4,220
uber-go/dosa
connectors/base/base.go
RemoveRange
func (c *Connector) RemoveRange(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.RemoveRange(ctx, ei, columnConditions) }
go
func (c *Connector) RemoveRange(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.RemoveRange(ctx, ei, columnConditions) }
[ "func", "(", "c", "*", "Connector", ")", "RemoveRange", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "columnConditions", "map", "[", "string", "]", "[", "]", "*", "dosa", ".", "Condition", ")", "error", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "RemoveRange", "(", "ctx", ",", "ei", ",", "columnConditions", ")", "\n", "}" ]
// RemoveRange calls Next.
[ "RemoveRange", "calls", "Next", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L107-L112
4,221
uber-go/dosa
connectors/base/base.go
MultiRemove
func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) ([]error, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.MultiRemove(ctx, ei, multiValues) }
go
func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) ([]error, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.MultiRemove(ctx, ei, multiValues) }
[ "func", "(", "c", "*", "Connector", ")", "MultiRemove", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "multiValues", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "(", "[", "]", "error", ",", "error", ")", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "nil", ",", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "MultiRemove", "(", "ctx", ",", "ei", ",", "multiValues", ")", "\n", "}" ]
// MultiRemove calls Next
[ "MultiRemove", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L115-L120
4,222
uber-go/dosa
connectors/base/base.go
CanUpsertSchema
func (c *Connector) CanUpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error) { if c.Next == nil { return dosa.InvalidVersion, NewErrNoMoreConnector() } return c.Next.CanUpsertSchema(ctx, scope, namePrefix, ed) }
go
func (c *Connector) CanUpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error) { if c.Next == nil { return dosa.InvalidVersion, NewErrNoMoreConnector() } return c.Next.CanUpsertSchema(ctx, scope, namePrefix, ed) }
[ "func", "(", "c", "*", "Connector", ")", "CanUpsertSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "ed", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "int32", ",", "error", ")", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "dosa", ".", "InvalidVersion", ",", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "CanUpsertSchema", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "ed", ")", "\n", "}" ]
// CanUpsertSchema calls Next
[ "CanUpsertSchema", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L147-L152
4,223
uber-go/dosa
connectors/base/base.go
UpsertSchema
func (c *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.UpsertSchema(ctx, scope, namePrefix, ed) }
go
func (c *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.UpsertSchema(ctx, scope, namePrefix, ed) }
[ "func", "(", "c", "*", "Connector", ")", "UpsertSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "ed", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "nil", ",", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "UpsertSchema", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "ed", ")", "\n", "}" ]
// UpsertSchema calls Next
[ "UpsertSchema", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L155-L160
4,224
uber-go/dosa
connectors/base/base.go
CheckSchemaStatus
func (c *Connector) CheckSchemaStatus(ctx context.Context, scope string, namePrefix string, version int32) (*dosa.SchemaStatus, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.CheckSchemaStatus(ctx, scope, namePrefix, version) }
go
func (c *Connector) CheckSchemaStatus(ctx context.Context, scope string, namePrefix string, version int32) (*dosa.SchemaStatus, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.CheckSchemaStatus(ctx, scope, namePrefix, version) }
[ "func", "(", "c", "*", "Connector", ")", "CheckSchemaStatus", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ",", "namePrefix", "string", ",", "version", "int32", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "nil", ",", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "CheckSchemaStatus", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "version", ")", "\n", "}" ]
// CheckSchemaStatus calls Next
[ "CheckSchemaStatus", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L163-L168
4,225
uber-go/dosa
connectors/base/base.go
GetEntitySchema
func (c *Connector) GetEntitySchema(ctx context.Context, scope, namePrefix, entityName string, version int32) (*dosa.EntityDefinition, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.GetEntitySchema(ctx, scope, namePrefix, entityName, version) }
go
func (c *Connector) GetEntitySchema(ctx context.Context, scope, namePrefix, entityName string, version int32) (*dosa.EntityDefinition, error) { if c.Next == nil { return nil, NewErrNoMoreConnector() } return c.Next.GetEntitySchema(ctx, scope, namePrefix, entityName, version) }
[ "func", "(", "c", "*", "Connector", ")", "GetEntitySchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", ",", "entityName", "string", ",", "version", "int32", ")", "(", "*", "dosa", ".", "EntityDefinition", ",", "error", ")", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "nil", ",", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "GetEntitySchema", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "entityName", ",", "version", ")", "\n", "}" ]
// GetEntitySchema calls next
[ "GetEntitySchema", "calls", "next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L171-L176
4,226
uber-go/dosa
connectors/base/base.go
CreateScope
func (c *Connector) CreateScope(ctx context.Context, md *dosa.ScopeMetadata) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.CreateScope(ctx, md) }
go
func (c *Connector) CreateScope(ctx context.Context, md *dosa.ScopeMetadata) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.CreateScope(ctx, md) }
[ "func", "(", "c", "*", "Connector", ")", "CreateScope", "(", "ctx", "context", ".", "Context", ",", "md", "*", "dosa", ".", "ScopeMetadata", ")", "error", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "CreateScope", "(", "ctx", ",", "md", ")", "\n", "}" ]
// CreateScope calls Next
[ "CreateScope", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L179-L184
4,227
uber-go/dosa
connectors/base/base.go
TruncateScope
func (c *Connector) TruncateScope(ctx context.Context, scope string) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.TruncateScope(ctx, scope) }
go
func (c *Connector) TruncateScope(ctx context.Context, scope string) error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.TruncateScope(ctx, scope) }
[ "func", "(", "c", "*", "Connector", ")", "TruncateScope", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "error", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "TruncateScope", "(", "ctx", ",", "scope", ")", "\n", "}" ]
// TruncateScope calls Next
[ "TruncateScope", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L187-L192
4,228
uber-go/dosa
connectors/base/base.go
ScopeExists
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { if c.Next == nil { return false, NewErrNoMoreConnector() } return c.Next.ScopeExists(ctx, scope) }
go
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { if c.Next == nil { return false, NewErrNoMoreConnector() } return c.Next.ScopeExists(ctx, scope) }
[ "func", "(", "c", "*", "Connector", ")", "ScopeExists", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "(", "bool", ",", "error", ")", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "false", ",", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "ScopeExists", "(", "ctx", ",", "scope", ")", "\n", "}" ]
// ScopeExists calls Next
[ "ScopeExists", "calls", "Next" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L203-L208
4,229
uber-go/dosa
connectors/base/base.go
Shutdown
func (c *Connector) Shutdown() error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.Shutdown() }
go
func (c *Connector) Shutdown() error { if c.Next == nil { return NewErrNoMoreConnector() } return c.Next.Shutdown() }
[ "func", "(", "c", "*", "Connector", ")", "Shutdown", "(", ")", "error", "{", "if", "c", ".", "Next", "==", "nil", "{", "return", "NewErrNoMoreConnector", "(", ")", "\n", "}", "\n", "return", "c", ".", "Next", ".", "Shutdown", "(", ")", "\n", "}" ]
// Shutdown always returns nil
[ "Shutdown", "always", "returns", "nil" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/base/base.go#L211-L216
4,230
uber-go/dosa
connectors/yarpc/client.go
NewClient
func (c ClientConfig) NewClient(entities ...dosa.DomainObject) (dosa.Client, error) { reg, err := dosa.NewRegistrar(c.Scope, c.NamePrefix, entities...) if err != nil { return nil, err } conn, err := NewConnector(c.Yarpc) if err != nil { return nil, err } return dosa.NewClient(reg, conn), nil }
go
func (c ClientConfig) NewClient(entities ...dosa.DomainObject) (dosa.Client, error) { reg, err := dosa.NewRegistrar(c.Scope, c.NamePrefix, entities...) if err != nil { return nil, err } conn, err := NewConnector(c.Yarpc) if err != nil { return nil, err } return dosa.NewClient(reg, conn), nil }
[ "func", "(", "c", "ClientConfig", ")", "NewClient", "(", "entities", "...", "dosa", ".", "DomainObject", ")", "(", "dosa", ".", "Client", ",", "error", ")", "{", "reg", ",", "err", ":=", "dosa", ".", "NewRegistrar", "(", "c", ".", "Scope", ",", "c", ".", "NamePrefix", ",", "entities", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "conn", ",", "err", ":=", "NewConnector", "(", "c", ".", "Yarpc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "dosa", ".", "NewClient", "(", "reg", ",", "conn", ")", ",", "nil", "\n", "}" ]
// NewClient creates a DOSA client based on a ClientConfig
[ "NewClient", "creates", "a", "DOSA", "client", "based", "on", "a", "ClientConfig" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/client.go#L36-L48
4,231
uber-go/dosa
conditioner.go
ConvertConditions
func ConvertConditions(conditions map[string][]*Condition, t *Table) (map[string][]*Condition, error) { serverConditions := map[string][]*Condition{} for colName, conds := range conditions { if scolName, ok := t.FieldToCol[colName]; ok { serverConditions[scolName] = conds // we need to be sure each of the types are correct for marshaling cd := t.FindColumnDefinition(scolName) for _, cond := range conds { if err := ensureTypeMatch(cd.Type, cond.Value); err != nil { return nil, errors.Wrapf(err, "column %s", colName) } } } else { return nil, errors.Errorf("Cannot find column %q in struct %q", colName, t.StructName) } } return serverConditions, nil }
go
func ConvertConditions(conditions map[string][]*Condition, t *Table) (map[string][]*Condition, error) { serverConditions := map[string][]*Condition{} for colName, conds := range conditions { if scolName, ok := t.FieldToCol[colName]; ok { serverConditions[scolName] = conds // we need to be sure each of the types are correct for marshaling cd := t.FindColumnDefinition(scolName) for _, cond := range conds { if err := ensureTypeMatch(cd.Type, cond.Value); err != nil { return nil, errors.Wrapf(err, "column %s", colName) } } } else { return nil, errors.Errorf("Cannot find column %q in struct %q", colName, t.StructName) } } return serverConditions, nil }
[ "func", "ConvertConditions", "(", "conditions", "map", "[", "string", "]", "[", "]", "*", "Condition", ",", "t", "*", "Table", ")", "(", "map", "[", "string", "]", "[", "]", "*", "Condition", ",", "error", ")", "{", "serverConditions", ":=", "map", "[", "string", "]", "[", "]", "*", "Condition", "{", "}", "\n", "for", "colName", ",", "conds", ":=", "range", "conditions", "{", "if", "scolName", ",", "ok", ":=", "t", ".", "FieldToCol", "[", "colName", "]", ";", "ok", "{", "serverConditions", "[", "scolName", "]", "=", "conds", "\n", "// we need to be sure each of the types are correct for marshaling", "cd", ":=", "t", ".", "FindColumnDefinition", "(", "scolName", ")", "\n", "for", "_", ",", "cond", ":=", "range", "conds", "{", "if", "err", ":=", "ensureTypeMatch", "(", "cd", ".", "Type", ",", "cond", ".", "Value", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "colName", ")", "\n", "}", "\n", "}", "\n", "}", "else", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "colName", ",", "t", ".", "StructName", ")", "\n", "}", "\n", "}", "\n", "return", "serverConditions", ",", "nil", "\n", "}" ]
// ConvertConditions converts a list of client field names to server side field names
[ "ConvertConditions", "converts", "a", "list", "of", "client", "field", "names", "to", "server", "side", "field", "names" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/conditioner.go#L35-L52
4,232
uber-go/dosa
mocks/client.go
GetRegistrar
func (m *MockClient) GetRegistrar() dosa.Registrar { ret := m.ctrl.Call(m, "GetRegistrar") ret0, _ := ret[0].(dosa.Registrar) return ret0 }
go
func (m *MockClient) GetRegistrar() dosa.Registrar { ret := m.ctrl.Call(m, "GetRegistrar") ret0, _ := ret[0].(dosa.Registrar) return ret0 }
[ "func", "(", "m", "*", "MockClient", ")", "GetRegistrar", "(", ")", "dosa", ".", "Registrar", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "dosa", ".", "Registrar", ")", "\n", "return", "ret0", "\n", "}" ]
// GetRegistrar mocks base method
[ "GetRegistrar", "mocks", "base", "method" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L71-L75
4,233
uber-go/dosa
mocks/client.go
GetRegistrar
func (mr *MockClientMockRecorder) GetRegistrar() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRegistrar", reflect.TypeOf((*MockClient)(nil).GetRegistrar)) }
go
func (mr *MockClientMockRecorder) GetRegistrar() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRegistrar", reflect.TypeOf((*MockClient)(nil).GetRegistrar)) }
[ "func", "(", "mr", "*", "MockClientMockRecorder", ")", "GetRegistrar", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockClient", ")", "(", "nil", ")", ".", "GetRegistrar", ")", ")", "\n", "}" ]
// GetRegistrar indicates an expected call of GetRegistrar
[ "GetRegistrar", "indicates", "an", "expected", "call", "of", "GetRegistrar" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L78-L80
4,234
uber-go/dosa
mocks/client.go
MultiRead
func (mr *MockClientMockRecorder) MultiRead(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { varargs := append([]interface{}{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MultiRead", reflect.TypeOf((*MockClient)(nil).MultiRead), varargs...) }
go
func (mr *MockClientMockRecorder) MultiRead(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { varargs := append([]interface{}{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MultiRead", reflect.TypeOf((*MockClient)(nil).MultiRead), varargs...) }
[ "func", "(", "mr", "*", "MockClientMockRecorder", ")", "MultiRead", "(", "arg0", ",", "arg1", "interface", "{", "}", ",", "arg2", "...", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "varargs", ":=", "append", "(", "[", "]", "interface", "{", "}", "{", "arg0", ",", "arg1", "}", ",", "arg2", "...", ")", "\n", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockClient", ")", "(", "nil", ")", ".", "MultiRead", ")", ",", "varargs", "...", ")", "\n", "}" ]
// MultiRead indicates an expected call of MultiRead
[ "MultiRead", "indicates", "an", "expected", "call", "of", "MultiRead" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L107-L110
4,235
uber-go/dosa
mocks/client.go
RemoveRange
func (m *MockClient) RemoveRange(arg0 context.Context, arg1 *dosa.RemoveRangeOp) error { ret := m.ctrl.Call(m, "RemoveRange", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockClient) RemoveRange(arg0 context.Context, arg1 *dosa.RemoveRangeOp) error { ret := m.ctrl.Call(m, "RemoveRange", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockClient", ")", "RemoveRange", "(", "arg0", "context", ".", "Context", ",", "arg1", "*", "dosa", ".", "RemoveRangeOp", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// RemoveRange mocks base method
[ "RemoveRange", "mocks", "base", "method" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L151-L155
4,236
uber-go/dosa
mocks/client.go
ScanEverything
func (m *MockClient) ScanEverything(arg0 context.Context, arg1 *dosa.ScanOp) ([]dosa.DomainObject, string, error) { ret := m.ctrl.Call(m, "ScanEverything", arg0, arg1) ret0, _ := ret[0].([]dosa.DomainObject) ret1, _ := ret[1].(string) ret2, _ := ret[2].(error) return ret0, ret1, ret2 }
go
func (m *MockClient) ScanEverything(arg0 context.Context, arg1 *dosa.ScanOp) ([]dosa.DomainObject, string, error) { ret := m.ctrl.Call(m, "ScanEverything", arg0, arg1) ret0, _ := ret[0].([]dosa.DomainObject) ret1, _ := ret[1].(string) ret2, _ := ret[2].(error) return ret0, ret1, ret2 }
[ "func", "(", "m", "*", "MockClient", ")", "ScanEverything", "(", "arg0", "context", ".", "Context", ",", "arg1", "*", "dosa", ".", "ScanOp", ")", "(", "[", "]", "dosa", ".", "DomainObject", ",", "string", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "[", "]", "dosa", ".", "DomainObject", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "string", ")", "\n", "ret2", ",", "_", ":=", "ret", "[", "2", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", ",", "ret2", "\n", "}" ]
// ScanEverything mocks base method
[ "ScanEverything", "mocks", "base", "method" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L163-L169
4,237
uber-go/dosa
mocks/client.go
Upsert
func (m *MockClient) Upsert(arg0 context.Context, arg1 []string, arg2 dosa.DomainObject) error { ret := m.ctrl.Call(m, "Upsert", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockClient) Upsert(arg0 context.Context, arg1 []string, arg2 dosa.DomainObject) error { ret := m.ctrl.Call(m, "Upsert", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockClient", ")", "Upsert", "(", "arg0", "context", ".", "Context", ",", "arg1", "[", "]", "string", ",", "arg2", "dosa", ".", "DomainObject", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// Upsert mocks base method
[ "Upsert", "mocks", "base", "method" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L189-L193
4,238
uber-go/dosa
mocks/client.go
WalkRange
func (m *MockClient) WalkRange(arg0 context.Context, arg1 *dosa.RangeOp, arg2 func(dosa.DomainObject) error) error { ret := m.ctrl.Call(m, "WalkRange", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockClient) WalkRange(arg0 context.Context, arg1 *dosa.RangeOp, arg2 func(dosa.DomainObject) error) error { ret := m.ctrl.Call(m, "WalkRange", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockClient", ")", "WalkRange", "(", "arg0", "context", ".", "Context", ",", "arg1", "*", "dosa", ".", "RangeOp", ",", "arg2", "func", "(", "dosa", ".", "DomainObject", ")", "error", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// WalkRange mocks base method
[ "WalkRange", "mocks", "base", "method" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L201-L205
4,239
uber-go/dosa
mocks/client.go
NewMockAdminClient
func NewMockAdminClient(ctrl *gomock.Controller) *MockAdminClient { mock := &MockAdminClient{ctrl: ctrl} mock.recorder = &MockAdminClientMockRecorder{mock} return mock }
go
func NewMockAdminClient(ctrl *gomock.Controller) *MockAdminClient { mock := &MockAdminClient{ctrl: ctrl} mock.recorder = &MockAdminClientMockRecorder{mock} return mock }
[ "func", "NewMockAdminClient", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockAdminClient", "{", "mock", ":=", "&", "MockAdminClient", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockAdminClientMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockAdminClient creates a new mock instance
[ "NewMockAdminClient", "creates", "a", "new", "mock", "instance" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L224-L228
4,240
uber-go/dosa
mocks/client.go
CreateScope
func (m *MockAdminClient) CreateScope(arg0 context.Context, arg1 *dosa.ScopeMetadata) error { ret := m.ctrl.Call(m, "CreateScope", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockAdminClient) CreateScope(arg0 context.Context, arg1 *dosa.ScopeMetadata) error { ret := m.ctrl.Call(m, "CreateScope", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockAdminClient", ")", "CreateScope", "(", "arg0", "context", ".", "Context", ",", "arg1", "*", "dosa", ".", "ScopeMetadata", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// CreateScope mocks base method
[ "CreateScope", "mocks", "base", "method" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L262-L266
4,241
uber-go/dosa
mocks/client.go
DropScope
func (mr *MockAdminClientMockRecorder) DropScope(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DropScope", reflect.TypeOf((*MockAdminClient)(nil).DropScope), arg0, arg1) }
go
func (mr *MockAdminClientMockRecorder) DropScope(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DropScope", reflect.TypeOf((*MockAdminClient)(nil).DropScope), arg0, arg1) }
[ "func", "(", "mr", "*", "MockAdminClientMockRecorder", ")", "DropScope", "(", "arg0", ",", "arg1", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAdminClient", ")", "(", "nil", ")", ".", "DropScope", ")", ",", "arg0", ",", "arg1", ")", "\n", "}" ]
// DropScope indicates an expected call of DropScope
[ "DropScope", "indicates", "an", "expected", "call", "of", "DropScope" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L293-L295
4,242
uber-go/dosa
mocks/client.go
Excludes
func (m *MockAdminClient) Excludes(arg0 []string) dosa.AdminClient { ret := m.ctrl.Call(m, "Excludes", arg0) ret0, _ := ret[0].(dosa.AdminClient) return ret0 }
go
func (m *MockAdminClient) Excludes(arg0 []string) dosa.AdminClient { ret := m.ctrl.Call(m, "Excludes", arg0) ret0, _ := ret[0].(dosa.AdminClient) return ret0 }
[ "func", "(", "m", "*", "MockAdminClient", ")", "Excludes", "(", "arg0", "[", "]", "string", ")", "dosa", ".", "AdminClient", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "dosa", ".", "AdminClient", ")", "\n", "return", "ret0", "\n", "}" ]
// Excludes mocks base method
[ "Excludes", "mocks", "base", "method" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L298-L302
4,243
uber-go/dosa
mocks/client.go
Shutdown
func (mr *MockAdminClientMockRecorder) Shutdown() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Shutdown", reflect.TypeOf((*MockAdminClient)(nil).Shutdown)) }
go
func (mr *MockAdminClientMockRecorder) Shutdown() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Shutdown", reflect.TypeOf((*MockAdminClient)(nil).Shutdown)) }
[ "func", "(", "mr", "*", "MockAdminClientMockRecorder", ")", "Shutdown", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAdminClient", ")", "(", "nil", ")", ".", "Shutdown", ")", ")", "\n", "}" ]
// Shutdown indicates an expected call of Shutdown
[ "Shutdown", "indicates", "an", "expected", "call", "of", "Shutdown" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/mocks/client.go#L342-L344
4,244
uber-go/dosa
encoding/encoding.go
NewGobEncoder
func NewGobEncoder() GobEncoder { // Register non-primitive dosa types gob.Register(time.Time{}) gob.Register(dosa.NewUUID()) return GobEncoder{} }
go
func NewGobEncoder() GobEncoder { // Register non-primitive dosa types gob.Register(time.Time{}) gob.Register(dosa.NewUUID()) return GobEncoder{} }
[ "func", "NewGobEncoder", "(", ")", "GobEncoder", "{", "// Register non-primitive dosa types", "gob", ".", "Register", "(", "time", ".", "Time", "{", "}", ")", "\n", "gob", ".", "Register", "(", "dosa", ".", "NewUUID", "(", ")", ")", "\n", "return", "GobEncoder", "{", "}", "\n", "}" ]
// NewGobEncoder returns a gob encoder
[ "NewGobEncoder", "returns", "a", "gob", "encoder" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/encoding/encoding.go#L56-L61
4,245
uber-go/dosa
connectors/devnull/devnull.go
MultiRead
func (c *Connector) MultiRead(ctx context.Context, ei *dosa.EntityInfo, values []map[string]dosa.FieldValue, minimumFields []string) ([]*dosa.FieldValuesOrError, error) { errors := make([]*dosa.FieldValuesOrError, len(values)) for inx := range values { errors[inx] = &dosa.FieldValuesOrError{Error: &dosa.ErrNotFound{}} } return errors, nil }
go
func (c *Connector) MultiRead(ctx context.Context, ei *dosa.EntityInfo, values []map[string]dosa.FieldValue, minimumFields []string) ([]*dosa.FieldValuesOrError, error) { errors := make([]*dosa.FieldValuesOrError, len(values)) for inx := range values { errors[inx] = &dosa.FieldValuesOrError{Error: &dosa.ErrNotFound{}} } return errors, nil }
[ "func", "(", "c", "*", "Connector", ")", "MultiRead", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "minimumFields", "[", "]", "string", ")", "(", "[", "]", "*", "dosa", ".", "FieldValuesOrError", ",", "error", ")", "{", "errors", ":=", "make", "(", "[", "]", "*", "dosa", ".", "FieldValuesOrError", ",", "len", "(", "values", ")", ")", "\n", "for", "inx", ":=", "range", "values", "{", "errors", "[", "inx", "]", "=", "&", "dosa", ".", "FieldValuesOrError", "{", "Error", ":", "&", "dosa", ".", "ErrNotFound", "{", "}", "}", "\n", "}", "\n", "return", "errors", ",", "nil", "\n", "}" ]
// MultiRead returns a set of not found errors for each key you specify
[ "MultiRead", "returns", "a", "set", "of", "not", "found", "errors", "for", "each", "key", "you", "specify" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L43-L49
4,246
uber-go/dosa
connectors/devnull/devnull.go
Upsert
func (c *Connector) Upsert(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { return nil }
go
func (c *Connector) Upsert(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { return nil }
[ "func", "(", "c", "*", "Connector", ")", "Upsert", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "error", "{", "return", "nil", "\n", "}" ]
// Upsert throws away the data you upsert
[ "Upsert", "throws", "away", "the", "data", "you", "upsert" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L52-L54
4,247
uber-go/dosa
connectors/devnull/devnull.go
makeErrorSlice
func makeErrorSlice(len int, e error) []error { errors := make([]error, len) for inx := 0; inx < len; inx = inx + 1 { errors[inx] = e } return errors }
go
func makeErrorSlice(len int, e error) []error { errors := make([]error, len) for inx := 0; inx < len; inx = inx + 1 { errors[inx] = e } return errors }
[ "func", "makeErrorSlice", "(", "len", "int", ",", "e", "error", ")", "[", "]", "error", "{", "errors", ":=", "make", "(", "[", "]", "error", ",", "len", ")", "\n", "for", "inx", ":=", "0", ";", "inx", "<", "len", ";", "inx", "=", "inx", "+", "1", "{", "errors", "[", "inx", "]", "=", "e", "\n", "}", "\n", "return", "errors", "\n", "}" ]
// makeErrorSlice is a handy function to make a slice of errors or nil errors
[ "makeErrorSlice", "is", "a", "handy", "function", "to", "make", "a", "slice", "of", "errors", "or", "nil", "errors" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L57-L63
4,248
uber-go/dosa
connectors/devnull/devnull.go
MultiUpsert
func (c *Connector) MultiUpsert(ctx context.Context, ei *dosa.EntityInfo, values []map[string]dosa.FieldValue) ([]error, error) { return makeErrorSlice(len(values), nil), nil }
go
func (c *Connector) MultiUpsert(ctx context.Context, ei *dosa.EntityInfo, values []map[string]dosa.FieldValue) ([]error, error) { return makeErrorSlice(len(values), nil), nil }
[ "func", "(", "c", "*", "Connector", ")", "MultiUpsert", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "(", "[", "]", "error", ",", "error", ")", "{", "return", "makeErrorSlice", "(", "len", "(", "values", ")", ",", "nil", ")", ",", "nil", "\n", "}" ]
// MultiUpsert throws away all the data you upsert, returning a set of no errors
[ "MultiUpsert", "throws", "away", "all", "the", "data", "you", "upsert", "returning", "a", "set", "of", "no", "errors" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L66-L68
4,249
uber-go/dosa
connectors/devnull/devnull.go
MultiRemove
func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) ([]error, error) { return makeErrorSlice(len(multiValues), &dosa.ErrNotFound{}), nil }
go
func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) ([]error, error) { return makeErrorSlice(len(multiValues), &dosa.ErrNotFound{}), nil }
[ "func", "(", "c", "*", "Connector", ")", "MultiRemove", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "multiValues", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "(", "[", "]", "error", ",", "error", ")", "{", "return", "makeErrorSlice", "(", "len", "(", "multiValues", ")", ",", "&", "dosa", ".", "ErrNotFound", "{", "}", ")", ",", "nil", "\n", "}" ]
// MultiRemove returns a not found error for each value
[ "MultiRemove", "returns", "a", "not", "found", "error", "for", "each", "value" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L81-L83
4,250
uber-go/dosa
connectors/devnull/devnull.go
CheckSchema
func (c *Connector) CheckSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error) { return int32(1), nil }
go
func (c *Connector) CheckSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error) { return int32(1), nil }
[ "func", "(", "c", "*", "Connector", ")", "CheckSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "ed", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "int32", ",", "error", ")", "{", "return", "int32", "(", "1", ")", ",", "nil", "\n", "}" ]
// CheckSchema always returns schema version 1
[ "CheckSchema", "always", "returns", "schema", "version", "1" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L96-L98
4,251
uber-go/dosa
connectors/devnull/devnull.go
UpsertSchema
func (c *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { return &dosa.SchemaStatus{Version: int32(1), Status: "COMPLETED"}, nil }
go
func (c *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { return &dosa.SchemaStatus{Version: int32(1), Status: "COMPLETED"}, nil }
[ "func", "(", "c", "*", "Connector", ")", "UpsertSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "ed", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "return", "&", "dosa", ".", "SchemaStatus", "{", "Version", ":", "int32", "(", "1", ")", ",", "Status", ":", "\"", "\"", "}", ",", "nil", "\n", "}" ]
// UpsertSchema always returns a SchemaStatus with version 1 and COMPLETED status
[ "UpsertSchema", "always", "returns", "a", "SchemaStatus", "with", "version", "1", "and", "COMPLETED", "status" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L106-L108
4,252
uber-go/dosa
connectors/devnull/devnull.go
CheckSchemaStatus
func (c *Connector) CheckSchemaStatus(ctx context.Context, scope, namePrefix string, version int32) (*dosa.SchemaStatus, error) { return &dosa.SchemaStatus{ Version: int32(1), Status: "ACCEPTED", }, nil }
go
func (c *Connector) CheckSchemaStatus(ctx context.Context, scope, namePrefix string, version int32) (*dosa.SchemaStatus, error) { return &dosa.SchemaStatus{ Version: int32(1), Status: "ACCEPTED", }, nil }
[ "func", "(", "c", "*", "Connector", ")", "CheckSchemaStatus", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "version", "int32", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "return", "&", "dosa", ".", "SchemaStatus", "{", "Version", ":", "int32", "(", "1", ")", ",", "Status", ":", "\"", "\"", ",", "}", ",", "nil", "\n", "}" ]
// CheckSchemaStatus always returns a SchemaStatus with version 1 and ACCEPTED status
[ "CheckSchemaStatus", "always", "returns", "a", "SchemaStatus", "with", "version", "1", "and", "ACCEPTED", "status" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L111-L116
4,253
uber-go/dosa
connectors/devnull/devnull.go
GetEntitySchema
func (c *Connector) GetEntitySchema(ctx context.Context, scope, namePrefix, entityName string, version int32) (*dosa.EntityDefinition, error) { return &dosa.EntityDefinition{}, nil }
go
func (c *Connector) GetEntitySchema(ctx context.Context, scope, namePrefix, entityName string, version int32) (*dosa.EntityDefinition, error) { return &dosa.EntityDefinition{}, nil }
[ "func", "(", "c", "*", "Connector", ")", "GetEntitySchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", ",", "entityName", "string", ",", "version", "int32", ")", "(", "*", "dosa", ".", "EntityDefinition", ",", "error", ")", "{", "return", "&", "dosa", ".", "EntityDefinition", "{", "}", ",", "nil", "\n", "}" ]
// GetEntitySchema always returns a blank EntityInfo and no error.
[ "GetEntitySchema", "always", "returns", "a", "blank", "EntityInfo", "and", "no", "error", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L119-L121
4,254
uber-go/dosa
connectors/devnull/devnull.go
CreateScope
func (c *Connector) CreateScope(ctx context.Context, _ *dosa.ScopeMetadata) error { return nil }
go
func (c *Connector) CreateScope(ctx context.Context, _ *dosa.ScopeMetadata) error { return nil }
[ "func", "(", "c", "*", "Connector", ")", "CreateScope", "(", "ctx", "context", ".", "Context", ",", "_", "*", "dosa", ".", "ScopeMetadata", ")", "error", "{", "return", "nil", "\n", "}" ]
// CreateScope returns success
[ "CreateScope", "returns", "success" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L124-L126
4,255
uber-go/dosa
connectors/devnull/devnull.go
TruncateScope
func (c *Connector) TruncateScope(ctx context.Context, scope string) error { return nil }
go
func (c *Connector) TruncateScope(ctx context.Context, scope string) error { return nil }
[ "func", "(", "c", "*", "Connector", ")", "TruncateScope", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "error", "{", "return", "nil", "\n", "}" ]
// TruncateScope returns success
[ "TruncateScope", "returns", "success" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L129-L131
4,256
uber-go/dosa
connectors/devnull/devnull.go
ScopeExists
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { return true, nil }
go
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { return true, nil }
[ "func", "(", "c", "*", "Connector", ")", "ScopeExists", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "true", ",", "nil", "\n", "}" ]
// ScopeExists returns true
[ "ScopeExists", "returns", "true" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/devnull/devnull.go#L139-L141
4,257
uber-go/dosa
connectors/yarpc/yarpc.go
NewConnector
func NewConnector(config Config) (*Connector, error) { // Ensure host, port, serviceName, and callerName are all specified. if config.Host == "" { return nil, errors.New("no host specified") } if config.Port == "" { return nil, errors.New("no port specified") } if config.ServiceName == "" { return nil, errors.New("no serviceName specified") } if config.CallerName == "" { return nil, errors.New("no callerName specified") } ycfg := rpc.Config{Name: config.CallerName} hostPort := fmt.Sprintf("%s:%s", config.Host, config.Port) // this looks wrong, BUT since it's a uni-directional tchannel // connection, we have to pass CallerName as the tchannel "ServiceName" // for source/destination to be reported correctly by RPC layer. ts, err := tchannel.NewChannelTransport(tchannel.ServiceName(config.CallerName)) if err != nil { return nil, err } ycfg.Outbounds = rpc.Outbounds{ config.ServiceName: { Unary: ts.NewSingleOutbound(hostPort), }, } // important to note that this will panic if config contains invalid // values such as service name containing invalid characters dispatcher := rpc.NewDispatcher(ycfg) if err := dispatcher.Start(); err != nil { return nil, err } client := dosaclient.New(dispatcher.ClientConfig(config.ServiceName)) return &Connector{ dispatcher: dispatcher, client: client, headers: checkHeaders(config.ExtraHeaders, config.CallerName), }, nil }
go
func NewConnector(config Config) (*Connector, error) { // Ensure host, port, serviceName, and callerName are all specified. if config.Host == "" { return nil, errors.New("no host specified") } if config.Port == "" { return nil, errors.New("no port specified") } if config.ServiceName == "" { return nil, errors.New("no serviceName specified") } if config.CallerName == "" { return nil, errors.New("no callerName specified") } ycfg := rpc.Config{Name: config.CallerName} hostPort := fmt.Sprintf("%s:%s", config.Host, config.Port) // this looks wrong, BUT since it's a uni-directional tchannel // connection, we have to pass CallerName as the tchannel "ServiceName" // for source/destination to be reported correctly by RPC layer. ts, err := tchannel.NewChannelTransport(tchannel.ServiceName(config.CallerName)) if err != nil { return nil, err } ycfg.Outbounds = rpc.Outbounds{ config.ServiceName: { Unary: ts.NewSingleOutbound(hostPort), }, } // important to note that this will panic if config contains invalid // values such as service name containing invalid characters dispatcher := rpc.NewDispatcher(ycfg) if err := dispatcher.Start(); err != nil { return nil, err } client := dosaclient.New(dispatcher.ClientConfig(config.ServiceName)) return &Connector{ dispatcher: dispatcher, client: client, headers: checkHeaders(config.ExtraHeaders, config.CallerName), }, nil }
[ "func", "NewConnector", "(", "config", "Config", ")", "(", "*", "Connector", ",", "error", ")", "{", "// Ensure host, port, serviceName, and callerName are all specified.", "if", "config", ".", "Host", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "config", ".", "Port", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "config", ".", "ServiceName", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "config", ".", "CallerName", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "ycfg", ":=", "rpc", ".", "Config", "{", "Name", ":", "config", ".", "CallerName", "}", "\n", "hostPort", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "config", ".", "Host", ",", "config", ".", "Port", ")", "\n", "// this looks wrong, BUT since it's a uni-directional tchannel", "// connection, we have to pass CallerName as the tchannel \"ServiceName\"", "// for source/destination to be reported correctly by RPC layer.", "ts", ",", "err", ":=", "tchannel", ".", "NewChannelTransport", "(", "tchannel", ".", "ServiceName", "(", "config", ".", "CallerName", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "ycfg", ".", "Outbounds", "=", "rpc", ".", "Outbounds", "{", "config", ".", "ServiceName", ":", "{", "Unary", ":", "ts", ".", "NewSingleOutbound", "(", "hostPort", ")", ",", "}", ",", "}", "\n\n", "// important to note that this will panic if config contains invalid", "// values such as service name containing invalid characters", "dispatcher", ":=", "rpc", ".", "NewDispatcher", "(", "ycfg", ")", "\n", "if", "err", ":=", "dispatcher", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "client", ":=", "dosaclient", ".", "New", "(", "dispatcher", ".", "ClientConfig", "(", "config", ".", "ServiceName", ")", ")", "\n\n", "return", "&", "Connector", "{", "dispatcher", ":", "dispatcher", ",", "client", ":", "client", ",", "headers", ":", "checkHeaders", "(", "config", ".", "ExtraHeaders", ",", "config", ".", "CallerName", ")", ",", "}", ",", "nil", "\n", "}" ]
// NewConnector creates a new instance with user provided transport
[ "NewConnector", "creates", "a", "new", "instance", "with", "user", "provided", "transport" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L77-L124
4,258
uber-go/dosa
connectors/yarpc/yarpc.go
checkHeaders
func checkHeaders(headers map[string]string, caller string) map[string]string { if headers == nil { headers = map[string]string{} } // We don't just check to see if there's a value; it has to be non-empty. if headers["X-Uber-Source"] == "" { headers["X-Uber-Source"] = caller } return headers }
go
func checkHeaders(headers map[string]string, caller string) map[string]string { if headers == nil { headers = map[string]string{} } // We don't just check to see if there's a value; it has to be non-empty. if headers["X-Uber-Source"] == "" { headers["X-Uber-Source"] = caller } return headers }
[ "func", "checkHeaders", "(", "headers", "map", "[", "string", "]", "string", ",", "caller", "string", ")", "map", "[", "string", "]", "string", "{", "if", "headers", "==", "nil", "{", "headers", "=", "map", "[", "string", "]", "string", "{", "}", "\n", "}", "\n", "// We don't just check to see if there's a value; it has to be non-empty.", "if", "headers", "[", "\"", "\"", "]", "==", "\"", "\"", "{", "headers", "[", "\"", "\"", "]", "=", "caller", "\n", "}", "\n", "return", "headers", "\n", "}" ]
// checkHeaders ensures that X-Uber-Source is set.
[ "checkHeaders", "ensures", "that", "X", "-", "Uber", "-", "Source", "is", "set", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L127-L136
4,259
uber-go/dosa
connectors/yarpc/yarpc.go
Upsert
func (c *Connector) Upsert(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { ev, err := fieldValueMapFromClientMap(values) if err != nil { return err } ttl := dosa.NoTTL().Nanoseconds() if ei.TTL != nil { ttl = ei.TTL.Nanoseconds() } upsertRequest := dosarpc.UpsertRequest{ Ref: entityInfoToSchemaRef(ei), EntityValues: ev, TTL: &ttl, } err = c.client.Upsert(ctx, &upsertRequest, getHeaders(c.headers)...) if !dosarpc.Dosa_Upsert_Helper.IsException(err) { return errors.Wrap(err, "failed to Upsert due to network issue") } return errors.Wrap(err, "failed to Upsert") }
go
func (c *Connector) Upsert(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { ev, err := fieldValueMapFromClientMap(values) if err != nil { return err } ttl := dosa.NoTTL().Nanoseconds() if ei.TTL != nil { ttl = ei.TTL.Nanoseconds() } upsertRequest := dosarpc.UpsertRequest{ Ref: entityInfoToSchemaRef(ei), EntityValues: ev, TTL: &ttl, } err = c.client.Upsert(ctx, &upsertRequest, getHeaders(c.headers)...) if !dosarpc.Dosa_Upsert_Helper.IsException(err) { return errors.Wrap(err, "failed to Upsert due to network issue") } return errors.Wrap(err, "failed to Upsert") }
[ "func", "(", "c", "*", "Connector", ")", "Upsert", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "error", "{", "ev", ",", "err", ":=", "fieldValueMapFromClientMap", "(", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "ttl", ":=", "dosa", ".", "NoTTL", "(", ")", ".", "Nanoseconds", "(", ")", "\n", "if", "ei", ".", "TTL", "!=", "nil", "{", "ttl", "=", "ei", ".", "TTL", ".", "Nanoseconds", "(", ")", "\n", "}", "\n\n", "upsertRequest", ":=", "dosarpc", ".", "UpsertRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "EntityValues", ":", "ev", ",", "TTL", ":", "&", "ttl", ",", "}", "\n\n", "err", "=", "c", ".", "client", ".", "Upsert", "(", "ctx", ",", "&", "upsertRequest", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n\n", "if", "!", "dosarpc", ".", "Dosa_Upsert_Helper", ".", "IsException", "(", "err", ")", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}" ]
// Upsert inserts or updates your data
[ "Upsert", "inserts", "or", "updates", "your", "data" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L172-L196
4,260
uber-go/dosa
connectors/yarpc/yarpc.go
MultiUpsert
func (c *Connector) MultiUpsert(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) ([]error, error) { values, err := fieldValueMapsFromClientMaps(multiValues) if err != nil { return nil, err } // ttl := dosa.NoTTL().Nanoseconds() // if ei.TTL != nil { // ttl = ei.TTL.Nanoseconds() // } // perform the multi upsert request request := &dosarpc.MultiUpsertRequest{ Ref: entityInfoToSchemaRef(ei), Entities: values, // TTL: &ttl, mgode@ has not yet committed origin/ttl-for-multi-upsert } response, err := c.client.MultiUpsert(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_MultiUpsert_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to MultiUpsert due to network issue") } return nil, errors.Wrap(err, "failed to MultiUpsert") } rpcErrors := response.Errors results := make([]error, len(rpcErrors)) for i, rpcError := range rpcErrors { if rpcError != nil { results[i] = wrapIDLError(rpcError) } } return results, nil }
go
func (c *Connector) MultiUpsert(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) ([]error, error) { values, err := fieldValueMapsFromClientMaps(multiValues) if err != nil { return nil, err } // ttl := dosa.NoTTL().Nanoseconds() // if ei.TTL != nil { // ttl = ei.TTL.Nanoseconds() // } // perform the multi upsert request request := &dosarpc.MultiUpsertRequest{ Ref: entityInfoToSchemaRef(ei), Entities: values, // TTL: &ttl, mgode@ has not yet committed origin/ttl-for-multi-upsert } response, err := c.client.MultiUpsert(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_MultiUpsert_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to MultiUpsert due to network issue") } return nil, errors.Wrap(err, "failed to MultiUpsert") } rpcErrors := response.Errors results := make([]error, len(rpcErrors)) for i, rpcError := range rpcErrors { if rpcError != nil { results[i] = wrapIDLError(rpcError) } } return results, nil }
[ "func", "(", "c", "*", "Connector", ")", "MultiUpsert", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "multiValues", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "(", "[", "]", "error", ",", "error", ")", "{", "values", ",", "err", ":=", "fieldValueMapsFromClientMaps", "(", "multiValues", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// ttl := dosa.NoTTL().Nanoseconds()", "// if ei.TTL != nil {", "// \tttl = ei.TTL.Nanoseconds()", "// }", "// perform the multi upsert request", "request", ":=", "&", "dosarpc", ".", "MultiUpsertRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "Entities", ":", "values", ",", "// TTL: &ttl, mgode@ has not yet committed origin/ttl-for-multi-upsert", "}", "\n\n", "response", ",", "err", ":=", "c", ".", "client", ".", "MultiUpsert", "(", "ctx", ",", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_MultiUpsert_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "rpcErrors", ":=", "response", ".", "Errors", "\n", "results", ":=", "make", "(", "[", "]", "error", ",", "len", "(", "rpcErrors", ")", ")", "\n", "for", "i", ",", "rpcError", ":=", "range", "rpcErrors", "{", "if", "rpcError", "!=", "nil", "{", "results", "[", "i", "]", "=", "wrapIDLError", "(", "rpcError", ")", "\n", "}", "\n", "}", "\n\n", "return", "results", ",", "nil", "\n", "}" ]
// MultiUpsert upserts multiple entities at one time
[ "MultiUpsert", "upserts", "multiple", "entities", "at", "one", "time" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L199-L235
4,261
uber-go/dosa
connectors/yarpc/yarpc.go
Read
func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, keys map[string]dosa.FieldValue, minimumFields []string) (map[string]dosa.FieldValue, error) { // Convert the fields from the client's map to a set of fields to read var rpcMinimumFields map[string]struct{} if minimumFields != nil { rpcMinimumFields = map[string]struct{}{} for _, field := range minimumFields { rpcMinimumFields[field] = struct{}{} } } // convert the key values from interface{} to RPC's Value rpcFields := make(dosarpc.FieldValueMap) for key, value := range keys { rv, err := RawValueFromInterface(value) if err != nil { return nil, errors.Wrapf(err, "Key field %q", key) } if rv == nil { continue } rpcValue := &dosarpc.Value{ElemValue: rv} rpcFields[key] = rpcValue } // perform the read request readRequest := &dosarpc.ReadRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: rpcFields, FieldsToRead: rpcMinimumFields, } response, err := c.client.Read(ctx, readRequest, getHeaders(c.headers)...) if err != nil { if be, ok := err.(*dosarpc.BadRequestError); ok { if be.ErrorCode != nil && *be.ErrorCode == errCodeNotFound { return nil, errors.Wrap(&dosa.ErrNotFound{}, "Read failed: not found") } } if !dosarpc.Dosa_Read_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to Read due to network issue") } return nil, errors.Wrap(err, "failed to Read") } // no error, so for each column, transform it into the map of (col->value) items return decodeResults(ei, response.EntityValues), nil }
go
func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, keys map[string]dosa.FieldValue, minimumFields []string) (map[string]dosa.FieldValue, error) { // Convert the fields from the client's map to a set of fields to read var rpcMinimumFields map[string]struct{} if minimumFields != nil { rpcMinimumFields = map[string]struct{}{} for _, field := range minimumFields { rpcMinimumFields[field] = struct{}{} } } // convert the key values from interface{} to RPC's Value rpcFields := make(dosarpc.FieldValueMap) for key, value := range keys { rv, err := RawValueFromInterface(value) if err != nil { return nil, errors.Wrapf(err, "Key field %q", key) } if rv == nil { continue } rpcValue := &dosarpc.Value{ElemValue: rv} rpcFields[key] = rpcValue } // perform the read request readRequest := &dosarpc.ReadRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: rpcFields, FieldsToRead: rpcMinimumFields, } response, err := c.client.Read(ctx, readRequest, getHeaders(c.headers)...) if err != nil { if be, ok := err.(*dosarpc.BadRequestError); ok { if be.ErrorCode != nil && *be.ErrorCode == errCodeNotFound { return nil, errors.Wrap(&dosa.ErrNotFound{}, "Read failed: not found") } } if !dosarpc.Dosa_Read_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to Read due to network issue") } return nil, errors.Wrap(err, "failed to Read") } // no error, so for each column, transform it into the map of (col->value) items return decodeResults(ei, response.EntityValues), nil }
[ "func", "(", "c", "*", "Connector", ")", "Read", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "keys", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "minimumFields", "[", "]", "string", ")", "(", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "error", ")", "{", "// Convert the fields from the client's map to a set of fields to read", "var", "rpcMinimumFields", "map", "[", "string", "]", "struct", "{", "}", "\n", "if", "minimumFields", "!=", "nil", "{", "rpcMinimumFields", "=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "for", "_", ",", "field", ":=", "range", "minimumFields", "{", "rpcMinimumFields", "[", "field", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n\n", "// convert the key values from interface{} to RPC's Value", "rpcFields", ":=", "make", "(", "dosarpc", ".", "FieldValueMap", ")", "\n", "for", "key", ",", "value", ":=", "range", "keys", "{", "rv", ",", "err", ":=", "RawValueFromInterface", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "if", "rv", "==", "nil", "{", "continue", "\n", "}", "\n", "rpcValue", ":=", "&", "dosarpc", ".", "Value", "{", "ElemValue", ":", "rv", "}", "\n", "rpcFields", "[", "key", "]", "=", "rpcValue", "\n", "}", "\n\n", "// perform the read request", "readRequest", ":=", "&", "dosarpc", ".", "ReadRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "KeyValues", ":", "rpcFields", ",", "FieldsToRead", ":", "rpcMinimumFields", ",", "}", "\n\n", "response", ",", "err", ":=", "c", ".", "client", ".", "Read", "(", "ctx", ",", "readRequest", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "be", ",", "ok", ":=", "err", ".", "(", "*", "dosarpc", ".", "BadRequestError", ")", ";", "ok", "{", "if", "be", ".", "ErrorCode", "!=", "nil", "&&", "*", "be", ".", "ErrorCode", "==", "errCodeNotFound", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "&", "dosa", ".", "ErrNotFound", "{", "}", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "if", "!", "dosarpc", ".", "Dosa_Read_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// no error, so for each column, transform it into the map of (col->value) items", "return", "decodeResults", "(", "ei", ",", "response", ".", "EntityValues", ")", ",", "nil", "\n", "}" ]
// Read reads a single entity
[ "Read", "reads", "a", "single", "entity" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L238-L287
4,262
uber-go/dosa
connectors/yarpc/yarpc.go
MultiRead
func (c *Connector) MultiRead(ctx context.Context, ei *dosa.EntityInfo, keys []map[string]dosa.FieldValue, minimumFields []string) ([]*dosa.FieldValuesOrError, error) { // Convert the fields from the client's map to a set of fields to read rpcMinimumFields := makeRPCminimumFields(minimumFields) // convert the keys to RPC's Value rpcFields := make([]dosarpc.FieldValueMap, len(keys)) for i, kmap := range keys { rpcFields[i] = make(dosarpc.FieldValueMap) for key, value := range kmap { rv, err := RawValueFromInterface(value) if err != nil { return nil, err } if rv == nil { continue } rpcValue := &dosarpc.Value{ElemValue: rv} rpcFields[i][key] = rpcValue } } // perform the multi read request request := &dosarpc.MultiReadRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: rpcFields, FieldsToRead: rpcMinimumFields, } response, err := c.client.MultiRead(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_MultiRead_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to MultiRead due to network issue") } return nil, errors.Wrap(err, "failed to MultiRead") } rpcResults := response.Results results := make([]*dosa.FieldValuesOrError, len(rpcResults)) for i, rpcResult := range rpcResults { results[i] = &dosa.FieldValuesOrError{Values: make(map[string]dosa.FieldValue), Error: nil} for name, value := range rpcResult.EntityValues { for _, col := range ei.Def.Columns { if col.Name == name { results[i].Values[name] = RawValueAsInterface(*value.ElemValue, col.Type) break } } } if rpcResult.Error != nil { results[i].Error = wrapIDLError(rpcResult.Error) } } return results, nil }
go
func (c *Connector) MultiRead(ctx context.Context, ei *dosa.EntityInfo, keys []map[string]dosa.FieldValue, minimumFields []string) ([]*dosa.FieldValuesOrError, error) { // Convert the fields from the client's map to a set of fields to read rpcMinimumFields := makeRPCminimumFields(minimumFields) // convert the keys to RPC's Value rpcFields := make([]dosarpc.FieldValueMap, len(keys)) for i, kmap := range keys { rpcFields[i] = make(dosarpc.FieldValueMap) for key, value := range kmap { rv, err := RawValueFromInterface(value) if err != nil { return nil, err } if rv == nil { continue } rpcValue := &dosarpc.Value{ElemValue: rv} rpcFields[i][key] = rpcValue } } // perform the multi read request request := &dosarpc.MultiReadRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: rpcFields, FieldsToRead: rpcMinimumFields, } response, err := c.client.MultiRead(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_MultiRead_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to MultiRead due to network issue") } return nil, errors.Wrap(err, "failed to MultiRead") } rpcResults := response.Results results := make([]*dosa.FieldValuesOrError, len(rpcResults)) for i, rpcResult := range rpcResults { results[i] = &dosa.FieldValuesOrError{Values: make(map[string]dosa.FieldValue), Error: nil} for name, value := range rpcResult.EntityValues { for _, col := range ei.Def.Columns { if col.Name == name { results[i].Values[name] = RawValueAsInterface(*value.ElemValue, col.Type) break } } } if rpcResult.Error != nil { results[i].Error = wrapIDLError(rpcResult.Error) } } return results, nil }
[ "func", "(", "c", "*", "Connector", ")", "MultiRead", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "keys", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "minimumFields", "[", "]", "string", ")", "(", "[", "]", "*", "dosa", ".", "FieldValuesOrError", ",", "error", ")", "{", "// Convert the fields from the client's map to a set of fields to read", "rpcMinimumFields", ":=", "makeRPCminimumFields", "(", "minimumFields", ")", "\n\n", "// convert the keys to RPC's Value", "rpcFields", ":=", "make", "(", "[", "]", "dosarpc", ".", "FieldValueMap", ",", "len", "(", "keys", ")", ")", "\n", "for", "i", ",", "kmap", ":=", "range", "keys", "{", "rpcFields", "[", "i", "]", "=", "make", "(", "dosarpc", ".", "FieldValueMap", ")", "\n", "for", "key", ",", "value", ":=", "range", "kmap", "{", "rv", ",", "err", ":=", "RawValueFromInterface", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "rv", "==", "nil", "{", "continue", "\n", "}", "\n", "rpcValue", ":=", "&", "dosarpc", ".", "Value", "{", "ElemValue", ":", "rv", "}", "\n", "rpcFields", "[", "i", "]", "[", "key", "]", "=", "rpcValue", "\n", "}", "\n", "}", "\n\n", "// perform the multi read request", "request", ":=", "&", "dosarpc", ".", "MultiReadRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "KeyValues", ":", "rpcFields", ",", "FieldsToRead", ":", "rpcMinimumFields", ",", "}", "\n\n", "response", ",", "err", ":=", "c", ".", "client", ".", "MultiRead", "(", "ctx", ",", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_MultiRead_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "rpcResults", ":=", "response", ".", "Results", "\n", "results", ":=", "make", "(", "[", "]", "*", "dosa", ".", "FieldValuesOrError", ",", "len", "(", "rpcResults", ")", ")", "\n", "for", "i", ",", "rpcResult", ":=", "range", "rpcResults", "{", "results", "[", "i", "]", "=", "&", "dosa", ".", "FieldValuesOrError", "{", "Values", ":", "make", "(", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", ",", "Error", ":", "nil", "}", "\n", "for", "name", ",", "value", ":=", "range", "rpcResult", ".", "EntityValues", "{", "for", "_", ",", "col", ":=", "range", "ei", ".", "Def", ".", "Columns", "{", "if", "col", ".", "Name", "==", "name", "{", "results", "[", "i", "]", ".", "Values", "[", "name", "]", "=", "RawValueAsInterface", "(", "*", "value", ".", "ElemValue", ",", "col", ".", "Type", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "rpcResult", ".", "Error", "!=", "nil", "{", "results", "[", "i", "]", ".", "Error", "=", "wrapIDLError", "(", "rpcResult", ".", "Error", ")", "\n", "}", "\n", "}", "\n\n", "return", "results", ",", "nil", "\n", "}" ]
// MultiRead reads multiple entities at one time
[ "MultiRead", "reads", "multiple", "entities", "at", "one", "time" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L290-L345
4,263
uber-go/dosa
connectors/yarpc/yarpc.go
Remove
func (c *Connector) Remove(ctx context.Context, ei *dosa.EntityInfo, keys map[string]dosa.FieldValue) error { // convert the key values from interface{} to RPC's Value rpcFields, err := keyValuesToRPCValues(keys) if err != nil { return err } // perform the remove request removeRequest := &dosarpc.RemoveRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: rpcFields, } err = c.client.Remove(ctx, removeRequest, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_Remove_Helper.IsException(err) { return errors.Wrap(err, "failed to Remove due to network issue") } return errors.Wrap(err, "failed to Remove") } return nil }
go
func (c *Connector) Remove(ctx context.Context, ei *dosa.EntityInfo, keys map[string]dosa.FieldValue) error { // convert the key values from interface{} to RPC's Value rpcFields, err := keyValuesToRPCValues(keys) if err != nil { return err } // perform the remove request removeRequest := &dosarpc.RemoveRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: rpcFields, } err = c.client.Remove(ctx, removeRequest, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_Remove_Helper.IsException(err) { return errors.Wrap(err, "failed to Remove due to network issue") } return errors.Wrap(err, "failed to Remove") } return nil }
[ "func", "(", "c", "*", "Connector", ")", "Remove", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "keys", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "error", "{", "// convert the key values from interface{} to RPC's Value", "rpcFields", ",", "err", ":=", "keyValuesToRPCValues", "(", "keys", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// perform the remove request", "removeRequest", ":=", "&", "dosarpc", ".", "RemoveRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "KeyValues", ":", "rpcFields", ",", "}", "\n\n", "err", "=", "c", ".", "client", ".", "Remove", "(", "ctx", ",", "removeRequest", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_Remove_Helper", ".", "IsException", "(", "err", ")", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Remove marshals a request to the YARPC remove call
[ "Remove", "marshals", "a", "request", "to", "the", "YARPC", "remove", "call" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L348-L370
4,264
uber-go/dosa
connectors/yarpc/yarpc.go
MultiRemove
func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiKeys []map[string]dosa.FieldValue) ([]error, error) { keyValues, err := multiKeyValuesToRPCValues(multiKeys) if err != nil { return nil, err } // perform the multi remove request request := &dosarpc.MultiRemoveRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: keyValues, } response, err := c.client.MultiRemove(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_MultiRemove_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to MultiRemove due to network issue") } return nil, errors.Wrap(err, "failed to MultiRemove") } rpcErrors := response.Errors results := make([]error, len(rpcErrors)) for i, rpcError := range rpcErrors { if rpcError != nil { results[i] = wrapIDLError(rpcError) } } return results, nil }
go
func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiKeys []map[string]dosa.FieldValue) ([]error, error) { keyValues, err := multiKeyValuesToRPCValues(multiKeys) if err != nil { return nil, err } // perform the multi remove request request := &dosarpc.MultiRemoveRequest{ Ref: entityInfoToSchemaRef(ei), KeyValues: keyValues, } response, err := c.client.MultiRemove(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_MultiRemove_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to MultiRemove due to network issue") } return nil, errors.Wrap(err, "failed to MultiRemove") } rpcErrors := response.Errors results := make([]error, len(rpcErrors)) for i, rpcError := range rpcErrors { if rpcError != nil { results[i] = wrapIDLError(rpcError) } } return results, nil }
[ "func", "(", "c", "*", "Connector", ")", "MultiRemove", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "multiKeys", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "(", "[", "]", "error", ",", "error", ")", "{", "keyValues", ",", "err", ":=", "multiKeyValuesToRPCValues", "(", "multiKeys", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// perform the multi remove request", "request", ":=", "&", "dosarpc", ".", "MultiRemoveRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "KeyValues", ":", "keyValues", ",", "}", "\n\n", "response", ",", "err", ":=", "c", ".", "client", ".", "MultiRemove", "(", "ctx", ",", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_MultiRemove_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "rpcErrors", ":=", "response", ".", "Errors", "\n", "results", ":=", "make", "(", "[", "]", "error", ",", "len", "(", "rpcErrors", ")", ")", "\n", "for", "i", ",", "rpcError", ":=", "range", "rpcErrors", "{", "if", "rpcError", "!=", "nil", "{", "results", "[", "i", "]", "=", "wrapIDLError", "(", "rpcError", ")", "\n", "}", "\n", "}", "\n\n", "return", "results", ",", "nil", "\n", "}" ]
// MultiRemove is not yet implemented
[ "MultiRemove", "is", "not", "yet", "implemented" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L373-L403
4,265
uber-go/dosa
connectors/yarpc/yarpc.go
Range
func (c *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { limit32 := int32(limit) rpcMinimumFields := makeRPCminimumFields(minimumFields) rpcConditions, err := createRPCConditions(columnConditions) if err != nil { return nil, "", errors.Wrap(err, "failed to Range: invalid column conditions") } rangeRequest := dosarpc.RangeRequest{ Ref: entityInfoToSchemaRef(ei), Token: &token, Limit: &limit32, Conditions: rpcConditions, FieldsToRead: rpcMinimumFields, } response, err := c.client.Range(ctx, &rangeRequest, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_Range_Helper.IsException(err) { return nil, "", errors.Wrap(err, "failed to Range due to network issue") } return nil, "", errors.Wrap(err, "failed to Range") } results := make([]map[string]dosa.FieldValue, len(response.Entities)) for idx, entity := range response.Entities { results[idx] = decodeResults(ei, entity) } return results, *response.NextToken, nil }
go
func (c *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { limit32 := int32(limit) rpcMinimumFields := makeRPCminimumFields(minimumFields) rpcConditions, err := createRPCConditions(columnConditions) if err != nil { return nil, "", errors.Wrap(err, "failed to Range: invalid column conditions") } rangeRequest := dosarpc.RangeRequest{ Ref: entityInfoToSchemaRef(ei), Token: &token, Limit: &limit32, Conditions: rpcConditions, FieldsToRead: rpcMinimumFields, } response, err := c.client.Range(ctx, &rangeRequest, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_Range_Helper.IsException(err) { return nil, "", errors.Wrap(err, "failed to Range due to network issue") } return nil, "", errors.Wrap(err, "failed to Range") } results := make([]map[string]dosa.FieldValue, len(response.Entities)) for idx, entity := range response.Entities { results[idx] = decodeResults(ei, entity) } return results, *response.NextToken, nil }
[ "func", "(", "c", "*", "Connector", ")", "Range", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "columnConditions", "map", "[", "string", "]", "[", "]", "*", "dosa", ".", "Condition", ",", "minimumFields", "[", "]", "string", ",", "token", "string", ",", "limit", "int", ")", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "string", ",", "error", ")", "{", "limit32", ":=", "int32", "(", "limit", ")", "\n", "rpcMinimumFields", ":=", "makeRPCminimumFields", "(", "minimumFields", ")", "\n", "rpcConditions", ",", "err", ":=", "createRPCConditions", "(", "columnConditions", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "rangeRequest", ":=", "dosarpc", ".", "RangeRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "Token", ":", "&", "token", ",", "Limit", ":", "&", "limit32", ",", "Conditions", ":", "rpcConditions", ",", "FieldsToRead", ":", "rpcMinimumFields", ",", "}", "\n", "response", ",", "err", ":=", "c", ".", "client", ".", "Range", "(", "ctx", ",", "&", "rangeRequest", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_Range_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "results", ":=", "make", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "len", "(", "response", ".", "Entities", ")", ")", "\n", "for", "idx", ",", "entity", ":=", "range", "response", ".", "Entities", "{", "results", "[", "idx", "]", "=", "decodeResults", "(", "ei", ",", "entity", ")", "\n", "}", "\n", "return", "results", ",", "*", "response", ".", "NextToken", ",", "nil", "\n", "}" ]
// Range does a scan across a range
[ "Range", "does", "a", "scan", "across", "a", "range" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L427-L454
4,266
uber-go/dosa
connectors/yarpc/yarpc.go
Scan
func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { limit32 := int32(limit) rpcMinimumFields := makeRPCminimumFields(minimumFields) scanRequest := dosarpc.ScanRequest{ Ref: entityInfoToSchemaRef(ei), Token: &token, Limit: &limit32, FieldsToRead: rpcMinimumFields, } response, err := c.client.Scan(ctx, &scanRequest, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_Scan_Helper.IsException(err) { return nil, "", errors.Wrap(err, "failed to Scan due to network issue") } return nil, "", errors.Wrap(err, "failed to Scan") } results := make([]map[string]dosa.FieldValue, len(response.Entities)) for idx, entity := range response.Entities { results[idx] = decodeResults(ei, entity) } return results, *response.NextToken, nil }
go
func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { limit32 := int32(limit) rpcMinimumFields := makeRPCminimumFields(minimumFields) scanRequest := dosarpc.ScanRequest{ Ref: entityInfoToSchemaRef(ei), Token: &token, Limit: &limit32, FieldsToRead: rpcMinimumFields, } response, err := c.client.Scan(ctx, &scanRequest, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_Scan_Helper.IsException(err) { return nil, "", errors.Wrap(err, "failed to Scan due to network issue") } return nil, "", errors.Wrap(err, "failed to Scan") } results := make([]map[string]dosa.FieldValue, len(response.Entities)) for idx, entity := range response.Entities { results[idx] = decodeResults(ei, entity) } return results, *response.NextToken, nil }
[ "func", "(", "c", "*", "Connector", ")", "Scan", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "minimumFields", "[", "]", "string", ",", "token", "string", ",", "limit", "int", ")", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "string", ",", "error", ")", "{", "limit32", ":=", "int32", "(", "limit", ")", "\n", "rpcMinimumFields", ":=", "makeRPCminimumFields", "(", "minimumFields", ")", "\n", "scanRequest", ":=", "dosarpc", ".", "ScanRequest", "{", "Ref", ":", "entityInfoToSchemaRef", "(", "ei", ")", ",", "Token", ":", "&", "token", ",", "Limit", ":", "&", "limit32", ",", "FieldsToRead", ":", "rpcMinimumFields", ",", "}", "\n", "response", ",", "err", ":=", "c", ".", "client", ".", "Scan", "(", "ctx", ",", "&", "scanRequest", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_Scan_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "results", ":=", "make", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "len", "(", "response", ".", "Entities", ")", ")", "\n", "for", "idx", ",", "entity", ":=", "range", "response", ".", "Entities", "{", "results", "[", "idx", "]", "=", "decodeResults", "(", "ei", ",", "entity", ")", "\n", "}", "\n", "return", "results", ",", "*", "response", ".", "NextToken", ",", "nil", "\n", "}" ]
// Scan marshals a scan request into YARPC
[ "Scan", "marshals", "a", "scan", "request", "into", "YARPC" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L481-L503
4,267
uber-go/dosa
connectors/yarpc/yarpc.go
CheckSchema
func (c *Connector) CheckSchema(ctx context.Context, scope, namePrefix string, eds []*dosa.EntityDefinition) (int32, error) { // convert the client EntityDefinition to the RPC EntityDefinition rpcEntityDefinition := EntityDefsToThrift(eds) csr := dosarpc.CheckSchemaRequest{ EntityDefs: rpcEntityDefinition, Scope: &scope, NamePrefix: &namePrefix, } response, err := c.client.CheckSchema(ctx, &csr, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_CheckSchema_Helper.IsException(err) { return dosa.InvalidVersion, errors.Wrap(err, "failed to CheckSchema due to network issue") } return dosa.InvalidVersion, wrapError(err, "failed to CheckSchema", scope) } return *response.Version, nil }
go
func (c *Connector) CheckSchema(ctx context.Context, scope, namePrefix string, eds []*dosa.EntityDefinition) (int32, error) { // convert the client EntityDefinition to the RPC EntityDefinition rpcEntityDefinition := EntityDefsToThrift(eds) csr := dosarpc.CheckSchemaRequest{ EntityDefs: rpcEntityDefinition, Scope: &scope, NamePrefix: &namePrefix, } response, err := c.client.CheckSchema(ctx, &csr, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_CheckSchema_Helper.IsException(err) { return dosa.InvalidVersion, errors.Wrap(err, "failed to CheckSchema due to network issue") } return dosa.InvalidVersion, wrapError(err, "failed to CheckSchema", scope) } return *response.Version, nil }
[ "func", "(", "c", "*", "Connector", ")", "CheckSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "eds", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "int32", ",", "error", ")", "{", "// convert the client EntityDefinition to the RPC EntityDefinition", "rpcEntityDefinition", ":=", "EntityDefsToThrift", "(", "eds", ")", "\n", "csr", ":=", "dosarpc", ".", "CheckSchemaRequest", "{", "EntityDefs", ":", "rpcEntityDefinition", ",", "Scope", ":", "&", "scope", ",", "NamePrefix", ":", "&", "namePrefix", ",", "}", "\n", "response", ",", "err", ":=", "c", ".", "client", ".", "CheckSchema", "(", "ctx", ",", "&", "csr", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_CheckSchema_Helper", ".", "IsException", "(", "err", ")", "{", "return", "dosa", ".", "InvalidVersion", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "dosa", ".", "InvalidVersion", ",", "wrapError", "(", "err", ",", "\"", "\"", ",", "scope", ")", "\n", "}", "\n\n", "return", "*", "response", ".", "Version", ",", "nil", "\n", "}" ]
// CheckSchema is one way to register a set of entities. This can be further validated by // a schema service downstream.
[ "CheckSchema", "is", "one", "way", "to", "register", "a", "set", "of", "entities", ".", "This", "can", "be", "further", "validated", "by", "a", "schema", "service", "downstream", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L507-L525
4,268
uber-go/dosa
connectors/yarpc/yarpc.go
UpsertSchema
func (c *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, eds []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { rpcEds := EntityDefsToThrift(eds) request := &dosarpc.UpsertSchemaRequest{ Scope: &scope, NamePrefix: &namePrefix, EntityDefs: rpcEds, } response, err := c.client.UpsertSchema(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_UpsertSchema_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to UpsertSchema due to network issue") } return nil, wrapError(err, "failed to UpsertSchema", scope) } status := "" if response.Status != nil { status = *response.Status } if response.Version == nil { return nil, errors.New("failed to UpsertSchema: server returns version nil") } return &dosa.SchemaStatus{ Version: *response.Version, Status: status, }, nil }
go
func (c *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, eds []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { rpcEds := EntityDefsToThrift(eds) request := &dosarpc.UpsertSchemaRequest{ Scope: &scope, NamePrefix: &namePrefix, EntityDefs: rpcEds, } response, err := c.client.UpsertSchema(ctx, request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_UpsertSchema_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to UpsertSchema due to network issue") } return nil, wrapError(err, "failed to UpsertSchema", scope) } status := "" if response.Status != nil { status = *response.Status } if response.Version == nil { return nil, errors.New("failed to UpsertSchema: server returns version nil") } return &dosa.SchemaStatus{ Version: *response.Version, Status: status, }, nil }
[ "func", "(", "c", "*", "Connector", ")", "UpsertSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "eds", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "rpcEds", ":=", "EntityDefsToThrift", "(", "eds", ")", "\n", "request", ":=", "&", "dosarpc", ".", "UpsertSchemaRequest", "{", "Scope", ":", "&", "scope", ",", "NamePrefix", ":", "&", "namePrefix", ",", "EntityDefs", ":", "rpcEds", ",", "}", "\n\n", "response", ",", "err", ":=", "c", ".", "client", ".", "UpsertSchema", "(", "ctx", ",", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_UpsertSchema_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", ",", "wrapError", "(", "err", ",", "\"", "\"", ",", "scope", ")", "\n", "}", "\n\n", "status", ":=", "\"", "\"", "\n", "if", "response", ".", "Status", "!=", "nil", "{", "status", "=", "*", "response", ".", "Status", "\n", "}", "\n\n", "if", "response", ".", "Version", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "&", "dosa", ".", "SchemaStatus", "{", "Version", ":", "*", "response", ".", "Version", ",", "Status", ":", "status", ",", "}", ",", "nil", "\n", "}" ]
// UpsertSchema upserts the schema through RPC
[ "UpsertSchema", "upserts", "the", "schema", "through", "RPC" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L550-L579
4,269
uber-go/dosa
connectors/yarpc/yarpc.go
CheckSchemaStatus
func (c *Connector) CheckSchemaStatus(ctx context.Context, scope, namePrefix string, version int32) (*dosa.SchemaStatus, error) { request := dosarpc.CheckSchemaStatusRequest{Scope: &scope, NamePrefix: &namePrefix, Version: &version} response, err := c.client.CheckSchemaStatus(ctx, &request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_CheckSchemaStatus_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to CheckSchemaStatus due to network issue") } return nil, wrapError(err, "failed to CheckSchemaStatus", scope) } status := "" if response.Status != nil { status = *response.Status } if response.Version == nil { return nil, errors.New("failed to ChecksShemaStatus: server returns version nil") } return &dosa.SchemaStatus{ Version: *response.Version, Status: status, }, nil }
go
func (c *Connector) CheckSchemaStatus(ctx context.Context, scope, namePrefix string, version int32) (*dosa.SchemaStatus, error) { request := dosarpc.CheckSchemaStatusRequest{Scope: &scope, NamePrefix: &namePrefix, Version: &version} response, err := c.client.CheckSchemaStatus(ctx, &request, getHeaders(c.headers)...) if err != nil { if !dosarpc.Dosa_CheckSchemaStatus_Helper.IsException(err) { return nil, errors.Wrap(err, "failed to CheckSchemaStatus due to network issue") } return nil, wrapError(err, "failed to CheckSchemaStatus", scope) } status := "" if response.Status != nil { status = *response.Status } if response.Version == nil { return nil, errors.New("failed to ChecksShemaStatus: server returns version nil") } return &dosa.SchemaStatus{ Version: *response.Version, Status: status, }, nil }
[ "func", "(", "c", "*", "Connector", ")", "CheckSchemaStatus", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "version", "int32", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "request", ":=", "dosarpc", ".", "CheckSchemaStatusRequest", "{", "Scope", ":", "&", "scope", ",", "NamePrefix", ":", "&", "namePrefix", ",", "Version", ":", "&", "version", "}", "\n", "response", ",", "err", ":=", "c", ".", "client", ".", "CheckSchemaStatus", "(", "ctx", ",", "&", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", "\n\n", "if", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_CheckSchemaStatus_Helper", ".", "IsException", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", ",", "wrapError", "(", "err", ",", "\"", "\"", ",", "scope", ")", "\n", "}", "\n\n", "status", ":=", "\"", "\"", "\n", "if", "response", ".", "Status", "!=", "nil", "{", "status", "=", "*", "response", ".", "Status", "\n", "}", "\n\n", "if", "response", ".", "Version", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "&", "dosa", ".", "SchemaStatus", "{", "Version", ":", "*", "response", ".", "Version", ",", "Status", ":", "status", ",", "}", ",", "nil", "\n", "}" ]
// CheckSchemaStatus checks the status of specific version of schema
[ "CheckSchemaStatus", "checks", "the", "status", "of", "specific", "version", "of", "schema" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L582-L607
4,270
uber-go/dosa
connectors/yarpc/yarpc.go
CreateScope
func (c *Connector) CreateScope(ctx context.Context, md *dosa.ScopeMetadata) error { bytes, err := json.Marshal(*md) if err != nil { return errors.Wrap(err, "could not encode metadata into JSON") } mds := string(bytes) request := &dosarpc.CreateScopeRequest{ Name: &(md.Name), Requester: &(md.Creator), Metadata: &mds, } if err = c.client.CreateScope(ctx, request, getHeaders(c.headers)...); err != nil { if !dosarpc.Dosa_CreateScope_Helper.IsException(err) { return errors.Wrap(err, "failed to CreateScope due to network issue") } return errors.Wrap(err, "failed to CreateScope") } return nil }
go
func (c *Connector) CreateScope(ctx context.Context, md *dosa.ScopeMetadata) error { bytes, err := json.Marshal(*md) if err != nil { return errors.Wrap(err, "could not encode metadata into JSON") } mds := string(bytes) request := &dosarpc.CreateScopeRequest{ Name: &(md.Name), Requester: &(md.Creator), Metadata: &mds, } if err = c.client.CreateScope(ctx, request, getHeaders(c.headers)...); err != nil { if !dosarpc.Dosa_CreateScope_Helper.IsException(err) { return errors.Wrap(err, "failed to CreateScope due to network issue") } return errors.Wrap(err, "failed to CreateScope") } return nil }
[ "func", "(", "c", "*", "Connector", ")", "CreateScope", "(", "ctx", "context", ".", "Context", ",", "md", "*", "dosa", ".", "ScopeMetadata", ")", "error", "{", "bytes", ",", "err", ":=", "json", ".", "Marshal", "(", "*", "md", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "mds", ":=", "string", "(", "bytes", ")", "\n\n", "request", ":=", "&", "dosarpc", ".", "CreateScopeRequest", "{", "Name", ":", "&", "(", "md", ".", "Name", ")", ",", "Requester", ":", "&", "(", "md", ".", "Creator", ")", ",", "Metadata", ":", "&", "mds", ",", "}", "\n\n", "if", "err", "=", "c", ".", "client", ".", "CreateScope", "(", "ctx", ",", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", ";", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_CreateScope_Helper", ".", "IsException", "(", "err", ")", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// CreateScope creates the scope specified
[ "CreateScope", "creates", "the", "scope", "specified" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L617-L639
4,271
uber-go/dosa
connectors/yarpc/yarpc.go
TruncateScope
func (c *Connector) TruncateScope(ctx context.Context, scope string) error { // A better authn story is needed -- an evildoer could just craft a request with a // bogus owner name and send it directly, bypassing this client. request := &dosarpc.TruncateScopeRequest{ Name: &scope, Requester: dosa.GetUsername(), } if err := c.client.TruncateScope(ctx, request, getHeaders(c.headers)...); err != nil { if !dosarpc.Dosa_TruncateScope_Helper.IsException(err) { return errors.Wrap(err, "failed to TruncateScope due to network issue") } return errors.Wrap(err, "failed to TruncateScope") } return nil }
go
func (c *Connector) TruncateScope(ctx context.Context, scope string) error { // A better authn story is needed -- an evildoer could just craft a request with a // bogus owner name and send it directly, bypassing this client. request := &dosarpc.TruncateScopeRequest{ Name: &scope, Requester: dosa.GetUsername(), } if err := c.client.TruncateScope(ctx, request, getHeaders(c.headers)...); err != nil { if !dosarpc.Dosa_TruncateScope_Helper.IsException(err) { return errors.Wrap(err, "failed to TruncateScope due to network issue") } return errors.Wrap(err, "failed to TruncateScope") } return nil }
[ "func", "(", "c", "*", "Connector", ")", "TruncateScope", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "error", "{", "// A better authn story is needed -- an evildoer could just craft a request with a", "// bogus owner name and send it directly, bypassing this client.", "request", ":=", "&", "dosarpc", ".", "TruncateScopeRequest", "{", "Name", ":", "&", "scope", ",", "Requester", ":", "dosa", ".", "GetUsername", "(", ")", ",", "}", "\n\n", "if", "err", ":=", "c", ".", "client", ".", "TruncateScope", "(", "ctx", ",", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", ";", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_TruncateScope_Helper", ".", "IsException", "(", "err", ")", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// TruncateScope truncates all data in the scope specified
[ "TruncateScope", "truncates", "all", "data", "in", "the", "scope", "specified" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L642-L659
4,272
uber-go/dosa
connectors/yarpc/yarpc.go
DropScope
func (c *Connector) DropScope(ctx context.Context, scope string) error { // A better authn story is needed -- an evildoer could just craft a request with a // bogus owner name and send it directly, bypassing this client. request := &dosarpc.DropScopeRequest{ Name: &scope, Requester: dosa.GetUsername(), } if err := c.client.DropScope(ctx, request, getHeaders(c.headers)...); err != nil { if !dosarpc.Dosa_DropScope_Helper.IsException(err) { return errors.Wrap(err, "failed to DropScope due to network issue") } return errors.Wrap(err, "failed to DropScope") } return nil }
go
func (c *Connector) DropScope(ctx context.Context, scope string) error { // A better authn story is needed -- an evildoer could just craft a request with a // bogus owner name and send it directly, bypassing this client. request := &dosarpc.DropScopeRequest{ Name: &scope, Requester: dosa.GetUsername(), } if err := c.client.DropScope(ctx, request, getHeaders(c.headers)...); err != nil { if !dosarpc.Dosa_DropScope_Helper.IsException(err) { return errors.Wrap(err, "failed to DropScope due to network issue") } return errors.Wrap(err, "failed to DropScope") } return nil }
[ "func", "(", "c", "*", "Connector", ")", "DropScope", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "error", "{", "// A better authn story is needed -- an evildoer could just craft a request with a", "// bogus owner name and send it directly, bypassing this client.", "request", ":=", "&", "dosarpc", ".", "DropScopeRequest", "{", "Name", ":", "&", "scope", ",", "Requester", ":", "dosa", ".", "GetUsername", "(", ")", ",", "}", "\n\n", "if", "err", ":=", "c", ".", "client", ".", "DropScope", "(", "ctx", ",", "request", ",", "getHeaders", "(", "c", ".", "headers", ")", "...", ")", ";", "err", "!=", "nil", "{", "if", "!", "dosarpc", ".", "Dosa_DropScope_Helper", ".", "IsException", "(", "err", ")", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// DropScope removes the scope specified
[ "DropScope", "removes", "the", "scope", "specified" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L662-L679
4,273
uber-go/dosa
connectors/yarpc/yarpc.go
ScopeExists
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { panic("not implemented") }
go
func (c *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { panic("not implemented") }
[ "func", "(", "c", "*", "Connector", ")", "ScopeExists", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "(", "bool", ",", "error", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}" ]
// ScopeExists is not implemented yet
[ "ScopeExists", "is", "not", "implemented", "yet" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/yarpc/yarpc.go#L682-L684
4,274
uber-go/dosa
connectors/random/random.go
Data
func Data(ei *dosa.EntityInfo, minimumFields []string) map[string]dosa.FieldValue { var result = map[string]dosa.FieldValue{} for _, field := range minimumFields { var v dosa.FieldValue cd := ei.Def.FindColumnDefinition(field) switch cd.Type { case dosa.Int32: v = dosa.FieldValue(rand.Int31()) case dosa.Int64: v = dosa.FieldValue(rand.Int63()) case dosa.Bool: if rand.Intn(2) == 0 { v = dosa.FieldValue(false) } else { v = dosa.FieldValue(true) } case dosa.Blob: // Blobs vary in length from 1 to maxBlobSize bytes blen := rand.Intn(maxBlobSize-1) + 1 blob := make([]byte, blen) for i := range blob { blob[i] = byte(rand.Intn(256)) } v = dosa.FieldValue(blob) case dosa.String: slen := rand.Intn(maxStringSize) + 1 v = dosa.FieldValue(randomString(slen)) case dosa.Double: v = dosa.FieldValue(rand.Float64()) case dosa.Timestamp: v = dosa.FieldValue(time.Unix(0, rand.Int63()/2)) case dosa.TUUID: v = dosa.FieldValue(dosa.NewUUID()) default: panic("invalid type " + cd.Type.String()) } result[field] = v } return result }
go
func Data(ei *dosa.EntityInfo, minimumFields []string) map[string]dosa.FieldValue { var result = map[string]dosa.FieldValue{} for _, field := range minimumFields { var v dosa.FieldValue cd := ei.Def.FindColumnDefinition(field) switch cd.Type { case dosa.Int32: v = dosa.FieldValue(rand.Int31()) case dosa.Int64: v = dosa.FieldValue(rand.Int63()) case dosa.Bool: if rand.Intn(2) == 0 { v = dosa.FieldValue(false) } else { v = dosa.FieldValue(true) } case dosa.Blob: // Blobs vary in length from 1 to maxBlobSize bytes blen := rand.Intn(maxBlobSize-1) + 1 blob := make([]byte, blen) for i := range blob { blob[i] = byte(rand.Intn(256)) } v = dosa.FieldValue(blob) case dosa.String: slen := rand.Intn(maxStringSize) + 1 v = dosa.FieldValue(randomString(slen)) case dosa.Double: v = dosa.FieldValue(rand.Float64()) case dosa.Timestamp: v = dosa.FieldValue(time.Unix(0, rand.Int63()/2)) case dosa.TUUID: v = dosa.FieldValue(dosa.NewUUID()) default: panic("invalid type " + cd.Type.String()) } result[field] = v } return result }
[ "func", "Data", "(", "ei", "*", "dosa", ".", "EntityInfo", ",", "minimumFields", "[", "]", "string", ")", "map", "[", "string", "]", "dosa", ".", "FieldValue", "{", "var", "result", "=", "map", "[", "string", "]", "dosa", ".", "FieldValue", "{", "}", "\n", "for", "_", ",", "field", ":=", "range", "minimumFields", "{", "var", "v", "dosa", ".", "FieldValue", "\n", "cd", ":=", "ei", ".", "Def", ".", "FindColumnDefinition", "(", "field", ")", "\n", "switch", "cd", ".", "Type", "{", "case", "dosa", ".", "Int32", ":", "v", "=", "dosa", ".", "FieldValue", "(", "rand", ".", "Int31", "(", ")", ")", "\n", "case", "dosa", ".", "Int64", ":", "v", "=", "dosa", ".", "FieldValue", "(", "rand", ".", "Int63", "(", ")", ")", "\n", "case", "dosa", ".", "Bool", ":", "if", "rand", ".", "Intn", "(", "2", ")", "==", "0", "{", "v", "=", "dosa", ".", "FieldValue", "(", "false", ")", "\n", "}", "else", "{", "v", "=", "dosa", ".", "FieldValue", "(", "true", ")", "\n", "}", "\n", "case", "dosa", ".", "Blob", ":", "// Blobs vary in length from 1 to maxBlobSize bytes", "blen", ":=", "rand", ".", "Intn", "(", "maxBlobSize", "-", "1", ")", "+", "1", "\n", "blob", ":=", "make", "(", "[", "]", "byte", ",", "blen", ")", "\n", "for", "i", ":=", "range", "blob", "{", "blob", "[", "i", "]", "=", "byte", "(", "rand", ".", "Intn", "(", "256", ")", ")", "\n", "}", "\n", "v", "=", "dosa", ".", "FieldValue", "(", "blob", ")", "\n", "case", "dosa", ".", "String", ":", "slen", ":=", "rand", ".", "Intn", "(", "maxStringSize", ")", "+", "1", "\n", "v", "=", "dosa", ".", "FieldValue", "(", "randomString", "(", "slen", ")", ")", "\n", "case", "dosa", ".", "Double", ":", "v", "=", "dosa", ".", "FieldValue", "(", "rand", ".", "Float64", "(", ")", ")", "\n", "case", "dosa", ".", "Timestamp", ":", "v", "=", "dosa", ".", "FieldValue", "(", "time", ".", "Unix", "(", "0", ",", "rand", ".", "Int63", "(", ")", "/", "2", ")", ")", "\n", "case", "dosa", ".", "TUUID", ":", "v", "=", "dosa", ".", "FieldValue", "(", "dosa", ".", "NewUUID", "(", ")", ")", "\n", "default", ":", "panic", "(", "\"", "\"", "+", "cd", ".", "Type", ".", "String", "(", ")", ")", "\n\n", "}", "\n", "result", "[", "field", "]", "=", "v", "\n", "}", "\n", "return", "result", "\n", "}" ]
// Data generates some random data. Because our test is blackbox in a different package, // we have to export this
[ "Data", "generates", "some", "random", "data", ".", "Because", "our", "test", "is", "blackbox", "in", "a", "different", "package", "we", "have", "to", "export", "this" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/random/random.go#L57-L97
4,275
uber-go/dosa
connectors/random/random.go
Read
func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue, minimumFields []string) (map[string]dosa.FieldValue, error) { return Data(ei, minimumFields), nil }
go
func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue, minimumFields []string) (map[string]dosa.FieldValue, error) { return Data(ei, minimumFields), nil }
[ "func", "(", "c", "*", "Connector", ")", "Read", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "minimumFields", "[", "]", "string", ")", "(", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "error", ")", "{", "return", "Data", "(", "ei", ",", "minimumFields", ")", ",", "nil", "\n", "}" ]
// Read always returns random data of the type specified
[ "Read", "always", "returns", "random", "data", "of", "the", "type", "specified" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/random/random.go#L100-L103
4,276
uber-go/dosa
connectors/random/random.go
MultiRead
func (c *Connector) MultiRead(ctx context.Context, ei *dosa.EntityInfo, values []map[string]dosa.FieldValue, minimumFields []string) ([]*dosa.FieldValuesOrError, error) { vals := make([]*dosa.FieldValuesOrError, len(values)) for inx := range values { vals[inx] = &dosa.FieldValuesOrError{ Values: Data(ei, minimumFields), } } return vals, nil }
go
func (c *Connector) MultiRead(ctx context.Context, ei *dosa.EntityInfo, values []map[string]dosa.FieldValue, minimumFields []string) ([]*dosa.FieldValuesOrError, error) { vals := make([]*dosa.FieldValuesOrError, len(values)) for inx := range values { vals[inx] = &dosa.FieldValuesOrError{ Values: Data(ei, minimumFields), } } return vals, nil }
[ "func", "(", "c", "*", "Connector", ")", "MultiRead", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "minimumFields", "[", "]", "string", ")", "(", "[", "]", "*", "dosa", ".", "FieldValuesOrError", ",", "error", ")", "{", "vals", ":=", "make", "(", "[", "]", "*", "dosa", ".", "FieldValuesOrError", ",", "len", "(", "values", ")", ")", "\n", "for", "inx", ":=", "range", "values", "{", "vals", "[", "inx", "]", "=", "&", "dosa", ".", "FieldValuesOrError", "{", "Values", ":", "Data", "(", "ei", ",", "minimumFields", ")", ",", "}", "\n", "}", "\n", "return", "vals", ",", "nil", "\n", "}" ]
// MultiRead returns a set of random data for each key you specify
[ "MultiRead", "returns", "a", "set", "of", "random", "data", "for", "each", "key", "you", "specify" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/random/random.go#L106-L114
4,277
uber-go/dosa
connectors/random/random.go
Range
func (c *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { if limit == dosa.AdaptiveRangeLimit { limit = defaultRangeLimit } vals := make([]map[string]dosa.FieldValue, limit) for inx := range vals { vals[inx] = Data(ei, minimumFields) } return vals, randomString(32), nil }
go
func (c *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { if limit == dosa.AdaptiveRangeLimit { limit = defaultRangeLimit } vals := make([]map[string]dosa.FieldValue, limit) for inx := range vals { vals[inx] = Data(ei, minimumFields) } return vals, randomString(32), nil }
[ "func", "(", "c", "*", "Connector", ")", "Range", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "columnConditions", "map", "[", "string", "]", "[", "]", "*", "dosa", ".", "Condition", ",", "minimumFields", "[", "]", "string", ",", "token", "string", ",", "limit", "int", ")", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "string", ",", "error", ")", "{", "if", "limit", "==", "dosa", ".", "AdaptiveRangeLimit", "{", "limit", "=", "defaultRangeLimit", "\n", "}", "\n", "vals", ":=", "make", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "limit", ")", "\n", "for", "inx", ":=", "range", "vals", "{", "vals", "[", "inx", "]", "=", "Data", "(", "ei", ",", "minimumFields", ")", "\n", "}", "\n", "return", "vals", ",", "randomString", "(", "32", ")", ",", "nil", "\n", "}" ]
// Range returns a random set of data, and a random continuation token
[ "Range", "returns", "a", "random", "set", "of", "data", "and", "a", "random", "continuation", "token" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/random/random.go#L151-L160
4,278
uber-go/dosa
connectors/random/random.go
Scan
func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { return c.Range(ctx, ei, map[string][]*dosa.Condition{}, minimumFields, token, limit) }
go
func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { return c.Range(ctx, ei, map[string][]*dosa.Condition{}, minimumFields, token, limit) }
[ "func", "(", "c", "*", "Connector", ")", "Scan", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "minimumFields", "[", "]", "string", ",", "token", "string", ",", "limit", "int", ")", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "string", ",", "error", ")", "{", "return", "c", ".", "Range", "(", "ctx", ",", "ei", ",", "map", "[", "string", "]", "[", "]", "*", "dosa", ".", "Condition", "{", "}", ",", "minimumFields", ",", "token", ",", "limit", ")", "\n", "}" ]
// Scan also returns a random set of data, like Range
[ "Scan", "also", "returns", "a", "random", "set", "of", "data", "like", "Range" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/random/random.go#L163-L165
4,279
uber-go/dosa
cmd/dosa/scopemd.go
Execute
func (c *ScopeList) Execute(args []string) error { client, err := c.makeClient() if err != nil { return errors.Wrap(err, "could not make client") } defer shutdownMDClient(client) var scopes []string if scopes, err = c.getScopes(client); err == nil { return err } for _, sp := range scopes { fmt.Println(sp) } return nil }
go
func (c *ScopeList) Execute(args []string) error { client, err := c.makeClient() if err != nil { return errors.Wrap(err, "could not make client") } defer shutdownMDClient(client) var scopes []string if scopes, err = c.getScopes(client); err == nil { return err } for _, sp := range scopes { fmt.Println(sp) } return nil }
[ "func", "(", "c", "*", "ScopeList", ")", "Execute", "(", "args", "[", "]", "string", ")", "error", "{", "client", ",", "err", ":=", "c", ".", "makeClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "defer", "shutdownMDClient", "(", "client", ")", "\n\n", "var", "scopes", "[", "]", "string", "\n", "if", "scopes", ",", "err", "=", "c", ".", "getScopes", "(", "client", ")", ";", "err", "==", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "sp", ":=", "range", "scopes", "{", "fmt", ".", "Println", "(", "sp", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Execute executes a scope list command
[ "Execute", "executes", "a", "scope", "list", "command" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/cmd/dosa/scopemd.go#L45-L60
4,280
uber-go/dosa
range.go
NewRangeOp
func NewRangeOp(object DomainObject) *RangeOp { rop := &RangeOp{ conditioner: conditioner{ object: object, conditions: map[string][]*Condition{}, }, } return rop }
go
func NewRangeOp(object DomainObject) *RangeOp { rop := &RangeOp{ conditioner: conditioner{ object: object, conditions: map[string][]*Condition{}, }, } return rop }
[ "func", "NewRangeOp", "(", "object", "DomainObject", ")", "*", "RangeOp", "{", "rop", ":=", "&", "RangeOp", "{", "conditioner", ":", "conditioner", "{", "object", ":", "object", ",", "conditions", ":", "map", "[", "string", "]", "[", "]", "*", "Condition", "{", "}", ",", "}", ",", "}", "\n", "return", "rop", "\n", "}" ]
// NewRangeOp returns a new RangeOp instance
[ "NewRangeOp", "returns", "a", "new", "RangeOp", "instance" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range.go#L46-L54
4,281
uber-go/dosa
range.go
Eq
func (r *RangeOp) Eq(fieldName string, value interface{}) *RangeOp { r.appendOp(Eq, fieldName, value) return r }
go
func (r *RangeOp) Eq(fieldName string, value interface{}) *RangeOp { r.appendOp(Eq, fieldName, value) return r }
[ "func", "(", "r", "*", "RangeOp", ")", "Eq", "(", "fieldName", "string", ",", "value", "interface", "{", "}", ")", "*", "RangeOp", "{", "r", ".", "appendOp", "(", "Eq", ",", "fieldName", ",", "value", ")", "\n", "return", "r", "\n", "}" ]
// Eq is used to express an equality constraint for a range query
[ "Eq", "is", "used", "to", "express", "an", "equality", "constraint", "for", "a", "range", "query" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range.go#L107-L110
4,282
uber-go/dosa
range.go
Gt
func (r *RangeOp) Gt(fieldName string, value interface{}) *RangeOp { r.appendOp(Gt, fieldName, value) return r }
go
func (r *RangeOp) Gt(fieldName string, value interface{}) *RangeOp { r.appendOp(Gt, fieldName, value) return r }
[ "func", "(", "r", "*", "RangeOp", ")", "Gt", "(", "fieldName", "string", ",", "value", "interface", "{", "}", ")", "*", "RangeOp", "{", "r", ".", "appendOp", "(", "Gt", ",", "fieldName", ",", "value", ")", "\n", "return", "r", "\n", "}" ]
// Gt is used to express an "greater than" constraint for a range query
[ "Gt", "is", "used", "to", "express", "an", "greater", "than", "constraint", "for", "a", "range", "query" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range.go#L113-L116
4,283
uber-go/dosa
range.go
GtOrEq
func (r *RangeOp) GtOrEq(fieldName string, value interface{}) *RangeOp { r.appendOp(GtOrEq, fieldName, value) return r }
go
func (r *RangeOp) GtOrEq(fieldName string, value interface{}) *RangeOp { r.appendOp(GtOrEq, fieldName, value) return r }
[ "func", "(", "r", "*", "RangeOp", ")", "GtOrEq", "(", "fieldName", "string", ",", "value", "interface", "{", "}", ")", "*", "RangeOp", "{", "r", ".", "appendOp", "(", "GtOrEq", ",", "fieldName", ",", "value", ")", "\n", "return", "r", "\n", "}" ]
// GtOrEq is used to express an "greater than or equal" constraint for a // range query
[ "GtOrEq", "is", "used", "to", "express", "an", "greater", "than", "or", "equal", "constraint", "for", "a", "range", "query" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range.go#L120-L123
4,284
uber-go/dosa
range.go
Lt
func (r *RangeOp) Lt(fieldName string, value interface{}) *RangeOp { r.appendOp(Lt, fieldName, value) return r }
go
func (r *RangeOp) Lt(fieldName string, value interface{}) *RangeOp { r.appendOp(Lt, fieldName, value) return r }
[ "func", "(", "r", "*", "RangeOp", ")", "Lt", "(", "fieldName", "string", ",", "value", "interface", "{", "}", ")", "*", "RangeOp", "{", "r", ".", "appendOp", "(", "Lt", ",", "fieldName", ",", "value", ")", "\n", "return", "r", "\n", "}" ]
// Lt is used to express a "less than" constraint for a range query
[ "Lt", "is", "used", "to", "express", "a", "less", "than", "constraint", "for", "a", "range", "query" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range.go#L126-L129
4,285
uber-go/dosa
range.go
LtOrEq
func (r *RangeOp) LtOrEq(fieldName string, value interface{}) *RangeOp { r.appendOp(LtOrEq, fieldName, value) return r }
go
func (r *RangeOp) LtOrEq(fieldName string, value interface{}) *RangeOp { r.appendOp(LtOrEq, fieldName, value) return r }
[ "func", "(", "r", "*", "RangeOp", ")", "LtOrEq", "(", "fieldName", "string", ",", "value", "interface", "{", "}", ")", "*", "RangeOp", "{", "r", ".", "appendOp", "(", "LtOrEq", ",", "fieldName", ",", "value", ")", "\n", "return", "r", "\n", "}" ]
// LtOrEq is used to express a "less than or equal" constraint for a // range query
[ "LtOrEq", "is", "used", "to", "express", "a", "less", "than", "or", "equal", "constraint", "for", "a", "range", "query" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range.go#L133-L136
4,286
uber-go/dosa
range.go
IndexFromConditions
func (ei *EntityInfo) IndexFromConditions(conditions map[string][]*Condition, searchIndexes bool) (name string, key *PrimaryKey, err error) { identityFunc := func(s string) string { return s } // see if we match the primary key for this table var baseTableError error if baseTableError = EnsureValidRangeConditions(ei.Def, ei.Def.Key, conditions, identityFunc); baseTableError == nil { return ei.Def.Name, ei.Def.Key, nil } if searchIndexes == false || len(ei.Def.Indexes) == 0 { return "", nil, baseTableError } // see if we match an index on this table var indexDef *IndexDefinition for name, indexDef = range ei.Def.Indexes { key = indexDef.Key // we check the range conditions before adding the uniqueness columns if err := EnsureValidRangeConditions(ei.Def, key, conditions, identityFunc); err == nil { return name, ei.Def.UniqueKey(key), nil } } // none of the indexes work, so fail return "", nil, errors.Wrapf(baseTableError, "No index matches specified conditions") }
go
func (ei *EntityInfo) IndexFromConditions(conditions map[string][]*Condition, searchIndexes bool) (name string, key *PrimaryKey, err error) { identityFunc := func(s string) string { return s } // see if we match the primary key for this table var baseTableError error if baseTableError = EnsureValidRangeConditions(ei.Def, ei.Def.Key, conditions, identityFunc); baseTableError == nil { return ei.Def.Name, ei.Def.Key, nil } if searchIndexes == false || len(ei.Def.Indexes) == 0 { return "", nil, baseTableError } // see if we match an index on this table var indexDef *IndexDefinition for name, indexDef = range ei.Def.Indexes { key = indexDef.Key // we check the range conditions before adding the uniqueness columns if err := EnsureValidRangeConditions(ei.Def, key, conditions, identityFunc); err == nil { return name, ei.Def.UniqueKey(key), nil } } // none of the indexes work, so fail return "", nil, errors.Wrapf(baseTableError, "No index matches specified conditions") }
[ "func", "(", "ei", "*", "EntityInfo", ")", "IndexFromConditions", "(", "conditions", "map", "[", "string", "]", "[", "]", "*", "Condition", ",", "searchIndexes", "bool", ")", "(", "name", "string", ",", "key", "*", "PrimaryKey", ",", "err", "error", ")", "{", "identityFunc", ":=", "func", "(", "s", "string", ")", "string", "{", "return", "s", "}", "\n", "// see if we match the primary key for this table", "var", "baseTableError", "error", "\n", "if", "baseTableError", "=", "EnsureValidRangeConditions", "(", "ei", ".", "Def", ",", "ei", ".", "Def", ".", "Key", ",", "conditions", ",", "identityFunc", ")", ";", "baseTableError", "==", "nil", "{", "return", "ei", ".", "Def", ".", "Name", ",", "ei", ".", "Def", ".", "Key", ",", "nil", "\n", "}", "\n", "if", "searchIndexes", "==", "false", "||", "len", "(", "ei", ".", "Def", ".", "Indexes", ")", "==", "0", "{", "return", "\"", "\"", ",", "nil", ",", "baseTableError", "\n", "}", "\n", "// see if we match an index on this table", "var", "indexDef", "*", "IndexDefinition", "\n", "for", "name", ",", "indexDef", "=", "range", "ei", ".", "Def", ".", "Indexes", "{", "key", "=", "indexDef", ".", "Key", "\n", "// we check the range conditions before adding the uniqueness columns", "if", "err", ":=", "EnsureValidRangeConditions", "(", "ei", ".", "Def", ",", "key", ",", "conditions", ",", "identityFunc", ")", ";", "err", "==", "nil", "{", "return", "name", ",", "ei", ".", "Def", ".", "UniqueKey", "(", "key", ")", ",", "nil", "\n", "}", "\n", "}", "\n", "// none of the indexes work, so fail", "return", "\"", "\"", ",", "nil", ",", "errors", ".", "Wrapf", "(", "baseTableError", ",", "\"", "\"", ")", "\n", "}" ]
// IndexFromConditions returns the name of the index or the base table to use, along with the key info // for that index. If no suitable index could be found, an error is returned
[ "IndexFromConditions", "returns", "the", "name", "of", "the", "index", "or", "the", "base", "table", "to", "use", "along", "with", "the", "key", "info", "for", "that", "index", ".", "If", "no", "suitable", "index", "could", "be", "found", "an", "error", "is", "returned" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/range.go#L150-L171
4,287
uber-go/dosa
cmd/dosa/read.go
Read
func (c *shellQueryClient) Read(ctx context.Context, ops []*queryObj, fields []string, limit int) ([]map[string]dosa.FieldValue, error) { // look up entity in the registry re, _ := c.registrar.Find(&dosa.Entity{}) // build arguments for read with expressions fvs, err := buildReadArgs(ops) if err != nil { return nil, err } // convert the field names to column names columns, err := re.ColumnNames(fields) if err != nil { return nil, err } res, err := c.connector.Read(ctx, re.EntityInfo(), fvs, columns) return convertColToField([]map[string]dosa.FieldValue{res}, re.Table().ColToField), err }
go
func (c *shellQueryClient) Read(ctx context.Context, ops []*queryObj, fields []string, limit int) ([]map[string]dosa.FieldValue, error) { // look up entity in the registry re, _ := c.registrar.Find(&dosa.Entity{}) // build arguments for read with expressions fvs, err := buildReadArgs(ops) if err != nil { return nil, err } // convert the field names to column names columns, err := re.ColumnNames(fields) if err != nil { return nil, err } res, err := c.connector.Read(ctx, re.EntityInfo(), fvs, columns) return convertColToField([]map[string]dosa.FieldValue{res}, re.Table().ColToField), err }
[ "func", "(", "c", "*", "shellQueryClient", ")", "Read", "(", "ctx", "context", ".", "Context", ",", "ops", "[", "]", "*", "queryObj", ",", "fields", "[", "]", "string", ",", "limit", "int", ")", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "error", ")", "{", "// look up entity in the registry", "re", ",", "_", ":=", "c", ".", "registrar", ".", "Find", "(", "&", "dosa", ".", "Entity", "{", "}", ")", "\n\n", "// build arguments for read with expressions", "fvs", ",", "err", ":=", "buildReadArgs", "(", "ops", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// convert the field names to column names", "columns", ",", "err", ":=", "re", ".", "ColumnNames", "(", "fields", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "res", ",", "err", ":=", "c", ".", "connector", ".", "Read", "(", "ctx", ",", "re", ".", "EntityInfo", "(", ")", ",", "fvs", ",", "columns", ")", "\n\n", "return", "convertColToField", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", "{", "res", "}", ",", "re", ".", "Table", "(", ")", ".", "ColToField", ")", ",", "err", "\n", "}" ]
// Read fetches a row by primary key.
[ "Read", "fetches", "a", "row", "by", "primary", "key", "." ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/cmd/dosa/read.go#L31-L50
4,288
uber-go/dosa
connectors/routing/connector.go
NewConnector
func NewConnector(cfg Config, connectorMap map[string]dosa.Connector) *Connector { return &Connector{ connectors: connectorMap, config: cfg, } }
go
func NewConnector(cfg Config, connectorMap map[string]dosa.Connector) *Connector { return &Connector{ connectors: connectorMap, config: cfg, } }
[ "func", "NewConnector", "(", "cfg", "Config", ",", "connectorMap", "map", "[", "string", "]", "dosa", ".", "Connector", ")", "*", "Connector", "{", "return", "&", "Connector", "{", "connectors", ":", "connectorMap", ",", "config", ":", "cfg", ",", "}", "\n", "}" ]
// NewConnector initializes the Connector // connectorMap has a key of connectorName, and the value is a dosa.connector instance
[ "NewConnector", "initializes", "the", "Connector", "connectorMap", "has", "a", "key", "of", "connectorName", "and", "the", "value", "is", "a", "dosa", ".", "connector", "instance" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L43-L48
4,289
uber-go/dosa
connectors/routing/connector.go
getConnector
func (rc *Connector) getConnector(scope, namePrefix string) (dosa.Connector, error) { router := rc.config.FindRouter(scope, namePrefix) c, ok := rc.connectors[router.Connector] if !ok { return nil, fmt.Errorf("can't find %q connector", router.Connector) } return c, nil }
go
func (rc *Connector) getConnector(scope, namePrefix string) (dosa.Connector, error) { router := rc.config.FindRouter(scope, namePrefix) c, ok := rc.connectors[router.Connector] if !ok { return nil, fmt.Errorf("can't find %q connector", router.Connector) } return c, nil }
[ "func", "(", "rc", "*", "Connector", ")", "getConnector", "(", "scope", ",", "namePrefix", "string", ")", "(", "dosa", ".", "Connector", ",", "error", ")", "{", "router", ":=", "rc", ".", "config", ".", "FindRouter", "(", "scope", ",", "namePrefix", ")", "\n\n", "c", ",", "ok", ":=", "rc", ".", "connectors", "[", "router", ".", "Connector", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "router", ".", "Connector", ")", "\n", "}", "\n\n", "return", "c", ",", "nil", "\n", "}" ]
// get connector by scope an namePrefix
[ "get", "connector", "by", "scope", "an", "namePrefix" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L51-L60
4,290
uber-go/dosa
connectors/routing/connector.go
CreateIfNotExists
func (rc *Connector) CreateIfNotExists(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { connector, err := rc.getConnector(ei.Ref.Scope, ei.Ref.NamePrefix) if err != nil { return err } return connector.CreateIfNotExists(ctx, ei, values) }
go
func (rc *Connector) CreateIfNotExists(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error { connector, err := rc.getConnector(ei.Ref.Scope, ei.Ref.NamePrefix) if err != nil { return err } return connector.CreateIfNotExists(ctx, ei, values) }
[ "func", "(", "rc", "*", "Connector", ")", "CreateIfNotExists", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "values", "map", "[", "string", "]", "dosa", ".", "FieldValue", ")", "error", "{", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "ei", ".", "Ref", ".", "Scope", ",", "ei", ".", "Ref", ".", "NamePrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "connector", ".", "CreateIfNotExists", "(", "ctx", ",", "ei", ",", "values", ")", "\n", "}" ]
// CreateIfNotExists selects corresponding connector
[ "CreateIfNotExists", "selects", "corresponding", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L63-L69
4,291
uber-go/dosa
connectors/routing/connector.go
RemoveRange
func (rc *Connector) RemoveRange(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition) error { connector, err := rc.getConnector(ei.Ref.Scope, ei.Ref.NamePrefix) if err != nil { return err } return connector.RemoveRange(ctx, ei, columnConditions) }
go
func (rc *Connector) RemoveRange(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition) error { connector, err := rc.getConnector(ei.Ref.Scope, ei.Ref.NamePrefix) if err != nil { return err } return connector.RemoveRange(ctx, ei, columnConditions) }
[ "func", "(", "rc", "*", "Connector", ")", "RemoveRange", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "columnConditions", "map", "[", "string", "]", "[", "]", "*", "dosa", ".", "Condition", ")", "error", "{", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "ei", ".", "Ref", ".", "Scope", ",", "ei", ".", "Ref", ".", "NamePrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "connector", ".", "RemoveRange", "(", "ctx", ",", "ei", ",", "columnConditions", ")", "\n", "}" ]
// RemoveRange selects corresponding connector
[ "RemoveRange", "selects", "corresponding", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L119-L125
4,292
uber-go/dosa
connectors/routing/connector.go
Range
func (rc *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { connector, err := rc.getConnector(ei.Ref.Scope, ei.Ref.NamePrefix) if err != nil { return nil, "", err } return connector.Range(ctx, ei, columnConditions, minimumFields, token, limit) }
go
func (rc *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) { connector, err := rc.getConnector(ei.Ref.Scope, ei.Ref.NamePrefix) if err != nil { return nil, "", err } return connector.Range(ctx, ei, columnConditions, minimumFields, token, limit) }
[ "func", "(", "rc", "*", "Connector", ")", "Range", "(", "ctx", "context", ".", "Context", ",", "ei", "*", "dosa", ".", "EntityInfo", ",", "columnConditions", "map", "[", "string", "]", "[", "]", "*", "dosa", ".", "Condition", ",", "minimumFields", "[", "]", "string", ",", "token", "string", ",", "limit", "int", ")", "(", "[", "]", "map", "[", "string", "]", "dosa", ".", "FieldValue", ",", "string", ",", "error", ")", "{", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "ei", ".", "Ref", ".", "Scope", ",", "ei", ".", "Ref", ".", "NamePrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "connector", ".", "Range", "(", "ctx", ",", "ei", ",", "columnConditions", ",", "minimumFields", ",", "token", ",", "limit", ")", "\n", "}" ]
// Range selects corresponding connector
[ "Range", "selects", "corresponding", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L137-L143
4,293
uber-go/dosa
connectors/routing/connector.go
UpsertSchema
func (rc *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return nil, err } return connector.UpsertSchema(ctx, scope, namePrefix, ed) }
go
func (rc *Connector) UpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (*dosa.SchemaStatus, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return nil, err } return connector.UpsertSchema(ctx, scope, namePrefix, ed) }
[ "func", "(", "rc", "*", "Connector", ")", "UpsertSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "ed", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "scope", ",", "namePrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "connector", ".", "UpsertSchema", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "ed", ")", "\n", "}" ]
// UpsertSchema calls selected connector
[ "UpsertSchema", "calls", "selected", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L164-L170
4,294
uber-go/dosa
connectors/routing/connector.go
CanUpsertSchema
func (rc *Connector) CanUpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return dosa.InvalidVersion, err } return connector.CanUpsertSchema(ctx, scope, namePrefix, ed) }
go
func (rc *Connector) CanUpsertSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return dosa.InvalidVersion, err } return connector.CanUpsertSchema(ctx, scope, namePrefix, ed) }
[ "func", "(", "rc", "*", "Connector", ")", "CanUpsertSchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", "string", ",", "ed", "[", "]", "*", "dosa", ".", "EntityDefinition", ")", "(", "int32", ",", "error", ")", "{", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "scope", ",", "namePrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "dosa", ".", "InvalidVersion", ",", "err", "\n", "}", "\n", "return", "connector", ".", "CanUpsertSchema", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "ed", ")", "\n", "}" ]
// CanUpsertSchema calls selected connector
[ "CanUpsertSchema", "calls", "selected", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L173-L179
4,295
uber-go/dosa
connectors/routing/connector.go
CheckSchemaStatus
func (rc *Connector) CheckSchemaStatus(ctx context.Context, scope string, namePrefix string, version int32) (*dosa.SchemaStatus, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return nil, err } return connector.CheckSchemaStatus(ctx, scope, namePrefix, version) }
go
func (rc *Connector) CheckSchemaStatus(ctx context.Context, scope string, namePrefix string, version int32) (*dosa.SchemaStatus, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return nil, err } return connector.CheckSchemaStatus(ctx, scope, namePrefix, version) }
[ "func", "(", "rc", "*", "Connector", ")", "CheckSchemaStatus", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ",", "namePrefix", "string", ",", "version", "int32", ")", "(", "*", "dosa", ".", "SchemaStatus", ",", "error", ")", "{", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "scope", ",", "namePrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "connector", ".", "CheckSchemaStatus", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "version", ")", "\n", "}" ]
// CheckSchemaStatus calls selected connector
[ "CheckSchemaStatus", "calls", "selected", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L182-L188
4,296
uber-go/dosa
connectors/routing/connector.go
GetEntitySchema
func (rc *Connector) GetEntitySchema(ctx context.Context, scope, namePrefix, entityName string, version int32) (*dosa.EntityDefinition, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return nil, err } return connector.GetEntitySchema(ctx, scope, namePrefix, entityName, version) }
go
func (rc *Connector) GetEntitySchema(ctx context.Context, scope, namePrefix, entityName string, version int32) (*dosa.EntityDefinition, error) { connector, err := rc.getConnector(scope, namePrefix) if err != nil { return nil, err } return connector.GetEntitySchema(ctx, scope, namePrefix, entityName, version) }
[ "func", "(", "rc", "*", "Connector", ")", "GetEntitySchema", "(", "ctx", "context", ".", "Context", ",", "scope", ",", "namePrefix", ",", "entityName", "string", ",", "version", "int32", ")", "(", "*", "dosa", ".", "EntityDefinition", ",", "error", ")", "{", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "scope", ",", "namePrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "connector", ".", "GetEntitySchema", "(", "ctx", ",", "scope", ",", "namePrefix", ",", "entityName", ",", "version", ")", "\n", "}" ]
// GetEntitySchema calls the selected connector
[ "GetEntitySchema", "calls", "the", "selected", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L191-L197
4,297
uber-go/dosa
connectors/routing/connector.go
CreateScope
func (rc *Connector) CreateScope(ctx context.Context, md *dosa.ScopeMetadata) error { // will fall to default connector connector, err := rc.getConnector(md.Name, "") if err != nil { return err } return connector.CreateScope(ctx, md) }
go
func (rc *Connector) CreateScope(ctx context.Context, md *dosa.ScopeMetadata) error { // will fall to default connector connector, err := rc.getConnector(md.Name, "") if err != nil { return err } return connector.CreateScope(ctx, md) }
[ "func", "(", "rc", "*", "Connector", ")", "CreateScope", "(", "ctx", "context", ".", "Context", ",", "md", "*", "dosa", ".", "ScopeMetadata", ")", "error", "{", "// will fall to default connector", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "md", ".", "Name", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "connector", ".", "CreateScope", "(", "ctx", ",", "md", ")", "\n", "}" ]
// CreateScope calls selected connector
[ "CreateScope", "calls", "selected", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L200-L207
4,298
uber-go/dosa
connectors/routing/connector.go
TruncateScope
func (rc *Connector) TruncateScope(ctx context.Context, scope string) error { // will fall to default connector connector, err := rc.getConnector(scope, "") if err != nil { return err } return connector.TruncateScope(ctx, scope) }
go
func (rc *Connector) TruncateScope(ctx context.Context, scope string) error { // will fall to default connector connector, err := rc.getConnector(scope, "") if err != nil { return err } return connector.TruncateScope(ctx, scope) }
[ "func", "(", "rc", "*", "Connector", ")", "TruncateScope", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "error", "{", "// will fall to default connector", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "scope", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "connector", ".", "TruncateScope", "(", "ctx", ",", "scope", ")", "\n", "}" ]
// TruncateScope calls selected connector
[ "TruncateScope", "calls", "selected", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L210-L217
4,299
uber-go/dosa
connectors/routing/connector.go
ScopeExists
func (rc *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { // will fall to default connector connector, err := rc.getConnector(scope, "") if err != nil { return false, err } return connector.ScopeExists(ctx, scope) }
go
func (rc *Connector) ScopeExists(ctx context.Context, scope string) (bool, error) { // will fall to default connector connector, err := rc.getConnector(scope, "") if err != nil { return false, err } return connector.ScopeExists(ctx, scope) }
[ "func", "(", "rc", "*", "Connector", ")", "ScopeExists", "(", "ctx", "context", ".", "Context", ",", "scope", "string", ")", "(", "bool", ",", "error", ")", "{", "// will fall to default connector", "connector", ",", "err", ":=", "rc", ".", "getConnector", "(", "scope", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "connector", ".", "ScopeExists", "(", "ctx", ",", "scope", ")", "\n", "}" ]
// ScopeExists calls selected connector
[ "ScopeExists", "calls", "selected", "connector" ]
18f7766015f97d726635fc75b21c93ec270e5ac5
https://github.com/uber-go/dosa/blob/18f7766015f97d726635fc75b21c93ec270e5ac5/connectors/routing/connector.go#L230-L237