repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | getEventsLimit | func (mc MongoClient) getEventsLimit(q bson.M, limit int) (me []models.Event, err error) {
s := mc.getSessionCopy()
defer s.Close()
// Check if limit is 0
if limit == 0 {
return []models.Event{}, nil
}
err = s.DB(mc.database.Name).C(db.EventsCollection).Find(q).Sort("-modified").Limit(limit).All(&me)
if err ... | go | func (mc MongoClient) getEventsLimit(q bson.M, limit int) (me []models.Event, err error) {
s := mc.getSessionCopy()
defer s.Close()
// Check if limit is 0
if limit == 0 {
return []models.Event{}, nil
}
err = s.DB(mc.database.Name).C(db.EventsCollection).Find(q).Sort("-modified").Limit(limit).All(&me)
if err ... | [
"func",
"(",
"mc",
"MongoClient",
")",
"getEventsLimit",
"(",
"q",
"bson",
".",
"M",
",",
"limit",
"int",
")",
"(",
"me",
"[",
"]",
"models",
".",
"Event",
",",
"err",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"de... | // Get events with a limit
// Sort the list before applying the limit so we can return the most recent events | [
"Get",
"events",
"with",
"a",
"limit",
"Sort",
"the",
"list",
"before",
"applying",
"the",
"limit",
"so",
"we",
"can",
"return",
"the",
"most",
"recent",
"events"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L215-L229 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | Readings | func (mc MongoClient) Readings() ([]contract.Reading, error) {
readings, err := mc.getReadings(nil)
if err != nil {
return []contract.Reading{}, err
}
mapped := make([]contract.Reading, 0)
for _, r := range readings {
mapped = append(mapped, r.ToContract())
}
return mapped, nil
} | go | func (mc MongoClient) Readings() ([]contract.Reading, error) {
readings, err := mc.getReadings(nil)
if err != nil {
return []contract.Reading{}, err
}
mapped := make([]contract.Reading, 0)
for _, r := range readings {
mapped = append(mapped, r.ToContract())
}
return mapped, nil
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"Readings",
"(",
")",
"(",
"[",
"]",
"contract",
".",
"Reading",
",",
"error",
")",
"{",
"readings",
",",
"err",
":=",
"mc",
".",
"getReadings",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Return a list of readings sorted by reading id | [
"Return",
"a",
"list",
"of",
"readings",
"sorted",
"by",
"reading",
"id"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L260-L271 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | AddReading | func (mc MongoClient) AddReading(r contract.Reading) (string, error) {
s := mc.getSessionCopy()
defer s.Close()
var mapped models.Reading
id, err := mapped.FromContract(r)
if err != nil {
return "", err
}
mapped.TimestampForAdd()
err = s.DB(mc.database.Name).C(db.ReadingsCollection).Insert(&mapped)
if err... | go | func (mc MongoClient) AddReading(r contract.Reading) (string, error) {
s := mc.getSessionCopy()
defer s.Close()
var mapped models.Reading
id, err := mapped.FromContract(r)
if err != nil {
return "", err
}
mapped.TimestampForAdd()
err = s.DB(mc.database.Name).C(db.ReadingsCollection).Insert(&mapped)
if err... | [
"func",
"(",
"mc",
"MongoClient",
")",
"AddReading",
"(",
"r",
"contract",
".",
"Reading",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"var",
"map... | // Post a new reading | [
"Post",
"a",
"new",
"reading"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L274-L291 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ReadingCount | func (mc MongoClient) ReadingCount() (int, error) {
s := mc.getSessionCopy()
defer s.Close()
count, err := s.DB(mc.database.Name).C(db.ReadingsCollection).Find(bson.M{}).Count()
if err != nil {
return 0, errorMap(err)
}
return count, nil
} | go | func (mc MongoClient) ReadingCount() (int, error) {
s := mc.getSessionCopy()
defer s.Close()
count, err := s.DB(mc.database.Name).C(db.ReadingsCollection).Find(bson.M{}).Count()
if err != nil {
return 0, errorMap(err)
}
return count, nil
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ReadingCount",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"count",
",",
"err",
":=",
"s",
".",
"DB",
... | // Get the count of readings in Mongo | [
"Get",
"the",
"count",
"of",
"readings",
"in",
"Mongo"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L335-L344 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ReadingsByValueDescriptor | func (mc MongoClient) ReadingsByValueDescriptor(name string, limit int) ([]contract.Reading, error) {
return mapReadings(mc.getReadingsLimit(bson.M{"name": name}, limit))
} | go | func (mc MongoClient) ReadingsByValueDescriptor(name string, limit int) ([]contract.Reading, error) {
return mapReadings(mc.getReadingsLimit(bson.M{"name": name}, limit))
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ReadingsByValueDescriptor",
"(",
"name",
"string",
",",
"limit",
"int",
")",
"(",
"[",
"]",
"contract",
".",
"Reading",
",",
"error",
")",
"{",
"return",
"mapReadings",
"(",
"mc",
".",
"getReadingsLimit",
"(",
"bson"... | // Return a list of readings for the given value descriptor
// Limit by the given limit | [
"Return",
"a",
"list",
"of",
"readings",
"for",
"the",
"given",
"value",
"descriptor",
"Limit",
"by",
"the",
"given",
"limit"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L360-L362 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ReadingsByValueDescriptorNames | func (mc MongoClient) ReadingsByValueDescriptorNames(names []string, limit int) ([]contract.Reading, error) {
return mapReadings(mc.getReadingsLimit(bson.M{"name": bson.M{"$in": names}}, limit))
} | go | func (mc MongoClient) ReadingsByValueDescriptorNames(names []string, limit int) ([]contract.Reading, error) {
return mapReadings(mc.getReadingsLimit(bson.M{"name": bson.M{"$in": names}}, limit))
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ReadingsByValueDescriptorNames",
"(",
"names",
"[",
"]",
"string",
",",
"limit",
"int",
")",
"(",
"[",
"]",
"contract",
".",
"Reading",
",",
"error",
")",
"{",
"return",
"mapReadings",
"(",
"mc",
".",
"getReadingsLim... | // Return a list of readings whose name is in the list of value descriptor names | [
"Return",
"a",
"list",
"of",
"readings",
"whose",
"name",
"is",
"in",
"the",
"list",
"of",
"value",
"descriptor",
"names"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L365-L367 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ReadingsByCreationTime | func (mc MongoClient) ReadingsByCreationTime(start, end int64, limit int) ([]contract.Reading, error) {
return mapReadings(mc.getReadingsLimit(bson.M{"created": bson.M{"$gte": start, "$lte": end}}, limit))
} | go | func (mc MongoClient) ReadingsByCreationTime(start, end int64, limit int) ([]contract.Reading, error) {
return mapReadings(mc.getReadingsLimit(bson.M{"created": bson.M{"$gte": start, "$lte": end}}, limit))
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ReadingsByCreationTime",
"(",
"start",
",",
"end",
"int64",
",",
"limit",
"int",
")",
"(",
"[",
"]",
"contract",
".",
"Reading",
",",
"error",
")",
"{",
"return",
"mapReadings",
"(",
"mc",
".",
"getReadingsLimit",
... | // Return a list of readings whose creation time is in-between start and end
// Limit by the limit parameter | [
"Return",
"a",
"list",
"of",
"readings",
"whose",
"creation",
"time",
"is",
"in",
"-",
"between",
"start",
"and",
"end",
"Limit",
"by",
"the",
"limit",
"parameter"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L371-L373 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | getReadingsLimit | func (mc MongoClient) getReadingsLimit(q bson.M, limit int) ([]models.Reading, error) {
s := mc.getSessionCopy()
defer s.Close()
// Check if limit is 0
if limit == 0 {
return []models.Reading{}, nil
}
var readings []models.Reading
if err := s.DB(mc.database.Name).C(db.ReadingsCollection).Find(q).Sort("-modif... | go | func (mc MongoClient) getReadingsLimit(q bson.M, limit int) ([]models.Reading, error) {
s := mc.getSessionCopy()
defer s.Close()
// Check if limit is 0
if limit == 0 {
return []models.Reading{}, nil
}
var readings []models.Reading
if err := s.DB(mc.database.Name).C(db.ReadingsCollection).Find(q).Sort("-modif... | [
"func",
"(",
"mc",
"MongoClient",
")",
"getReadingsLimit",
"(",
"q",
"bson",
".",
"M",
",",
"limit",
"int",
")",
"(",
"[",
"]",
"models",
".",
"Reading",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
... | // Return a list of readings that match.
// Sort the list before applying the limit so we can return the most recent readings | [
"Return",
"a",
"list",
"of",
"readings",
"that",
"match",
".",
"Sort",
"the",
"list",
"before",
"applying",
"the",
"limit",
"so",
"we",
"can",
"return",
"the",
"most",
"recent",
"readings"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L383-L397 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | getReading | func (mc MongoClient) getReading(q bson.M) (models.Reading, error) {
s := mc.getSessionCopy()
defer s.Close()
var res models.Reading
if err := s.DB(mc.database.Name).C(db.ReadingsCollection).Find(q).One(&res); err != nil {
return models.Reading{}, errorMap(err)
}
return res, nil
} | go | func (mc MongoClient) getReading(q bson.M) (models.Reading, error) {
s := mc.getSessionCopy()
defer s.Close()
var res models.Reading
if err := s.DB(mc.database.Name).C(db.ReadingsCollection).Find(q).One(&res); err != nil {
return models.Reading{}, errorMap(err)
}
return res, nil
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"getReading",
"(",
"q",
"bson",
".",
"M",
")",
"(",
"models",
".",
"Reading",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"va... | // Get a reading from the database with the passed query | [
"Get",
"a",
"reading",
"from",
"the",
"database",
"with",
"the",
"passed",
"query"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L412-L421 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | DeleteValueDescriptorById | func (mc MongoClient) DeleteValueDescriptorById(id string) error {
return mc.deleteById(db.ValueDescriptorCollection, id)
} | go | func (mc MongoClient) DeleteValueDescriptorById(id string) error {
return mc.deleteById(db.ValueDescriptorCollection, id)
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"DeleteValueDescriptorById",
"(",
"id",
"string",
")",
"error",
"{",
"return",
"mc",
".",
"deleteById",
"(",
"db",
".",
"ValueDescriptorCollection",
",",
"id",
")",
"\n",
"}"
] | // Delete the value descriptor based on the id
// Not found error if there isn't a value descriptor for the ID
// ValueDescriptorStillInUse if the value descriptor is still referenced by readings | [
"Delete",
"the",
"value",
"descriptor",
"based",
"on",
"the",
"id",
"Not",
"found",
"error",
"if",
"there",
"isn",
"t",
"a",
"value",
"descriptor",
"for",
"the",
"ID",
"ValueDescriptorStillInUse",
"if",
"the",
"value",
"descriptor",
"is",
"still",
"referenced"... | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L496-L498 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ValueDescriptorByName | func (mc MongoClient) ValueDescriptorByName(name string) (contract.ValueDescriptor, error) {
mvd, err := mc.getValueDescriptor(bson.M{"name": name})
if err != nil {
return contract.ValueDescriptor{}, err
}
return mvd.ToContract(), nil
} | go | func (mc MongoClient) ValueDescriptorByName(name string) (contract.ValueDescriptor, error) {
mvd, err := mc.getValueDescriptor(bson.M{"name": name})
if err != nil {
return contract.ValueDescriptor{}, err
}
return mvd.ToContract(), nil
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ValueDescriptorByName",
"(",
"name",
"string",
")",
"(",
"contract",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"mvd",
",",
"err",
":=",
"mc",
".",
"getValueDescriptor",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",... | // Return a value descriptor based on the name
// Can return null if no value descriptor is found | [
"Return",
"a",
"value",
"descriptor",
"based",
"on",
"the",
"name",
"Can",
"return",
"null",
"if",
"no",
"value",
"descriptor",
"is",
"found"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L502-L508 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ValueDescriptorsByName | func (mc MongoClient) ValueDescriptorsByName(names []string) ([]contract.ValueDescriptor, error) {
vList := make([]contract.ValueDescriptor, 0)
for _, name := range names {
v, err := mc.ValueDescriptorByName(name)
if err != nil && err != db.ErrNotFound {
return []contract.ValueDescriptor{}, err
}
if err ==... | go | func (mc MongoClient) ValueDescriptorsByName(names []string) ([]contract.ValueDescriptor, error) {
vList := make([]contract.ValueDescriptor, 0)
for _, name := range names {
v, err := mc.ValueDescriptorByName(name)
if err != nil && err != db.ErrNotFound {
return []contract.ValueDescriptor{}, err
}
if err ==... | [
"func",
"(",
"mc",
"MongoClient",
")",
"ValueDescriptorsByName",
"(",
"names",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"contract",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"vList",
":=",
"make",
"(",
"[",
"]",
"contract",
".",
"ValueDescriptor",
"... | // Return all of the value descriptors based on the names | [
"Return",
"all",
"of",
"the",
"value",
"descriptors",
"based",
"on",
"the",
"names"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L511-L524 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ValueDescriptorById | func (mc MongoClient) ValueDescriptorById(id string) (contract.ValueDescriptor, error) {
query, err := idToBsonM(id)
if err != nil {
return contract.ValueDescriptor{}, err
}
mvd, err := mc.getValueDescriptor(query)
if err != nil {
return contract.ValueDescriptor{}, err
}
return mvd.ToContract(), nil
} | go | func (mc MongoClient) ValueDescriptorById(id string) (contract.ValueDescriptor, error) {
query, err := idToBsonM(id)
if err != nil {
return contract.ValueDescriptor{}, err
}
mvd, err := mc.getValueDescriptor(query)
if err != nil {
return contract.ValueDescriptor{}, err
}
return mvd.ToContract(), nil
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ValueDescriptorById",
"(",
"id",
"string",
")",
"(",
"contract",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"query",
",",
"err",
":=",
"idToBsonM",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // Return a value descriptor based on the id
// Return NotFoundError if there is no value descriptor for the id | [
"Return",
"a",
"value",
"descriptor",
"based",
"on",
"the",
"id",
"Return",
"NotFoundError",
"if",
"there",
"is",
"no",
"value",
"descriptor",
"for",
"the",
"id"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L528-L539 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ValueDescriptorsByUomLabel | func (mc MongoClient) ValueDescriptorsByUomLabel(uomLabel string) ([]contract.ValueDescriptor, error) {
return mapValueDescriptors(mc.getValueDescriptors(bson.M{"uomLabel": uomLabel}))
} | go | func (mc MongoClient) ValueDescriptorsByUomLabel(uomLabel string) ([]contract.ValueDescriptor, error) {
return mapValueDescriptors(mc.getValueDescriptors(bson.M{"uomLabel": uomLabel}))
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ValueDescriptorsByUomLabel",
"(",
"uomLabel",
"string",
")",
"(",
"[",
"]",
"contract",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"return",
"mapValueDescriptors",
"(",
"mc",
".",
"getValueDescriptors",
"(",
"bson",
... | // Return all the value descriptors that match the UOM label | [
"Return",
"all",
"the",
"value",
"descriptors",
"that",
"match",
"the",
"UOM",
"label"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L542-L544 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ValueDescriptorsByLabel | func (mc MongoClient) ValueDescriptorsByLabel(label string) ([]contract.ValueDescriptor, error) {
return mapValueDescriptors(mc.getValueDescriptors(bson.M{"labels": label}))
} | go | func (mc MongoClient) ValueDescriptorsByLabel(label string) ([]contract.ValueDescriptor, error) {
return mapValueDescriptors(mc.getValueDescriptors(bson.M{"labels": label}))
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ValueDescriptorsByLabel",
"(",
"label",
"string",
")",
"(",
"[",
"]",
"contract",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"return",
"mapValueDescriptors",
"(",
"mc",
".",
"getValueDescriptors",
"(",
"bson",
".",
... | // Return value descriptors based on if it has the label | [
"Return",
"value",
"descriptors",
"based",
"on",
"if",
"it",
"has",
"the",
"label"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L547-L549 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ValueDescriptorsByType | func (mc MongoClient) ValueDescriptorsByType(t string) ([]contract.ValueDescriptor, error) {
return mapValueDescriptors(mc.getValueDescriptors(bson.M{"type": t}))
} | go | func (mc MongoClient) ValueDescriptorsByType(t string) ([]contract.ValueDescriptor, error) {
return mapValueDescriptors(mc.getValueDescriptors(bson.M{"type": t}))
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ValueDescriptorsByType",
"(",
"t",
"string",
")",
"(",
"[",
"]",
"contract",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"return",
"mapValueDescriptors",
"(",
"mc",
".",
"getValueDescriptors",
"(",
"bson",
".",
"M"... | // Return value descriptors based on the type | [
"Return",
"value",
"descriptors",
"based",
"on",
"the",
"type"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L552-L554 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | ScrubAllValueDescriptors | func (mc MongoClient) ScrubAllValueDescriptors() error {
s := mc.getSessionCopy()
defer s.Close()
if _, err := s.DB(mc.database.Name).C(db.ValueDescriptorCollection).RemoveAll(nil); err != nil {
return errorMap(err)
}
return nil
} | go | func (mc MongoClient) ScrubAllValueDescriptors() error {
s := mc.getSessionCopy()
defer s.Close()
if _, err := s.DB(mc.database.Name).C(db.ValueDescriptorCollection).RemoveAll(nil); err != nil {
return errorMap(err)
}
return nil
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"ScrubAllValueDescriptors",
"(",
")",
"error",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"DB",
"(",
"mc",... | // Delete all of the value descriptors | [
"Delete",
"all",
"of",
"the",
"value",
"descriptors"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L557-L565 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | getValueDescriptors | func (mc MongoClient) getValueDescriptors(q bson.M) ([]models.ValueDescriptor, error) {
s := mc.getSessionCopy()
defer s.Close()
var v []models.ValueDescriptor
if err := s.DB(mc.database.Name).C(db.ValueDescriptorCollection).Find(q).All(&v); err != nil {
return []models.ValueDescriptor{}, errorMap(err)
}
retur... | go | func (mc MongoClient) getValueDescriptors(q bson.M) ([]models.ValueDescriptor, error) {
s := mc.getSessionCopy()
defer s.Close()
var v []models.ValueDescriptor
if err := s.DB(mc.database.Name).C(db.ValueDescriptorCollection).Find(q).All(&v); err != nil {
return []models.ValueDescriptor{}, errorMap(err)
}
retur... | [
"func",
"(",
"mc",
"MongoClient",
")",
"getValueDescriptors",
"(",
"q",
"bson",
".",
"M",
")",
"(",
"[",
"]",
"models",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close"... | // Get value descriptors based on the query | [
"Get",
"value",
"descriptors",
"based",
"on",
"the",
"query"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L568-L577 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/data.go | getValueDescriptor | func (mc MongoClient) getValueDescriptor(q bson.M) (models.ValueDescriptor, error) {
s := mc.getSessionCopy()
defer s.Close()
var m models.ValueDescriptor
if err := s.DB(mc.database.Name).C(db.ValueDescriptorCollection).Find(q).One(&m); err != nil {
return models.ValueDescriptor{}, errorMap(err)
}
return m, ni... | go | func (mc MongoClient) getValueDescriptor(q bson.M) (models.ValueDescriptor, error) {
s := mc.getSessionCopy()
defer s.Close()
var m models.ValueDescriptor
if err := s.DB(mc.database.Name).C(db.ValueDescriptorCollection).Find(q).One(&m); err != nil {
return models.ValueDescriptor{}, errorMap(err)
}
return m, ni... | [
"func",
"(",
"mc",
"MongoClient",
")",
"getValueDescriptor",
"(",
"q",
"bson",
".",
"M",
")",
"(",
"models",
".",
"ValueDescriptor",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",... | // Get a value descriptor based on the query | [
"Get",
"a",
"value",
"descriptor",
"based",
"on",
"the",
"query"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/data.go#L592-L601 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/notifications.go | GetSubscriptions | func (mc MongoClient) GetSubscriptions() ([]contract.Subscription, error) {
return mc.getSubscriptions(bson.M{})
} | go | func (mc MongoClient) GetSubscriptions() ([]contract.Subscription, error) {
return mc.getSubscriptions(bson.M{})
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"GetSubscriptions",
"(",
")",
"(",
"[",
"]",
"contract",
".",
"Subscription",
",",
"error",
")",
"{",
"return",
"mc",
".",
"getSubscriptions",
"(",
"bson",
".",
"M",
"{",
"}",
")",
"\n",
"}"
] | // Return all the subscriptions
// UnexpectedError - failed to retrieve subscriptions from the database | [
"Return",
"all",
"the",
"subscriptions",
"UnexpectedError",
"-",
"failed",
"to",
"retrieve",
"subscriptions",
"from",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/notifications.go#L288-L290 | train |
edgexfoundry/edgex-go | internal/export/client/server.go | encode | func encode(i interface{}, w http.ResponseWriter) {
w.Header().Add("Content-Type", "application/json")
enc := json.NewEncoder(w)
err := enc.Encode(i)
// Problems encoding
if err != nil {
LoggingClient.Error("Error encoding the data: " + err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
... | go | func encode(i interface{}, w http.ResponseWriter) {
w.Header().Add("Content-Type", "application/json")
enc := json.NewEncoder(w)
err := enc.Encode(i)
// Problems encoding
if err != nil {
LoggingClient.Error("Error encoding the data: " + err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
... | [
"func",
"encode",
"(",
"i",
"interface",
"{",
"}",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"enc",
":=",
"json",
".",
"NewEncoder",
"(",
"w",
")"... | // Helper function for encoding things for returning from REST calls | [
"Helper",
"function",
"for",
"encoding",
"things",
"for",
"returning",
"from",
"REST",
"calls"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/export/client/server.go#L32-L43 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_provisionwatcher.go | deleteProvisionWatcher | func deleteProvisionWatcher(pw models.ProvisionWatcher, w http.ResponseWriter) error {
if err := dbClient.DeleteProvisionWatcherById(pw.Id); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
if err := notifyProvisionWatcherAssociates(pw, http.MethodDelete); err != nil {
Loggi... | go | func deleteProvisionWatcher(pw models.ProvisionWatcher, w http.ResponseWriter) error {
if err := dbClient.DeleteProvisionWatcherById(pw.Id); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
if err := notifyProvisionWatcherAssociates(pw, http.MethodDelete); err != nil {
Loggi... | [
"func",
"deleteProvisionWatcher",
"(",
"pw",
"models",
".",
"ProvisionWatcher",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"if",
"err",
":=",
"dbClient",
".",
"DeleteProvisionWatcherById",
"(",
"pw",
".",
"Id",
")",
";",
"err",
"!=",
"nil",
... | // Delete the provision watcher | [
"Delete",
"the",
"provision",
"watcher"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_provisionwatcher.go#L104-L115 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_provisionwatcher.go | restUpdateProvisionWatcher | func restUpdateProvisionWatcher(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
var from models.ProvisionWatcher
if err := json.NewDecoder(r.Body).Decode(&from); err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
}
// Check if the pr... | go | func restUpdateProvisionWatcher(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
var from models.ProvisionWatcher
if err := json.NewDecoder(r.Body).Decode(&from); err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
}
// Check if the pr... | [
"func",
"restUpdateProvisionWatcher",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"r",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"var",
"from",
"models",
".",
"ProvisionWatcher",
"\n",
"if",
"err",
... | // Update the provision watcher object
// ID is used first for identification, then name
// The service and profile cannot be updated | [
"Update",
"the",
"provision",
"watcher",
"object",
"ID",
"is",
"used",
"first",
"for",
"identification",
"then",
"name",
"The",
"service",
"and",
"profile",
"cannot",
"be",
"updated"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_provisionwatcher.go#L385-L429 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_provisionwatcher.go | updateProvisionWatcherFields | func updateProvisionWatcherFields(from models.ProvisionWatcher, to *models.ProvisionWatcher, w http.ResponseWriter) error {
if from.Identifiers != nil {
to.Identifiers = from.Identifiers
}
if from.Origin != 0 {
to.Origin = from.Origin
}
if from.Name != "" {
// Check that the name is unique
checkPW, err := ... | go | func updateProvisionWatcherFields(from models.ProvisionWatcher, to *models.ProvisionWatcher, w http.ResponseWriter) error {
if from.Identifiers != nil {
to.Identifiers = from.Identifiers
}
if from.Origin != 0 {
to.Origin = from.Origin
}
if from.Name != "" {
// Check that the name is unique
checkPW, err := ... | [
"func",
"updateProvisionWatcherFields",
"(",
"from",
"models",
".",
"ProvisionWatcher",
",",
"to",
"*",
"models",
".",
"ProvisionWatcher",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"if",
"from",
".",
"Identifiers",
"!=",
"nil",
"{",
"to",
"... | // Update the relevant fields of the provision watcher | [
"Update",
"the",
"relevant",
"fields",
"of",
"the",
"provision",
"watcher"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_provisionwatcher.go#L432-L460 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_provisionwatcher.go | notifyProvisionWatcherAssociates | func notifyProvisionWatcherAssociates(pw models.ProvisionWatcher, action string) error {
// Get the device service for the provision watcher
ds, err := dbClient.GetDeviceServiceById(pw.Service.Id)
if err != nil {
return err
}
// Notify the service
if err = notifyAssociates([]models.DeviceService{ds}, pw.Id, ac... | go | func notifyProvisionWatcherAssociates(pw models.ProvisionWatcher, action string) error {
// Get the device service for the provision watcher
ds, err := dbClient.GetDeviceServiceById(pw.Service.Id)
if err != nil {
return err
}
// Notify the service
if err = notifyAssociates([]models.DeviceService{ds}, pw.Id, ac... | [
"func",
"notifyProvisionWatcherAssociates",
"(",
"pw",
"models",
".",
"ProvisionWatcher",
",",
"action",
"string",
")",
"error",
"{",
"// Get the device service for the provision watcher",
"ds",
",",
"err",
":=",
"dbClient",
".",
"GetDeviceServiceById",
"(",
"pw",
".",
... | // Notify the associated device services for the provision watcher | [
"Notify",
"the",
"associated",
"device",
"services",
"for",
"the",
"provision",
"watcher"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_provisionwatcher.go#L463-L476 | train |
edgexfoundry/edgex-go | internal/core/data/device.go | updateDeviceLastReportedConnected | func updateDeviceLastReportedConnected(device string) {
// Config set to skip update last reported
if !Configuration.Writable.DeviceUpdateLastConnected {
LoggingClient.Debug("Skipping update of device connected/reported times for: " + device)
return
}
d, err := mdc.CheckForDevice(device, context.Background())... | go | func updateDeviceLastReportedConnected(device string) {
// Config set to skip update last reported
if !Configuration.Writable.DeviceUpdateLastConnected {
LoggingClient.Debug("Skipping update of device connected/reported times for: " + device)
return
}
d, err := mdc.CheckForDevice(device, context.Background())... | [
"func",
"updateDeviceLastReportedConnected",
"(",
"device",
"string",
")",
"{",
"// Config set to skip update last reported",
"if",
"!",
"Configuration",
".",
"Writable",
".",
"DeviceUpdateLastConnected",
"{",
"LoggingClient",
".",
"Debug",
"(",
"\"",
"\"",
"+",
"device... | // Update when the device was last reported connected | [
"Update",
"when",
"the",
"device",
"was",
"last",
"reported",
"connected"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/data/device.go#L23-L55 | train |
edgexfoundry/edgex-go | internal/core/data/device.go | updateDeviceServiceLastReportedConnected | func updateDeviceServiceLastReportedConnected(device string) {
if !Configuration.Writable.ServiceUpdateLastConnected {
LoggingClient.Debug("Skipping update of device service connected/reported times for: " + device)
return
}
t := db.MakeTimestamp()
// Get the device
d, err := mdc.CheckForDevice(device, cont... | go | func updateDeviceServiceLastReportedConnected(device string) {
if !Configuration.Writable.ServiceUpdateLastConnected {
LoggingClient.Debug("Skipping update of device service connected/reported times for: " + device)
return
}
t := db.MakeTimestamp()
// Get the device
d, err := mdc.CheckForDevice(device, cont... | [
"func",
"updateDeviceServiceLastReportedConnected",
"(",
"device",
"string",
")",
"{",
"if",
"!",
"Configuration",
".",
"Writable",
".",
"ServiceUpdateLastConnected",
"{",
"LoggingClient",
".",
"Debug",
"(",
"\"",
"\"",
"+",
"device",
")",
"\n",
"return",
"\n",
... | // Update when the device service was last reported connected | [
"Update",
"when",
"the",
"device",
"service",
"was",
"last",
"reported",
"connected"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/data/device.go#L58-L89 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/queries.go | getObjectsByRangeFilter | func getObjectsByRangeFilter(conn redis.Conn, key string, filter string, start, end int) (objects [][]byte, err error) {
ids, err := redis.Values(conn.Do("ZRANGE", key, start, end))
if err != nil && err != redis.ErrNil {
return nil, err
}
// https://github.com/golang/go/wiki/SliceTricks#filtering-without-allocat... | go | func getObjectsByRangeFilter(conn redis.Conn, key string, filter string, start, end int) (objects [][]byte, err error) {
ids, err := redis.Values(conn.Do("ZRANGE", key, start, end))
if err != nil && err != redis.ErrNil {
return nil, err
}
// https://github.com/golang/go/wiki/SliceTricks#filtering-without-allocat... | [
"func",
"getObjectsByRangeFilter",
"(",
"conn",
"redis",
".",
"Conn",
",",
"key",
"string",
",",
"filter",
"string",
",",
"start",
",",
"end",
"int",
")",
"(",
"objects",
"[",
"]",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"ids",
",",
"err",
... | // Return objects by a score from a zset
// if limit is 0, all are returned
// if end is negative, it is considered as positive infinity | [
"Return",
"objects",
"by",
"a",
"score",
"from",
"a",
"zset",
"if",
"limit",
"is",
"0",
"all",
"are",
"returned",
"if",
"end",
"is",
"negative",
"it",
"is",
"considered",
"as",
"positive",
"infinity"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/queries.go#L132-L164 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/queries.go | addObject | func addObject(data []byte, adder models.Adder, id string, conn redis.Conn) {
_ = conn.Send("SET", id, data)
for _, cmd := range adder.Add() {
switch cmd.Command {
case "ZADD":
_ = conn.Send(cmd.Command, cmd.Hash, cmd.Rank, cmd.Key)
case "SADD":
_ = conn.Send(cmd.Command, cmd.Hash, cmd.Key)
case "HSET"... | go | func addObject(data []byte, adder models.Adder, id string, conn redis.Conn) {
_ = conn.Send("SET", id, data)
for _, cmd := range adder.Add() {
switch cmd.Command {
case "ZADD":
_ = conn.Send(cmd.Command, cmd.Hash, cmd.Rank, cmd.Key)
case "SADD":
_ = conn.Send(cmd.Command, cmd.Hash, cmd.Key)
case "HSET"... | [
"func",
"addObject",
"(",
"data",
"[",
"]",
"byte",
",",
"adder",
"models",
".",
"Adder",
",",
"id",
"string",
",",
"conn",
"redis",
".",
"Conn",
")",
"{",
"_",
"=",
"conn",
".",
"Send",
"(",
"\"",
"\"",
",",
"id",
",",
"data",
")",
"\n\n",
"fo... | // addObject is responsible for setting the object's primary record and then sending the appropriate
// follow-on commands as provided by the caller.
// Transactions are managed outside of this function. | [
"addObject",
"is",
"responsible",
"for",
"setting",
"the",
"object",
"s",
"primary",
"record",
"and",
"then",
"sending",
"the",
"appropriate",
"follow",
"-",
"on",
"commands",
"as",
"provided",
"by",
"the",
"caller",
".",
"Transactions",
"are",
"managed",
"out... | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/queries.go#L196-L209 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/queries.go | deleteObject | func deleteObject(remover models.Remover, id string, conn redis.Conn) {
_ = conn.Send("DEL", id)
for _, cmd := range remover.Remove() {
switch cmd.Command {
case "ZREM":
case "SREM":
case "HDEL":
_ = conn.Send(cmd.Command, cmd.Hash, cmd.Key)
}
}
} | go | func deleteObject(remover models.Remover, id string, conn redis.Conn) {
_ = conn.Send("DEL", id)
for _, cmd := range remover.Remove() {
switch cmd.Command {
case "ZREM":
case "SREM":
case "HDEL":
_ = conn.Send(cmd.Command, cmd.Hash, cmd.Key)
}
}
} | [
"func",
"deleteObject",
"(",
"remover",
"models",
".",
"Remover",
",",
"id",
"string",
",",
"conn",
"redis",
".",
"Conn",
")",
"{",
"_",
"=",
"conn",
".",
"Send",
"(",
"\"",
"\"",
",",
"id",
")",
"\n\n",
"for",
"_",
",",
"cmd",
":=",
"range",
"re... | // deleteObject is responsible for removing the object's primary record and then sending the appropriate
// follow-on commands as provided by the caller.
//
// Transactions are managed outside of this function. | [
"deleteObject",
"is",
"responsible",
"for",
"removing",
"the",
"object",
"s",
"primary",
"record",
"and",
"then",
"sending",
"the",
"appropriate",
"follow",
"-",
"on",
"commands",
"as",
"provided",
"by",
"the",
"caller",
".",
"Transactions",
"are",
"managed",
... | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/queries.go#L215-L226 | train |
edgexfoundry/edgex-go | internal/core/command/get.go | NewGetCommand | func NewGetCommand(device contract.Device, command contract.Command, context context.Context, httpCaller internal.HttpCaller) (Executor, error) {
url := device.Service.Addressable.GetBaseURL() + strings.Replace(command.Get.Action.Path, DEVICEIDURLPARAM, device.Id, -1)
request, err := http.NewRequest(http.MethodGet, u... | go | func NewGetCommand(device contract.Device, command contract.Command, context context.Context, httpCaller internal.HttpCaller) (Executor, error) {
url := device.Service.Addressable.GetBaseURL() + strings.Replace(command.Get.Action.Path, DEVICEIDURLPARAM, device.Id, -1)
request, err := http.NewRequest(http.MethodGet, u... | [
"func",
"NewGetCommand",
"(",
"device",
"contract",
".",
"Device",
",",
"command",
"contract",
".",
"Command",
",",
"context",
"context",
".",
"Context",
",",
"httpCaller",
"internal",
".",
"HttpCaller",
")",
"(",
"Executor",
",",
"error",
")",
"{",
"url",
... | // NewGetCommand creates and Executor which can be used to execute the GET related command. | [
"NewGetCommand",
"creates",
"and",
"Executor",
"which",
"can",
"be",
"used",
"to",
"execute",
"the",
"GET",
"related",
"command",
"."
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/command/get.go#L26-L43 | train |
edgexfoundry/edgex-go | internal/export/distro/httpsender.go | newHTTPSender | func newHTTPSender(addr contract.Addressable) sender {
sender := httpSender{
url: addr.Protocol + "://" + addr.Address + ":" + strconv.Itoa(addr.Port) + addr.Path,
method: addr.HTTPMethod,
}
return sender
} | go | func newHTTPSender(addr contract.Addressable) sender {
sender := httpSender{
url: addr.Protocol + "://" + addr.Address + ":" + strconv.Itoa(addr.Port) + addr.Path,
method: addr.HTTPMethod,
}
return sender
} | [
"func",
"newHTTPSender",
"(",
"addr",
"contract",
".",
"Addressable",
")",
"sender",
"{",
"sender",
":=",
"httpSender",
"{",
"url",
":",
"addr",
".",
"Protocol",
"+",
"\"",
"\"",
"+",
"addr",
".",
"Address",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa"... | // newHTTPSender - create http sender | [
"newHTTPSender",
"-",
"create",
"http",
"sender"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/export/distro/httpsender.go#L34-L41 | train |
edgexfoundry/edgex-go | internal/export/distro/httpsender.go | Send | func (sender httpSender) Send(data []byte, event *models.Event) bool {
switch sender.method {
case http.MethodPost:
ctx := context.WithValue(context.Background(), clients.CorrelationHeader, event.CorrelationId)
req, err := http.NewRequest(http.MethodPost, sender.url, bytes.NewReader(data))
if err != nil {
r... | go | func (sender httpSender) Send(data []byte, event *models.Event) bool {
switch sender.method {
case http.MethodPost:
ctx := context.WithValue(context.Background(), clients.CorrelationHeader, event.CorrelationId)
req, err := http.NewRequest(http.MethodPost, sender.url, bytes.NewReader(data))
if err != nil {
r... | [
"func",
"(",
"sender",
"httpSender",
")",
"Send",
"(",
"data",
"[",
"]",
"byte",
",",
"event",
"*",
"models",
".",
"Event",
")",
"bool",
"{",
"switch",
"sender",
".",
"method",
"{",
"case",
"http",
".",
"MethodPost",
":",
"ctx",
":=",
"context",
".",... | // Send will send the optionally filtered, compressed, encypted contract.Event via HTTP POST
// The model.Event is provided in order to obtain the necessary correlation-id. | [
"Send",
"will",
"send",
"the",
"optionally",
"filtered",
"compressed",
"encypted",
"contract",
".",
"Event",
"via",
"HTTP",
"POST",
"The",
"model",
".",
"Event",
"is",
"provided",
"in",
"order",
"to",
"obtain",
"the",
"necessary",
"correlation",
"-",
"id",
"... | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/export/distro/httpsender.go#L45-L73 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/client.go | NewClient | func NewClient(config db.Configuration) (MongoClient, error) {
m := MongoClient{}
// Create the dial info for the Mongo session
connectionString := config.Host + ":" + strconv.Itoa(config.Port)
mongoDBDialInfo := &mgo.DialInfo{
Addrs: []string{connectionString},
Timeout: time.Duration(config.Timeout) * tim... | go | func NewClient(config db.Configuration) (MongoClient, error) {
m := MongoClient{}
// Create the dial info for the Mongo session
connectionString := config.Host + ":" + strconv.Itoa(config.Port)
mongoDBDialInfo := &mgo.DialInfo{
Addrs: []string{connectionString},
Timeout: time.Duration(config.Timeout) * tim... | [
"func",
"NewClient",
"(",
"config",
"db",
".",
"Configuration",
")",
"(",
"MongoClient",
",",
"error",
")",
"{",
"m",
":=",
"MongoClient",
"{",
"}",
"\n\n",
"// Create the dial info for the Mongo session",
"connectionString",
":=",
"config",
".",
"Host",
"+",
"\... | // Return a pointer to the MongoClient | [
"Return",
"a",
"pointer",
"to",
"the",
"MongoClient"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/client.go#L32-L54 | train |
edgexfoundry/edgex-go | internal/support/logging/types.go | SetLogLevel | func (l privLogger) SetLogLevel(logLevel string) error {
if logger.IsValidLogLevel(logLevel) == true {
*l.logLevel = logLevel
return nil
}
return types.ErrNotFound{}
} | go | func (l privLogger) SetLogLevel(logLevel string) error {
if logger.IsValidLogLevel(logLevel) == true {
*l.logLevel = logLevel
return nil
}
return types.ErrNotFound{}
} | [
"func",
"(",
"l",
"privLogger",
")",
"SetLogLevel",
"(",
"logLevel",
"string",
")",
"error",
"{",
"if",
"logger",
".",
"IsValidLogLevel",
"(",
"logLevel",
")",
"==",
"true",
"{",
"*",
"l",
".",
"logLevel",
"=",
"logLevel",
"\n",
"return",
"nil",
"\n",
... | // SetLogLevel sets logger log level | [
"SetLogLevel",
"sets",
"logger",
"log",
"level"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/support/logging/types.go#L105-L111 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/metadata.go | GetDeviceProfilesByCommandId | func (mc MongoClient) GetDeviceProfilesByCommandId(id string) ([]contract.DeviceProfile, error) {
command, err := mc.getCommandById(id)
if err != nil {
return []contract.DeviceProfile{}, err
}
dps, err := mc.getDeviceProfiles(bson.M{"commands.$id": command.Id})
if err != nil {
return []contract.DeviceProfile{... | go | func (mc MongoClient) GetDeviceProfilesByCommandId(id string) ([]contract.DeviceProfile, error) {
command, err := mc.getCommandById(id)
if err != nil {
return []contract.DeviceProfile{}, err
}
dps, err := mc.getDeviceProfiles(bson.M{"commands.$id": command.Id})
if err != nil {
return []contract.DeviceProfile{... | [
"func",
"(",
"mc",
"MongoClient",
")",
"GetDeviceProfilesByCommandId",
"(",
"id",
"string",
")",
"(",
"[",
"]",
"contract",
".",
"DeviceProfile",
",",
"error",
")",
"{",
"command",
",",
"err",
":=",
"mc",
".",
"getCommandById",
"(",
"id",
")",
"\n",
"if"... | // Get the device profiles that are currently using the command | [
"Get",
"the",
"device",
"profiles",
"that",
"are",
"currently",
"using",
"the",
"command"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/metadata.go#L393-L404 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/metadata.go | DeleteCommandById | func (mc MongoClient) DeleteCommandById(id string) error {
s := mc.session.Copy()
defer s.Close()
col := s.DB(mc.database.Name).C(db.Command)
// Check if the command is still in use
findParameters, err := idToBsonM(id)
if err != nil {
return err
}
query := bson.M{"commands": bson.M{"$elemMatch": findParamete... | go | func (mc MongoClient) DeleteCommandById(id string) error {
s := mc.session.Copy()
defer s.Close()
col := s.DB(mc.database.Name).C(db.Command)
// Check if the command is still in use
findParameters, err := idToBsonM(id)
if err != nil {
return err
}
query := bson.M{"commands": bson.M{"$elemMatch": findParamete... | [
"func",
"(",
"mc",
"MongoClient",
")",
"DeleteCommandById",
"(",
"id",
"string",
")",
"error",
"{",
"s",
":=",
"mc",
".",
"session",
".",
"Copy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n",
"col",
":=",
"s",
".",
"DB",
"(",
"mc",
... | // Delete the command by ID
// Check if the command is still in use by device profiles | [
"Delete",
"the",
"command",
"by",
"ID",
"Check",
"if",
"the",
"command",
"is",
"still",
"in",
"use",
"by",
"device",
"profiles"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/metadata.go#L999-L1024 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/metadata.go | ScrubMetadata | func (mc MongoClient) ScrubMetadata() error {
s := mc.session.Copy()
defer s.Close()
_, err := s.DB(mc.database.Name).C(db.Addressable).RemoveAll(nil)
if err != nil {
return errorMap(err)
}
_, err = s.DB(mc.database.Name).C(db.DeviceService).RemoveAll(nil)
if err != nil {
return errorMap(err)
}
_, err = s... | go | func (mc MongoClient) ScrubMetadata() error {
s := mc.session.Copy()
defer s.Close()
_, err := s.DB(mc.database.Name).C(db.Addressable).RemoveAll(nil)
if err != nil {
return errorMap(err)
}
_, err = s.DB(mc.database.Name).C(db.DeviceService).RemoveAll(nil)
if err != nil {
return errorMap(err)
}
_, err = s... | [
"func",
"(",
"mc",
"MongoClient",
")",
"ScrubMetadata",
"(",
")",
"error",
"{",
"s",
":=",
"mc",
".",
"session",
".",
"Copy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"_",
",",
"err",
":=",
"s",
".",
"DB",
"(",
"mc",
".",
... | // Scrub all metadata | [
"Scrub",
"all",
"metadata"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/metadata.go#L1042-L1072 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/notifications.go | GetNotifications | func (c Client) GetNotifications() (n []contract.Notification, err error) {
conn := c.Pool.Get()
defer conn.Close()
objects, err := getObjectsByRange(conn, db.Notification, 0, -1)
if err != nil {
return nil, err
}
n, err = unmarshalNotifications(objects)
if err != nil {
return n, err
}
return n, nil
} | go | func (c Client) GetNotifications() (n []contract.Notification, err error) {
conn := c.Pool.Get()
defer conn.Close()
objects, err := getObjectsByRange(conn, db.Notification, 0, -1)
if err != nil {
return nil, err
}
n, err = unmarshalNotifications(objects)
if err != nil {
return n, err
}
return n, nil
} | [
"func",
"(",
"c",
"Client",
")",
"GetNotifications",
"(",
")",
"(",
"n",
"[",
"]",
"contract",
".",
"Notification",
",",
"err",
"error",
")",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")"... | // Get all notifications | [
"Get",
"all",
"notifications"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/notifications.go#L51-L66 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/notifications.go | DeleteNotificationsOld | func (c Client) DeleteNotificationsOld(age int) error {
conn := c.Pool.Get()
defer conn.Close()
currentTime := db.MakeTimestamp()
end := int64(int(currentTime) - age)
objects, err := getObjectsByScore(conn, db.Notification+":modified", 0, end, 0)
for _, object := range objects {
if len(object) > 0 {
var n... | go | func (c Client) DeleteNotificationsOld(age int) error {
conn := c.Pool.Get()
defer conn.Close()
currentTime := db.MakeTimestamp()
end := int64(int(currentTime) - age)
objects, err := getObjectsByScore(conn, db.Notification+":modified", 0, end, 0)
for _, object := range objects {
if len(object) > 0 {
var n... | [
"func",
"(",
"c",
"Client",
")",
"DeleteNotificationsOld",
"(",
"age",
"int",
")",
"error",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"currentTime",
":=",
"db",
".",
"MakeTimesta... | // DeleteNotificationsOld remove all the notifications that are older than the given age | [
"DeleteNotificationsOld",
"remove",
"all",
"the",
"notifications",
"that",
"are",
"older",
"than",
"the",
"given",
"age"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/notifications.go#L265-L292 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/notifications.go | DeleteTransmission | func (c Client) DeleteTransmission(age int64, status contract.TransmissionStatus) error {
conn := c.Pool.Get()
defer conn.Close()
currentTime := db.MakeTimestamp()
end := currentTime - age
objects, err := getObjectsByRangeFilter(conn, db.Transmission+":modified", db.Transmission+":status:"+fmt.Sprintf("%s", stat... | go | func (c Client) DeleteTransmission(age int64, status contract.TransmissionStatus) error {
conn := c.Pool.Get()
defer conn.Close()
currentTime := db.MakeTimestamp()
end := currentTime - age
objects, err := getObjectsByRangeFilter(conn, db.Transmission+":modified", db.Transmission+":status:"+fmt.Sprintf("%s", stat... | [
"func",
"(",
"c",
"Client",
")",
"DeleteTransmission",
"(",
"age",
"int64",
",",
"status",
"contract",
".",
"TransmissionStatus",
")",
"error",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
... | // DeleteTransmission delete old transmission with specified status | [
"DeleteTransmission",
"delete",
"old",
"transmission",
"with",
"specified",
"status"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/notifications.go#L572-L595 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/notifications.go | Cleanup | func (c Client) Cleanup() error {
//conn := c.Pool.Get()
//defer conn.Close()
//
//cols := []string{
// db.Transmission, db.Notification,
//}
//
//for _, col := range cols {
// err := unlinkCollection(conn, col)
// if err != nil {
// return err
// }
//}
err := c.CleanupOld(0)
if err != nil {
return er... | go | func (c Client) Cleanup() error {
//conn := c.Pool.Get()
//defer conn.Close()
//
//cols := []string{
// db.Transmission, db.Notification,
//}
//
//for _, col := range cols {
// err := unlinkCollection(conn, col)
// if err != nil {
// return err
// }
//}
err := c.CleanupOld(0)
if err != nil {
return er... | [
"func",
"(",
"c",
"Client",
")",
"Cleanup",
"(",
")",
"error",
"{",
"//conn := c.Pool.Get()",
"//defer conn.Close()",
"//",
"//cols := []string{",
"//\tdb.Transmission, db.Notification,",
"//}",
"//",
"//for _, col := range cols {",
"//\terr := unlinkCollection(conn, col)",
"//... | // Cleanup delete all notifications and associated transmissions | [
"Cleanup",
"delete",
"all",
"notifications",
"and",
"associated",
"transmissions"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/notifications.go#L598-L617 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/notifications.go | CleanupOld | func (c Client) CleanupOld(age int) error {
conn := c.Pool.Get()
defer conn.Close()
currentTime := db.MakeTimestamp()
end := currentTime - int64(age)
objects, err := getObjectsByScore(conn, db.Notification+":created", 0, end, -1)
if err != nil {
return err
}
notifications, err := unmarshalNotifications(obje... | go | func (c Client) CleanupOld(age int) error {
conn := c.Pool.Get()
defer conn.Close()
currentTime := db.MakeTimestamp()
end := currentTime - int64(age)
objects, err := getObjectsByScore(conn, db.Notification+":created", 0, end, -1)
if err != nil {
return err
}
notifications, err := unmarshalNotifications(obje... | [
"func",
"(",
"c",
"Client",
")",
"CleanupOld",
"(",
"age",
"int",
")",
"error",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"currentTime",
":=",
"db",
".",
"MakeTimestamp",
"(",
... | // Cleanup delete old notifications and associated transmissions | [
"Cleanup",
"delete",
"old",
"notifications",
"and",
"associated",
"transmissions"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/notifications.go#L620-L654 | train |
edgexfoundry/edgex-go | internal/seed/config/populate.go | ImportProperties | func ImportProperties(root string) error {
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
// Skip directories & unacceptable property extension
if info.IsDir() || !isAcceptablePropertyExtensions(info.Name()) {
return nil
}
dir, file :=... | go | func ImportProperties(root string) error {
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
// Skip directories & unacceptable property extension
if info.IsDir() || !isAcceptablePropertyExtensions(info.Name()) {
return nil
}
dir, file :=... | [
"func",
"ImportProperties",
"(",
"root",
"string",
")",
"error",
"{",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"root",
",",
"func",
"(",
"path",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"!="... | // Import properties files for support of legacy Java services. | [
"Import",
"properties",
"files",
"for",
"support",
"of",
"legacy",
"Java",
"services",
"."
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/seed/config/populate.go#L34-L74 | train |
edgexfoundry/edgex-go | internal/seed/config/populate.go | listDirectories | func listDirectories() [9]string {
var names = [9]string{internal.CoreMetaDataServiceKey, internal.CoreCommandServiceKey, internal.CoreDataServiceKey,
internal.ExportDistroServiceKey, internal.ExportClientServiceKey, internal.SupportLoggingServiceKey,
internal.SupportSchedulerServiceKey, internal.SupportNotificati... | go | func listDirectories() [9]string {
var names = [9]string{internal.CoreMetaDataServiceKey, internal.CoreCommandServiceKey, internal.CoreDataServiceKey,
internal.ExportDistroServiceKey, internal.ExportClientServiceKey, internal.SupportLoggingServiceKey,
internal.SupportSchedulerServiceKey, internal.SupportNotificati... | [
"func",
"listDirectories",
"(",
")",
"[",
"9",
"]",
"string",
"{",
"var",
"names",
"=",
"[",
"9",
"]",
"string",
"{",
"internal",
".",
"CoreMetaDataServiceKey",
",",
"internal",
".",
"CoreCommandServiceKey",
",",
"internal",
".",
"CoreDataServiceKey",
",",
"... | // As services are converted to utilize V2 types, add them to this list and remove from the one above. | [
"As",
"services",
"are",
"converted",
"to",
"utilize",
"V2",
"types",
"add",
"them",
"to",
"this",
"list",
"and",
"remove",
"from",
"the",
"one",
"above",
"."
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/seed/config/populate.go#L134-L144 | train |
edgexfoundry/edgex-go | internal/seed/config/populate.go | readPropertiesFile | func readPropertiesFile(filePath string) (map[string]string, error) {
props, err := properties.LoadFile(filePath, properties.UTF8)
if err != nil {
return nil, err
}
return props.Map(), nil
} | go | func readPropertiesFile(filePath string) (map[string]string, error) {
props, err := properties.LoadFile(filePath, properties.UTF8)
if err != nil {
return nil, err
}
return props.Map(), nil
} | [
"func",
"readPropertiesFile",
"(",
"filePath",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"props",
",",
"err",
":=",
"properties",
".",
"LoadFile",
"(",
"filePath",
",",
"properties",
".",
"UTF8",
")",
"\n",
"if",
... | // Parse a properties file to a map. | [
"Parse",
"a",
"properties",
"file",
"to",
"a",
"map",
"."
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/seed/config/populate.go#L189-L196 | train |
edgexfoundry/edgex-go | internal/seed/config/populate.go | traverse | func traverse(path string, j interface{}) ([]*pair, error) {
kvs := make([]*pair, 0)
pathPre := ""
if path != "" {
pathPre = path + "/"
}
switch j.(type) {
case []interface{}:
for sk, sv := range j.([]interface{}) {
skvs, err := traverse(pathPre+strconv.Itoa(sk), sv)
if err != nil {
return nil, er... | go | func traverse(path string, j interface{}) ([]*pair, error) {
kvs := make([]*pair, 0)
pathPre := ""
if path != "" {
pathPre = path + "/"
}
switch j.(type) {
case []interface{}:
for sk, sv := range j.([]interface{}) {
skvs, err := traverse(pathPre+strconv.Itoa(sk), sv)
if err != nil {
return nil, er... | [
"func",
"traverse",
"(",
"path",
"string",
",",
"j",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"*",
"pair",
",",
"error",
")",
"{",
"kvs",
":=",
"make",
"(",
"[",
"]",
"*",
"pair",
",",
"0",
")",
"\n\n",
"pathPre",
":=",
"\"",
"\"",
"\n",
"i... | // Traverse or walk hierarchical configuration in preparation for loading into Registry | [
"Traverse",
"or",
"walk",
"hierarchical",
"configuration",
"in",
"preparation",
"for",
"loading",
"into",
"Registry"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/seed/config/populate.go#L229-L272 | train |
edgexfoundry/edgex-go | internal/export/distro/registrations.go | Loop | func Loop() {
go func() {
p := fmt.Sprintf(":%d", Configuration.Service.Port)
LoggingClient.Info(fmt.Sprintf("Starting Export Distro %s", p))
messageErrors <- http.ListenAndServe(p, httpServer())
}()
registrations := make(map[string]*registrationInfo)
allRegs, err := getRegistrations()
for allRegs == nil ... | go | func Loop() {
go func() {
p := fmt.Sprintf(":%d", Configuration.Service.Port)
LoggingClient.Info(fmt.Sprintf("Starting Export Distro %s", p))
messageErrors <- http.ListenAndServe(p, httpServer())
}()
registrations := make(map[string]*registrationInfo)
allRegs, err := getRegistrations()
for allRegs == nil ... | [
"func",
"Loop",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"p",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"Configuration",
".",
"Service",
".",
"Port",
")",
"\n",
"LoggingClient",
".",
"Info",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\""... | // Loop - registration loop | [
"Loop",
"-",
"registration",
"loop"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/export/distro/registrations.go#L275-L354 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | checkDuplicateProfileNames | func checkDuplicateProfileNames(dp models.DeviceProfile, w http.ResponseWriter) error {
profiles, err := dbClient.GetAllDeviceProfiles()
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
for _, p := range profiles {
if p.Name == dp.Name && p.Id != dp.Id {
err = errors.... | go | func checkDuplicateProfileNames(dp models.DeviceProfile, w http.ResponseWriter) error {
profiles, err := dbClient.GetAllDeviceProfiles()
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
for _, p := range profiles {
if p.Name == dp.Name && p.Id != dp.Id {
err = errors.... | [
"func",
"checkDuplicateProfileNames",
"(",
"dp",
"models",
".",
"DeviceProfile",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"profiles",
",",
"err",
":=",
"dbClient",
".",
"GetAllDeviceProfiles",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // Check for duplicate names in device profiles | [
"Check",
"for",
"duplicate",
"names",
"in",
"device",
"profiles"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L192-L208 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | checkDuplicateCommands | func checkDuplicateCommands(dp models.DeviceProfile, w http.ResponseWriter) error {
// Check if there are duplicate names in the device profile command list
for _, c1 := range dp.CoreCommands {
count := 0
for _, c2 := range dp.CoreCommands {
if c1.Name == c2.Name {
count += 1
}
}
if count > 1 {
e... | go | func checkDuplicateCommands(dp models.DeviceProfile, w http.ResponseWriter) error {
// Check if there are duplicate names in the device profile command list
for _, c1 := range dp.CoreCommands {
count := 0
for _, c2 := range dp.CoreCommands {
if c1.Name == c2.Name {
count += 1
}
}
if count > 1 {
e... | [
"func",
"checkDuplicateCommands",
"(",
"dp",
"models",
".",
"DeviceProfile",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"// Check if there are duplicate names in the device profile command list",
"for",
"_",
",",
"c1",
":=",
"range",
"dp",
".",
"CoreC... | // Check for duplicate command names in the device profile | [
"Check",
"for",
"duplicate",
"command",
"names",
"in",
"the",
"device",
"profile"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L211-L228 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | deleteCommands | func deleteCommands(dp models.DeviceProfile, w http.ResponseWriter) error {
for _, command := range dp.CoreCommands {
err := dbClient.DeleteCommandById(command.Id)
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
}
return nil
} | go | func deleteCommands(dp models.DeviceProfile, w http.ResponseWriter) error {
for _, command := range dp.CoreCommands {
err := dbClient.DeleteCommandById(command.Id)
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
}
return nil
} | [
"func",
"deleteCommands",
"(",
"dp",
"models",
".",
"DeviceProfile",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"for",
"_",
",",
"command",
":=",
"range",
"dp",
".",
"CoreCommands",
"{",
"err",
":=",
"dbClient",
".",
"DeleteCommandById",
"... | // Delete all of the commands that are a part of the device profile | [
"Delete",
"all",
"of",
"the",
"commands",
"that",
"are",
"a",
"part",
"of",
"the",
"device",
"profile"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L231-L241 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | addCommands | func addCommands(dp *models.DeviceProfile, w http.ResponseWriter) error {
for i := range dp.CoreCommands {
if newId, err := dbClient.AddCommand(dp.CoreCommands[i]); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
} else {
dp.CoreCommands[i].Id = newId
}
}
return nil
... | go | func addCommands(dp *models.DeviceProfile, w http.ResponseWriter) error {
for i := range dp.CoreCommands {
if newId, err := dbClient.AddCommand(dp.CoreCommands[i]); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
} else {
dp.CoreCommands[i].Id = newId
}
}
return nil
... | [
"func",
"addCommands",
"(",
"dp",
"*",
"models",
".",
"DeviceProfile",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"for",
"i",
":=",
"range",
"dp",
".",
"CoreCommands",
"{",
"if",
"newId",
",",
"err",
":=",
"dbClient",
".",
"AddCommand",
... | // Add all of the commands that are a part of the device profile | [
"Add",
"all",
"of",
"the",
"commands",
"that",
"are",
"a",
"part",
"of",
"the",
"device",
"profile"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L244-L255 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | restDeleteProfileByName | func restDeleteProfileByName(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
n, err := url.QueryUnescape(vars[NAME])
if err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// Check if the device profile exists
dp, err := dbClient.GetDeviceP... | go | func restDeleteProfileByName(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
n, err := url.QueryUnescape(vars[NAME])
if err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// Check if the device profile exists
dp, err := dbClient.GetDeviceP... | [
"func",
"restDeleteProfileByName",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"vars",
":=",
"mux",
".",
"Vars",
"(",
"r",
")",
"\n",
"n",
",",
"err",
":=",
"url",
".",
"QueryUnescape",
"(",
"vars",
"[",
... | // Delete the device profile based on its name | [
"Delete",
"the",
"device",
"profile",
"based",
"on",
"its",
"name"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L302-L331 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | deleteDeviceProfile | func deleteDeviceProfile(dp models.DeviceProfile, w http.ResponseWriter) error {
// Check if the device profile is still in use by devices
d, err := dbClient.GetDevicesByProfileId(dp.Id)
// XXX ErrNotFound should always be returned but this is not consistent in the implementations
if err == db.ErrNotFound {
err ... | go | func deleteDeviceProfile(dp models.DeviceProfile, w http.ResponseWriter) error {
// Check if the device profile is still in use by devices
d, err := dbClient.GetDevicesByProfileId(dp.Id)
// XXX ErrNotFound should always be returned but this is not consistent in the implementations
if err == db.ErrNotFound {
err ... | [
"func",
"deleteDeviceProfile",
"(",
"dp",
"models",
".",
"DeviceProfile",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"// Check if the device profile is still in use by devices",
"d",
",",
"err",
":=",
"dbClient",
".",
"GetDevicesByProfileId",
"(",
"dp... | // Delete the device profile
// Make sure there are no devices still using it
// Delete the associated commands | [
"Delete",
"the",
"device",
"profile",
"Make",
"sure",
"there",
"are",
"no",
"devices",
"still",
"using",
"it",
"Delete",
"the",
"associated",
"commands"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L336-L373 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | restAddProfileByYamlRaw | func restAddProfileByYamlRaw(w http.ResponseWriter, r *http.Request) {
// Get the YAML string
body, err := ioutil.ReadAll(r.Body)
if err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
addDeviceProfileYaml(body, w)
} | go | func restAddProfileByYamlRaw(w http.ResponseWriter, r *http.Request) {
// Get the YAML string
body, err := ioutil.ReadAll(r.Body)
if err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
addDeviceProfileYaml(body, w)
} | [
"func",
"restAddProfileByYamlRaw",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Get the YAML string",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
".",
"Body",
")",
"\n",
"if",
"err",
"!="... | // Add a device profile with YAML content
// The YAML content is passed as a string in the http request | [
"Add",
"a",
"device",
"profile",
"with",
"YAML",
"content",
"The",
"YAML",
"content",
"is",
"passed",
"as",
"a",
"string",
"in",
"the",
"http",
"request"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L408-L418 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceprofile.go | notifyProfileAssociates | func notifyProfileAssociates(dp models.DeviceProfile, action string) error {
// Get the devices
d, err := dbClient.GetDevicesByProfileId(dp.Id)
if err != nil {
LoggingClient.Error(err.Error())
return err
}
// Get the services for each device
// Use map as a Set
dsMap := map[string]models.DeviceService{}
ds... | go | func notifyProfileAssociates(dp models.DeviceProfile, action string) error {
// Get the devices
d, err := dbClient.GetDevicesByProfileId(dp.Id)
if err != nil {
LoggingClient.Error(err.Error())
return err
}
// Get the services for each device
// Use map as a Set
dsMap := map[string]models.DeviceService{}
ds... | [
"func",
"notifyProfileAssociates",
"(",
"dp",
"models",
".",
"DeviceProfile",
",",
"action",
"string",
")",
"error",
"{",
"// Get the devices",
"d",
",",
"err",
":=",
"dbClient",
".",
"GetDevicesByProfileId",
"(",
"dp",
".",
"Id",
")",
"\n",
"if",
"err",
"!=... | // Notify the associated device services for changes in the device profile | [
"Notify",
"the",
"associated",
"device",
"services",
"for",
"changes",
"in",
"the",
"device",
"profile"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceprofile.go#L649-L675 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_command.go | restUpdateCommand | func restUpdateCommand(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
var c contract.Command
if err := json.NewDecoder(r.Body).Decode(&c); err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// Check if command exists (By ID)
former, err ... | go | func restUpdateCommand(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
var c contract.Command
if err := json.NewDecoder(r.Body).Decode(&c); err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// Check if command exists (By ID)
former, err ... | [
"func",
"restUpdateCommand",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"r",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"var",
"c",
"contract",
".",
"Command",
"\n",
"if",
"err",
":=",
"json",
... | // Update a command
// 404 if the command can't be found by ID
// 409 if the name of the command changes and its not unique to the device profile | [
"Update",
"a",
"command",
"404",
"if",
"the",
"command",
"can",
"t",
"be",
"found",
"by",
"ID",
"409",
"if",
"the",
"name",
"of",
"the",
"command",
"changes",
"and",
"its",
"not",
"unique",
"to",
"the",
"device",
"profile"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_command.go#L69-L130 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_command.go | restDeleteCommandById | func restDeleteCommandById(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
var id string = vars[ID]
// Check if the command exists
_, err := dbClient.GetCommandById(id)
if err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusNotFound)
return
}
// Check if the ... | go | func restDeleteCommandById(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
var id string = vars[ID]
// Check if the command exists
_, err := dbClient.GetCommandById(id)
if err != nil {
LoggingClient.Error(err.Error())
http.Error(w, err.Error(), http.StatusNotFound)
return
}
// Check if the ... | [
"func",
"restDeleteCommandById",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"vars",
":=",
"mux",
".",
"Vars",
"(",
"r",
")",
"\n",
"var",
"id",
"string",
"=",
"vars",
"[",
"ID",
"]",
"\n\n",
"// Check if... | // Delete a command by its ID | [
"Delete",
"a",
"command",
"by",
"its",
"ID"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_command.go#L175-L213 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_command.go | isCommandStillInUse | func isCommandStillInUse(id string) (bool, error) {
dp, err := dbClient.GetDeviceProfilesByCommandId(id)
if err == db.ErrNotFound { // XXX Inconsistent return values. Should be ErrNotFound
err = nil
} else if err != nil {
return false, err
}
if len(dp) == 0 {
return false, err
}
return true, err
} | go | func isCommandStillInUse(id string) (bool, error) {
dp, err := dbClient.GetDeviceProfilesByCommandId(id)
if err == db.ErrNotFound { // XXX Inconsistent return values. Should be ErrNotFound
err = nil
} else if err != nil {
return false, err
}
if len(dp) == 0 {
return false, err
}
return true, err
} | [
"func",
"isCommandStillInUse",
"(",
"id",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"dp",
",",
"err",
":=",
"dbClient",
".",
"GetDeviceProfilesByCommandId",
"(",
"id",
")",
"\n\n",
"if",
"err",
"==",
"db",
".",
"ErrNotFound",
"{",
"// XXX Inconsi... | // Helper function to determine if the command is still in use by device profiles | [
"Helper",
"function",
"to",
"determine",
"if",
"the",
"command",
"is",
"still",
"in",
"use",
"by",
"device",
"profiles"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_command.go#L216-L230 | train |
edgexfoundry/edgex-go | internal/pkg/usage/usage.go | HelpCallback | func HelpCallback() {
msg := fmt.Sprintf(usageStr, os.Args[0])
fmt.Printf("%s\n", msg)
os.Exit(0)
} | go | func HelpCallback() {
msg := fmt.Sprintf(usageStr, os.Args[0])
fmt.Printf("%s\n", msg)
os.Exit(0)
} | [
"func",
"HelpCallback",
"(",
")",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"usageStr",
",",
"os",
".",
"Args",
"[",
"0",
"]",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"msg",
")",
"\n",
"os",
".",
"Exit",
"(",
"0",
")... | // usage will print out the flag options for the server. | [
"usage",
"will",
"print",
"out",
"the",
"flag",
"options",
"for",
"the",
"server",
"."
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/usage/usage.go#L42-L46 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_devicereport.go | updateDeviceReportFields | func updateDeviceReportFields(from models.DeviceReport, to *models.DeviceReport, w http.ResponseWriter) error {
if from.Device != "" {
to.Device = from.Device
if err := validateDevice(to.Device, w); err != nil {
return err
}
}
if from.Action != "" {
to.Action = from.Action
}
if from.Expected != nil {
... | go | func updateDeviceReportFields(from models.DeviceReport, to *models.DeviceReport, w http.ResponseWriter) error {
if from.Device != "" {
to.Device = from.Device
if err := validateDevice(to.Device, w); err != nil {
return err
}
}
if from.Action != "" {
to.Action = from.Action
}
if from.Expected != nil {
... | [
"func",
"updateDeviceReportFields",
"(",
"from",
"models",
".",
"DeviceReport",
",",
"to",
"*",
"models",
".",
"DeviceReport",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"if",
"from",
".",
"Device",
"!=",
"\"",
"\"",
"{",
"to",
".",
"Dev... | // Update the relevant fields for the device report | [
"Update",
"the",
"relevant",
"fields",
"for",
"the",
"device",
"report"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_devicereport.go#L139-L161 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_devicereport.go | validateDevice | func validateDevice(d string, w http.ResponseWriter) error {
if _, err := dbClient.GetDeviceByName(d); err != nil {
if err == db.ErrNotFound {
http.Error(w, "Device was not found", http.StatusNotFound)
} else {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
}
return err
}
return nil
} | go | func validateDevice(d string, w http.ResponseWriter) error {
if _, err := dbClient.GetDeviceByName(d); err != nil {
if err == db.ErrNotFound {
http.Error(w, "Device was not found", http.StatusNotFound)
} else {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
}
return err
}
return nil
} | [
"func",
"validateDevice",
"(",
"d",
"string",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"dbClient",
".",
"GetDeviceByName",
"(",
"d",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"db",
".",
"E... | // Validate that the device exists | [
"Validate",
"that",
"the",
"device",
"exists"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_devicereport.go#L164-L175 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_devicereport.go | restGetValueDescriptorsForDeviceName | func restGetValueDescriptorsForDeviceName(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
n, err := url.QueryUnescape(vars[DEVICENAME])
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
LoggingClient.Error(err.Error())
return
}
// Get all the associated device reports
reports,... | go | func restGetValueDescriptorsForDeviceName(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
n, err := url.QueryUnescape(vars[DEVICENAME])
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
LoggingClient.Error(err.Error())
return
}
// Get all the associated device reports
reports,... | [
"func",
"restGetValueDescriptorsForDeviceName",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"vars",
":=",
"mux",
".",
"Vars",
"(",
"r",
")",
"\n",
"n",
",",
"err",
":=",
"url",
".",
"QueryUnescape",
"(",
"v... | // Get a list of value descriptor names
// The names are a union of all the value descriptors from the device reports for the given device | [
"Get",
"a",
"list",
"of",
"value",
"descriptor",
"names",
"The",
"names",
"are",
"a",
"union",
"of",
"all",
"the",
"value",
"descriptors",
"from",
"the",
"device",
"reports",
"for",
"the",
"given",
"device"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_devicereport.go#L221-L247 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_devicereport.go | notifyDeviceReportAssociates | func notifyDeviceReportAssociates(dr models.DeviceReport, action string) error {
// Get the device of the report
d, err := dbClient.GetDeviceByName(dr.Device)
if err != nil {
return err
}
// Get the device service for the device
ds, err := dbClient.GetDeviceServiceById(d.Service.Id)
if err != nil {
return e... | go | func notifyDeviceReportAssociates(dr models.DeviceReport, action string) error {
// Get the device of the report
d, err := dbClient.GetDeviceByName(dr.Device)
if err != nil {
return err
}
// Get the device service for the device
ds, err := dbClient.GetDeviceServiceById(d.Service.Id)
if err != nil {
return e... | [
"func",
"notifyDeviceReportAssociates",
"(",
"dr",
"models",
".",
"DeviceReport",
",",
"action",
"string",
")",
"error",
"{",
"// Get the device of the report",
"d",
",",
"err",
":=",
"dbClient",
".",
"GetDeviceByName",
"(",
"dr",
".",
"Device",
")",
"\n",
"if",... | // Notify the associated device services to the device report | [
"Notify",
"the",
"associated",
"device",
"services",
"to",
"the",
"device",
"report"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_devicereport.go#L338-L357 | train |
edgexfoundry/edgex-go | internal/pkg/config/types.go | HealthCheck | func (s ServiceInfo) HealthCheck() string {
hc := fmt.Sprintf("%s://%s:%v%s", s.Protocol, s.Host, s.Port, clients.ApiPingRoute)
return hc
} | go | func (s ServiceInfo) HealthCheck() string {
hc := fmt.Sprintf("%s://%s:%v%s", s.Protocol, s.Host, s.Port, clients.ApiPingRoute)
return hc
} | [
"func",
"(",
"s",
"ServiceInfo",
")",
"HealthCheck",
"(",
")",
"string",
"{",
"hc",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"Protocol",
",",
"s",
".",
"Host",
",",
"s",
".",
"Port",
",",
"clients",
".",
"ApiPingRoute",
")",
"... | // HealthCheck is a URL specifying a healthcheck REST endpoint used by the Registry to determine if the
// service is available. | [
"HealthCheck",
"is",
"a",
"URL",
"specifying",
"a",
"healthcheck",
"REST",
"endpoint",
"used",
"by",
"the",
"Registry",
"to",
"determine",
"if",
"the",
"service",
"is",
"available",
"."
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/config/types.go#L50-L53 | train |
edgexfoundry/edgex-go | internal/pkg/config/types.go | Url | func (s ServiceInfo) Url() string {
url := fmt.Sprintf("%s://%s:%v", s.Protocol, s.Host, s.Port)
return url
} | go | func (s ServiceInfo) Url() string {
url := fmt.Sprintf("%s://%s:%v", s.Protocol, s.Host, s.Port)
return url
} | [
"func",
"(",
"s",
"ServiceInfo",
")",
"Url",
"(",
")",
"string",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"Protocol",
",",
"s",
".",
"Host",
",",
"s",
".",
"Port",
")",
"\n",
"return",
"url",
"\n",
"}"
] | // Url provides a way to obtain the full url of the host service for use in initialization or, in some cases,
// responses to a caller. | [
"Url",
"provides",
"a",
"way",
"to",
"obtain",
"the",
"full",
"url",
"of",
"the",
"host",
"service",
"for",
"use",
"in",
"initialization",
"or",
"in",
"some",
"cases",
"responses",
"to",
"a",
"caller",
"."
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/config/types.go#L57-L60 | train |
edgexfoundry/edgex-go | internal/pkg/config/types.go | Url | func (e IntervalActionInfo) Url() string {
url := fmt.Sprintf("%s://%s:%v", e.Protocol, e.Host, e.Port)
return url
} | go | func (e IntervalActionInfo) Url() string {
url := fmt.Sprintf("%s://%s:%v", e.Protocol, e.Host, e.Port)
return url
} | [
"func",
"(",
"e",
"IntervalActionInfo",
")",
"Url",
"(",
")",
"string",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Protocol",
",",
"e",
".",
"Host",
",",
"e",
".",
"Port",
")",
"\n",
"return",
"url",
"\n",
"}"
] | // ScheduleEventInfo helper function | [
"ScheduleEventInfo",
"helper",
"function"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/config/types.go#L142-L145 | train |
edgexfoundry/edgex-go | internal/support/scheduler/utils.go | msToTime | func msToTime(ms string) (time.Time, error) {
msInt, err := strconv.ParseInt(ms, 10, 64)
if err != nil {
// todo: support-scheduler will be removed later issue_650a
t, err := time.Parse(TIMELAYOUT, ms)
if err == nil {
return t, nil
}
return time.Time{}, err
}
return time.Unix(0, msInt*int64(time.Milli... | go | func msToTime(ms string) (time.Time, error) {
msInt, err := strconv.ParseInt(ms, 10, 64)
if err != nil {
// todo: support-scheduler will be removed later issue_650a
t, err := time.Parse(TIMELAYOUT, ms)
if err == nil {
return t, nil
}
return time.Time{}, err
}
return time.Unix(0, msInt*int64(time.Milli... | [
"func",
"msToTime",
"(",
"ms",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"msInt",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"ms",
",",
"10",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// todo: support-sche... | // Convert millisecond string to Time | [
"Convert",
"millisecond",
"string",
"to",
"Time"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/support/scheduler/utils.go#L37-L49 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/export.go | DeleteRegistrationByName | func (c *Client) DeleteRegistrationByName(name string) error {
conn := c.Pool.Get()
defer conn.Close()
id, err := redis.String(conn.Do("HGET", db.ExportCollection+":name", name))
if err == redis.ErrNil {
return db.ErrNotFound
} else if err != nil {
return err
}
return deleteRegistration(conn, id)
} | go | func (c *Client) DeleteRegistrationByName(name string) error {
conn := c.Pool.Get()
defer conn.Close()
id, err := redis.String(conn.Do("HGET", db.ExportCollection+":name", name))
if err == redis.ErrNil {
return db.ErrNotFound
} else if err != nil {
return err
}
return deleteRegistration(conn, id)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteRegistrationByName",
"(",
"name",
"string",
")",
"error",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"id",
",",
"err",
":=",
"redis"... | // Delete a registration by name
// UnexpectedError - problem getting in database
// NotFound - no registration with the name was found | [
"Delete",
"a",
"registration",
"by",
"name",
"UnexpectedError",
"-",
"problem",
"getting",
"in",
"database",
"NotFound",
"-",
"no",
"registration",
"with",
"the",
"name",
"was",
"found"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/export.go#L115-L127 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/export.go | ScrubAllRegistrations | func (c *Client) ScrubAllRegistrations() (err error) {
conn := c.Pool.Get()
defer conn.Close()
return unlinkCollection(conn, db.ExportCollection)
} | go | func (c *Client) ScrubAllRegistrations() (err error) {
conn := c.Pool.Get()
defer conn.Close()
return unlinkCollection(conn, db.ExportCollection)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ScrubAllRegistrations",
"(",
")",
"(",
"err",
"error",
")",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"return",
"unlinkCollection",
"(",
... | // ScrubAllRegistrations deletes all export related data | [
"ScrubAllRegistrations",
"deletes",
"all",
"export",
"related",
"data"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/export.go#L130-L135 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | updateDeviceServiceFields | func updateDeviceServiceFields(from models.DeviceService, to *models.DeviceService, w http.ResponseWriter) error {
// Use .String() to compare empty structs (not ideal, but there is no .equals method)
if (from.Addressable.String() != models.Addressable{}.String()) {
var addr models.Addressable
var err error
if ... | go | func updateDeviceServiceFields(from models.DeviceService, to *models.DeviceService, w http.ResponseWriter) error {
// Use .String() to compare empty structs (not ideal, but there is no .equals method)
if (from.Addressable.String() != models.Addressable{}.String()) {
var addr models.Addressable
var err error
if ... | [
"func",
"updateDeviceServiceFields",
"(",
"from",
"models",
".",
"DeviceService",
",",
"to",
"*",
"models",
".",
"DeviceService",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"// Use .String() to compare empty structs (not ideal, but there is no .equals metho... | // Update the relevant device service fields | [
"Update",
"the",
"relevant",
"device",
"service",
"fields"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L142-L202 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | deleteDeviceService | func deleteDeviceService(ds models.DeviceService, w http.ResponseWriter, ctx context.Context) error {
// Delete the associated devices
devices, err := dbClient.GetDevicesByServiceId(ds.Id)
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
for _, device := range devices {
... | go | func deleteDeviceService(ds models.DeviceService, w http.ResponseWriter, ctx context.Context) error {
// Delete the associated devices
devices, err := dbClient.GetDevicesByServiceId(ds.Id)
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
for _, device := range devices {
... | [
"func",
"deleteDeviceService",
"(",
"ds",
"models",
".",
"DeviceService",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"// Delete the associated devices",
"devices",
",",
"err",
":=",
"dbClient",
".",
"GetDev... | // Delete the device service
// Delete the associated devices
// Delete the associated provision watchers | [
"Delete",
"the",
"device",
"service",
"Delete",
"the",
"associated",
"devices",
"Delete",
"the",
"associated",
"provision",
"watchers"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L367-L399 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | updateServiceLastConnected | func updateServiceLastConnected(ds models.DeviceService, lc int64, w http.ResponseWriter) error {
ds.LastConnected = lc
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | go | func updateServiceLastConnected(ds models.DeviceService, lc int64, w http.ResponseWriter) error {
ds.LastConnected = lc
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | [
"func",
"updateServiceLastConnected",
"(",
"ds",
"models",
".",
"DeviceService",
",",
"lc",
"int64",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"ds",
".",
"LastConnected",
"=",
"lc",
"\n\n",
"if",
"err",
":=",
"dbClient",
".",
"UpdateDeviceS... | // Update the last connected value of the device service | [
"Update",
"the",
"last",
"connected",
"value",
"of",
"the",
"device",
"service"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L472-L481 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | updateServiceOpState | func updateServiceOpState(ds models.DeviceService, os models.OperatingState, w http.ResponseWriter) error {
ds.OperatingState = os
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | go | func updateServiceOpState(ds models.DeviceService, os models.OperatingState, w http.ResponseWriter) error {
ds.OperatingState = os
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | [
"func",
"updateServiceOpState",
"(",
"ds",
"models",
".",
"DeviceService",
",",
"os",
"models",
".",
"OperatingState",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"ds",
".",
"OperatingState",
"=",
"os",
"\n",
"if",
"err",
":=",
"dbClient",
... | // Update the OpState for the device service | [
"Update",
"the",
"OpState",
"for",
"the",
"device",
"service"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L578-L586 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | updateServiceAdminState | func updateServiceAdminState(ds models.DeviceService, as models.AdminState, w http.ResponseWriter) error {
ds.AdminState = as
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | go | func updateServiceAdminState(ds models.DeviceService, as models.AdminState, w http.ResponseWriter) error {
ds.AdminState = as
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | [
"func",
"updateServiceAdminState",
"(",
"ds",
"models",
".",
"DeviceService",
",",
"as",
"models",
".",
"AdminState",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"ds",
".",
"AdminState",
"=",
"as",
"\n",
"if",
"err",
":=",
"dbClient",
".",
... | // Update the admin state for the device service | [
"Update",
"the",
"admin",
"state",
"for",
"the",
"device",
"service"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L666-L674 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | updateServiceLastReported | func updateServiceLastReported(ds models.DeviceService, lr int64, w http.ResponseWriter) error {
ds.LastReported = lr
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | go | func updateServiceLastReported(ds models.DeviceService, lr int64, w http.ResponseWriter) error {
ds.LastReported = lr
if err := dbClient.UpdateDeviceService(ds); err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return err
}
return nil
} | [
"func",
"updateServiceLastReported",
"(",
"ds",
"models",
".",
"DeviceService",
",",
"lr",
"int64",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"ds",
".",
"LastReported",
"=",
"lr",
"\n",
"if",
"err",
":=",
"dbClient",
".",
"UpdateDeviceServi... | // Update the last reported value for the device service | [
"Update",
"the",
"last",
"reported",
"value",
"for",
"the",
"device",
"service"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L746-L754 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | callback | func callback(service models.DeviceService, id string, action string, actionType models.ActionType) error {
client := &http.Client{}
url := service.Addressable.GetCallbackURL()
if len(url) > 0 {
body, err := getBody(id, actionType)
if err != nil {
return err
}
req, err := http.NewRequest(string(action), u... | go | func callback(service models.DeviceService, id string, action string, actionType models.ActionType) error {
client := &http.Client{}
url := service.Addressable.GetCallbackURL()
if len(url) > 0 {
body, err := getBody(id, actionType)
if err != nil {
return err
}
req, err := http.NewRequest(string(action), u... | [
"func",
"callback",
"(",
"service",
"models",
".",
"DeviceService",
",",
"id",
"string",
",",
"action",
"string",
",",
"actionType",
"models",
".",
"ActionType",
")",
"error",
"{",
"client",
":=",
"&",
"http",
".",
"Client",
"{",
"}",
"\n",
"url",
":=",
... | // Make the callback for the device service | [
"Make",
"the",
"callback",
"for",
"the",
"device",
"service"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L769-L788 | train |
edgexfoundry/edgex-go | internal/core/metadata/rest_deviceservice.go | getBody | func getBody(id string, actionType models.ActionType) ([]byte, error) {
return json.Marshal(models.CallbackAlert{ActionType: actionType, Id: id})
} | go | func getBody(id string, actionType models.ActionType) ([]byte, error) {
return json.Marshal(models.CallbackAlert{ActionType: actionType, Id: id})
} | [
"func",
"getBody",
"(",
"id",
"string",
",",
"actionType",
"models",
".",
"ActionType",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"models",
".",
"CallbackAlert",
"{",
"ActionType",
":",
"actionType",
",",
... | // Turn the ID and ActionType into the JSON body that will be passed | [
"Turn",
"the",
"ID",
"and",
"ActionType",
"into",
"the",
"JSON",
"body",
"that",
"will",
"be",
"passed"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/metadata/rest_deviceservice.go#L803-L805 | train |
edgexfoundry/edgex-go | internal/core/data/router.go | scrubAllHandler | func scrubAllHandler(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
LoggingClient.Info("Deleting all events from database")
err := deleteAllEvents()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
LoggingClient.Error(err.Error())
return
}
encode(true, w)
} | go | func scrubAllHandler(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
LoggingClient.Info("Deleting all events from database")
err := deleteAllEvents()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
LoggingClient.Error(err.Error())
return
}
encode(true, w)
} | [
"func",
"scrubAllHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"r",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"LoggingClient",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"err",
":=",
... | // Undocumented feature to remove all readings and events from the database
// This should primarily be used for debugging purposes | [
"Undocumented",
"feature",
"to",
"remove",
"all",
"readings",
"and",
"events",
"from",
"the",
"database",
"This",
"should",
"primarily",
"be",
"used",
"for",
"debugging",
"purposes"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/data/router.go#L288-L301 | train |
edgexfoundry/edgex-go | internal/core/command/types.go | Execute | func (sc serviceCommand) Execute() (string, int, error) {
if sc.AdminState == contract.Locked {
LoggingClient.Error(sc.Name + " is in admin locked state")
return "", DefaultErrorCode, ErrDeviceLocked{}
}
LoggingClient.Info("Issuing" + sc.Request.Method + " command to: " + sc.Request.URL.String())
resp, reqErr... | go | func (sc serviceCommand) Execute() (string, int, error) {
if sc.AdminState == contract.Locked {
LoggingClient.Error(sc.Name + " is in admin locked state")
return "", DefaultErrorCode, ErrDeviceLocked{}
}
LoggingClient.Info("Issuing" + sc.Request.Method + " command to: " + sc.Request.URL.String())
resp, reqErr... | [
"func",
"(",
"sc",
"serviceCommand",
")",
"Execute",
"(",
")",
"(",
"string",
",",
"int",
",",
"error",
")",
"{",
"if",
"sc",
".",
"AdminState",
"==",
"contract",
".",
"Locked",
"{",
"LoggingClient",
".",
"Error",
"(",
"sc",
".",
"Name",
"+",
"\"",
... | // Execute sends the command to the command service | [
"Execute",
"sends",
"the",
"command",
"to",
"the",
"command",
"service"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/core/command/types.go#L41-L63 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | IntervalByName | func (mc MongoClient) IntervalByName(name string) (contract.Interval, error) {
s := mc.getSessionCopy()
defer s.Close()
query := bson.M{"name": name}
mi := models.Interval{}
if err := s.DB(mc.database.Name).C(db.Interval).Find(query).One(&mi); err != nil {
return contract.Interval{}, errorMap(err)
}
return m... | go | func (mc MongoClient) IntervalByName(name string) (contract.Interval, error) {
s := mc.getSessionCopy()
defer s.Close()
query := bson.M{"name": name}
mi := models.Interval{}
if err := s.DB(mc.database.Name).C(db.Interval).Find(query).One(&mi); err != nil {
return contract.Interval{}, errorMap(err)
}
return m... | [
"func",
"(",
"mc",
"MongoClient",
")",
"IntervalByName",
"(",
"name",
"string",
")",
"(",
"contract",
".",
"Interval",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"quer... | // Return an Interval by name
// UnexpectedError - failed to retrieve interval from the database | [
"Return",
"an",
"Interval",
"by",
"name",
"UnexpectedError",
"-",
"failed",
"to",
"retrieve",
"interval",
"from",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L42-L53 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | IntervalById | func (mc MongoClient) IntervalById(id string) (contract.Interval, error) {
s := mc.getSessionCopy()
defer s.Close()
query, err := idToBsonM(id)
if err != nil {
return contract.Interval{}, err
}
var interval models.Interval
if err := s.DB(mc.database.Name).C(db.Interval).Find(query).One(&interval); err != nil... | go | func (mc MongoClient) IntervalById(id string) (contract.Interval, error) {
s := mc.getSessionCopy()
defer s.Close()
query, err := idToBsonM(id)
if err != nil {
return contract.Interval{}, err
}
var interval models.Interval
if err := s.DB(mc.database.Name).C(db.Interval).Find(query).One(&interval); err != nil... | [
"func",
"(",
"mc",
"MongoClient",
")",
"IntervalById",
"(",
"id",
"string",
")",
"(",
"contract",
".",
"Interval",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"query",
... | // Return an Interval by ID
// UnexpectedError - failed to retrieve interval from the database | [
"Return",
"an",
"Interval",
"by",
"ID",
"UnexpectedError",
"-",
"failed",
"to",
"retrieve",
"interval",
"from",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L57-L71 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | UpdateInterval | func (mc MongoClient) UpdateInterval(interval contract.Interval) error {
var mapped models.Interval
id, err := mapped.FromContract(interval)
if err != nil {
return err
}
mapped.TimestampForUpdate()
return mc.updateId(db.Interval, id, mapped)
} | go | func (mc MongoClient) UpdateInterval(interval contract.Interval) error {
var mapped models.Interval
id, err := mapped.FromContract(interval)
if err != nil {
return err
}
mapped.TimestampForUpdate()
return mc.updateId(db.Interval, id, mapped)
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"UpdateInterval",
"(",
"interval",
"contract",
".",
"Interval",
")",
"error",
"{",
"var",
"mapped",
"models",
".",
"Interval",
"\n",
"id",
",",
"err",
":=",
"mapped",
".",
"FromContract",
"(",
"interval",
")",
"\n",
... | // Update an Interval
// UnexpectedError - failed to update interval in the database | [
"Update",
"an",
"Interval",
"UnexpectedError",
"-",
"failed",
"to",
"update",
"interval",
"in",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L103-L113 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | DeleteIntervalById | func (mc MongoClient) DeleteIntervalById(id string) error {
return mc.deleteById(db.Interval, id)
} | go | func (mc MongoClient) DeleteIntervalById(id string) error {
return mc.deleteById(db.Interval, id)
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"DeleteIntervalById",
"(",
"id",
"string",
")",
"error",
"{",
"return",
"mc",
".",
"deleteById",
"(",
"db",
".",
"Interval",
",",
"id",
")",
"\n",
"}"
] | // Remove an Interval by ID
// UnexpectedError - failed to remove interval from the database | [
"Remove",
"an",
"Interval",
"by",
"ID",
"UnexpectedError",
"-",
"failed",
"to",
"remove",
"interval",
"from",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L117-L119 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | IntervalActionById | func (mc MongoClient) IntervalActionById(id string) (contract.IntervalAction, error) {
s := mc.getSessionCopy()
defer s.Close()
query, err := idToBsonM(id)
if err != nil {
return contract.IntervalAction{}, err
}
var action models.IntervalAction
if err := s.DB(mc.database.Name).C(db.IntervalAction).Find(query... | go | func (mc MongoClient) IntervalActionById(id string) (contract.IntervalAction, error) {
s := mc.getSessionCopy()
defer s.Close()
query, err := idToBsonM(id)
if err != nil {
return contract.IntervalAction{}, err
}
var action models.IntervalAction
if err := s.DB(mc.database.Name).C(db.IntervalAction).Find(query... | [
"func",
"(",
"mc",
"MongoClient",
")",
"IntervalActionById",
"(",
"id",
"string",
")",
"(",
"contract",
".",
"IntervalAction",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",... | // Return an Interval Action by ID
// UnexpectedError - failed to retrieve interval actions from the database
// Sort the interval actions in descending order by ID | [
"Return",
"an",
"Interval",
"Action",
"by",
"ID",
"UnexpectedError",
"-",
"failed",
"to",
"retrieve",
"interval",
"actions",
"from",
"the",
"database",
"Sort",
"the",
"interval",
"actions",
"in",
"descending",
"order",
"by",
"ID"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L154-L168 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | IntervalActionByName | func (mc MongoClient) IntervalActionByName(name string) (contract.IntervalAction, error) {
s := mc.getSessionCopy()
defer s.Close()
query := bson.M{"name": name}
mia := models.IntervalAction{}
if err := s.DB(mc.database.Name).C(db.IntervalAction).Find(query).One(&mia); err != nil {
return contract.IntervalActi... | go | func (mc MongoClient) IntervalActionByName(name string) (contract.IntervalAction, error) {
s := mc.getSessionCopy()
defer s.Close()
query := bson.M{"name": name}
mia := models.IntervalAction{}
if err := s.DB(mc.database.Name).C(db.IntervalAction).Find(query).One(&mia); err != nil {
return contract.IntervalActi... | [
"func",
"(",
"mc",
"MongoClient",
")",
"IntervalActionByName",
"(",
"name",
"string",
")",
"(",
"contract",
".",
"IntervalAction",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n... | // Return an Interval Action by name
// UnexpectedError - failed to retrieve interval actions from the database
// Sort the interval actions in descending order by ID | [
"Return",
"an",
"Interval",
"Action",
"by",
"name",
"UnexpectedError",
"-",
"failed",
"to",
"retrieve",
"interval",
"actions",
"from",
"the",
"database",
"Sort",
"the",
"interval",
"actions",
"in",
"descending",
"order",
"by",
"ID"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L173-L184 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | AddIntervalAction | func (mc MongoClient) AddIntervalAction(action contract.IntervalAction) (string, error) {
s := mc.getSessionCopy()
defer s.Close()
var mapped models.IntervalAction
id, err := mapped.FromContract(action)
if err != nil {
return "", err
}
// See if the name is unique and add the value descriptors
found, err :=... | go | func (mc MongoClient) AddIntervalAction(action contract.IntervalAction) (string, error) {
s := mc.getSessionCopy()
defer s.Close()
var mapped models.IntervalAction
id, err := mapped.FromContract(action)
if err != nil {
return "", err
}
// See if the name is unique and add the value descriptors
found, err :=... | [
"func",
"(",
"mc",
"MongoClient",
")",
"AddIntervalAction",
"(",
"action",
"contract",
".",
"IntervalAction",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
":=",
"mc",
".",
"getSessionCopy",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\... | // Add a new Interval Action
// UnexpectedError - failed to add interval action into the database | [
"Add",
"a",
"new",
"Interval",
"Action",
"UnexpectedError",
"-",
"failed",
"to",
"add",
"interval",
"action",
"into",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L188-L211 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | UpdateIntervalAction | func (mc MongoClient) UpdateIntervalAction(action contract.IntervalAction) error {
var mapped models.IntervalAction
id, err := mapped.FromContract(action)
if err != nil {
return err
}
mapped.TimestampForUpdate()
return mc.updateId(db.IntervalAction, id, mapped)
} | go | func (mc MongoClient) UpdateIntervalAction(action contract.IntervalAction) error {
var mapped models.IntervalAction
id, err := mapped.FromContract(action)
if err != nil {
return err
}
mapped.TimestampForUpdate()
return mc.updateId(db.IntervalAction, id, mapped)
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"UpdateIntervalAction",
"(",
"action",
"contract",
".",
"IntervalAction",
")",
"error",
"{",
"var",
"mapped",
"models",
".",
"IntervalAction",
"\n",
"id",
",",
"err",
":=",
"mapped",
".",
"FromContract",
"(",
"action",
... | // Update an Interval Action
// UnexpectedError - failed to update interval action in the database | [
"Update",
"an",
"Interval",
"Action",
"UnexpectedError",
"-",
"failed",
"to",
"update",
"interval",
"action",
"in",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L215-L225 | train |
edgexfoundry/edgex-go | internal/pkg/db/mongo/scheduler.go | DeleteIntervalActionById | func (mc MongoClient) DeleteIntervalActionById(id string) error {
return mc.deleteById(db.IntervalAction, id)
} | go | func (mc MongoClient) DeleteIntervalActionById(id string) error {
return mc.deleteById(db.IntervalAction, id)
} | [
"func",
"(",
"mc",
"MongoClient",
")",
"DeleteIntervalActionById",
"(",
"id",
"string",
")",
"error",
"{",
"return",
"mc",
".",
"deleteById",
"(",
"db",
".",
"IntervalAction",
",",
"id",
")",
"\n",
"}"
] | // Remove an Interval Action by ID
// UnexpectedError - failed to remove interval action from the database | [
"Remove",
"an",
"Interval",
"Action",
"by",
"ID",
"UnexpectedError",
"-",
"failed",
"to",
"remove",
"interval",
"action",
"from",
"the",
"database"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/mongo/scheduler.go#L229-L231 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/client.go | NewClient | func NewClient(config db.Configuration) (*Client, error) {
once.Do(func() {
connectionString := fmt.Sprintf("%s:%d", config.Host, config.Port)
opts := []redis.DialOption{
redis.DialPassword(config.Password),
redis.DialConnectTimeout(time.Duration(config.Timeout) * time.Millisecond),
}
dialFunc := func()... | go | func NewClient(config db.Configuration) (*Client, error) {
once.Do(func() {
connectionString := fmt.Sprintf("%s:%d", config.Host, config.Port)
opts := []redis.DialOption{
redis.DialPassword(config.Password),
redis.DialConnectTimeout(time.Duration(config.Timeout) * time.Millisecond),
}
dialFunc := func()... | [
"func",
"NewClient",
"(",
"config",
"db",
".",
"Configuration",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"connectionString",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"config",
".",
"H... | // Return a pointer to the Redis client | [
"Return",
"a",
"pointer",
"to",
"the",
"Redis",
"client"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/client.go#L35-L69 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/client.go | CloseSession | func (c *Client) CloseSession() {
c.Pool.Close()
currClient = nil
once = sync.Once{}
} | go | func (c *Client) CloseSession() {
c.Pool.Close()
currClient = nil
once = sync.Once{}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CloseSession",
"(",
")",
"{",
"c",
".",
"Pool",
".",
"Close",
"(",
")",
"\n",
"currClient",
"=",
"nil",
"\n",
"once",
"=",
"sync",
".",
"Once",
"{",
"}",
"\n",
"}"
] | // CloseSession closes the connections to Redis | [
"CloseSession",
"closes",
"the",
"connections",
"to",
"Redis"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/client.go#L77-L81 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/client.go | getConnection | func getConnection() (conn redis.Conn, err error) {
if currClient == nil {
return nil, errors.New("No current Redis client: create a new client before getting a connection from it")
}
conn = currClient.Pool.Get()
return conn, nil
} | go | func getConnection() (conn redis.Conn, err error) {
if currClient == nil {
return nil, errors.New("No current Redis client: create a new client before getting a connection from it")
}
conn = currClient.Pool.Get()
return conn, nil
} | [
"func",
"getConnection",
"(",
")",
"(",
"conn",
"redis",
".",
"Conn",
",",
"err",
"error",
")",
"{",
"if",
"currClient",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"conn",
"=",
"currClient... | // getConnection gets a connection from the pool | [
"getConnection",
"gets",
"a",
"connection",
"from",
"the",
"pool"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/client.go#L84-L91 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | IntervalByName | func (c *Client) IntervalByName(name string) (interval contract.Interval, err error) {
conn := c.Pool.Get()
defer conn.Close()
err = getObjectByKey(conn, models.IntervalNameKey, name, &interval)
return interval, err
} | go | func (c *Client) IntervalByName(name string) (interval contract.Interval, err error) {
conn := c.Pool.Get()
defer conn.Close()
err = getObjectByKey(conn, models.IntervalNameKey, name, &interval)
return interval, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"IntervalByName",
"(",
"name",
"string",
")",
"(",
"interval",
"contract",
".",
"Interval",
",",
"err",
"error",
")",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Clos... | // Return schedule interval by name | [
"Return",
"schedule",
"interval",
"by",
"name"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L73-L79 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | IntervalById | func (c *Client) IntervalById(id string) (interval contract.Interval, err error) {
conn := c.Pool.Get()
defer conn.Close()
object, err := redis.Bytes(conn.Do("GET", id))
if err == redis.ErrNil {
return contract.Interval{}, db.ErrNotFound
} else if err != nil {
return contract.Interval{}, err
}
err = json.U... | go | func (c *Client) IntervalById(id string) (interval contract.Interval, err error) {
conn := c.Pool.Get()
defer conn.Close()
object, err := redis.Bytes(conn.Do("GET", id))
if err == redis.ErrNil {
return contract.Interval{}, db.ErrNotFound
} else if err != nil {
return contract.Interval{}, err
}
err = json.U... | [
"func",
"(",
"c",
"*",
"Client",
")",
"IntervalById",
"(",
"id",
"string",
")",
"(",
"interval",
"contract",
".",
"Interval",
",",
"err",
"error",
")",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
"Close",
... | // Return schedule interval by ID | [
"Return",
"schedule",
"interval",
"by",
"ID"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L82-L99 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | AddInterval | func (c *Client) AddInterval(from contract.Interval) (id string, err error) {
interval := models.NewInterval(from)
if interval.ID != "" {
_, err = uuid.Parse(interval.ID)
if err != nil {
return "", db.ErrInvalidObjectId
}
} else {
interval.ID = uuid.New().String()
}
if interval.Timestamps.Created == 0 ... | go | func (c *Client) AddInterval(from contract.Interval) (id string, err error) {
interval := models.NewInterval(from)
if interval.ID != "" {
_, err = uuid.Parse(interval.ID)
if err != nil {
return "", db.ErrInvalidObjectId
}
} else {
interval.ID = uuid.New().String()
}
if interval.Timestamps.Created == 0 ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddInterval",
"(",
"from",
"contract",
".",
"Interval",
")",
"(",
"id",
"string",
",",
"err",
"error",
")",
"{",
"interval",
":=",
"models",
".",
"NewInterval",
"(",
"from",
")",
"\n",
"if",
"interval",
".",
"ID... | // Add a new schedule interval | [
"Add",
"a",
"new",
"schedule",
"interval"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L102-L132 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | UpdateInterval | func (c *Client) UpdateInterval(from contract.Interval) (err error) {
check, err := c.IntervalByName(from.Name)
if err != nil && err != redis.ErrNil {
return err
}
if err == nil && from.ID != check.ID {
// IDs are different -> name not unique
return db.ErrNotUnique
}
from.Timestamps.Modified = db.MakeTimes... | go | func (c *Client) UpdateInterval(from contract.Interval) (err error) {
check, err := c.IntervalByName(from.Name)
if err != nil && err != redis.ErrNil {
return err
}
if err == nil && from.ID != check.ID {
// IDs are different -> name not unique
return db.ErrNotUnique
}
from.Timestamps.Modified = db.MakeTimes... | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateInterval",
"(",
"from",
"contract",
".",
"Interval",
")",
"(",
"err",
"error",
")",
"{",
"check",
",",
"err",
":=",
"c",
".",
"IntervalByName",
"(",
"from",
".",
"Name",
")",
"\n",
"if",
"err",
"!=",
"ni... | // Update a schedule interval | [
"Update",
"a",
"schedule",
"interval"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L135-L166 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | DeleteIntervalById | func (c *Client) DeleteIntervalById(id string) (err error) {
check, err := c.IntervalById(id)
if err != nil {
if err == db.ErrNotFound {
return nil
}
return
}
interval := models.NewInterval(check)
conn := c.Pool.Get()
defer conn.Close()
_ = conn.Send("MULTI")
deleteObject(interval, id, conn)
_, err... | go | func (c *Client) DeleteIntervalById(id string) (err error) {
check, err := c.IntervalById(id)
if err != nil {
if err == db.ErrNotFound {
return nil
}
return
}
interval := models.NewInterval(check)
conn := c.Pool.Get()
defer conn.Close()
_ = conn.Send("MULTI")
deleteObject(interval, id, conn)
_, err... | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteIntervalById",
"(",
"id",
"string",
")",
"(",
"err",
"error",
")",
"{",
"check",
",",
"err",
":=",
"c",
".",
"IntervalById",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"db"... | // Remove schedule interval by ID | [
"Remove",
"schedule",
"interval",
"by",
"ID"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L169-L188 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | IntervalActionById | func (c *Client) IntervalActionById(id string) (action contract.IntervalAction, err error) {
conn := c.Pool.Get()
defer conn.Close()
object, err := redis.Bytes(conn.Do("GET", id))
if err == redis.ErrNil {
return contract.IntervalAction{}, db.ErrNotFound
} else if err != nil {
return contract.IntervalAction{},... | go | func (c *Client) IntervalActionById(id string) (action contract.IntervalAction, err error) {
conn := c.Pool.Get()
defer conn.Close()
object, err := redis.Bytes(conn.Do("GET", id))
if err == redis.ErrNil {
return contract.IntervalAction{}, db.ErrNotFound
} else if err != nil {
return contract.IntervalAction{},... | [
"func",
"(",
"c",
"*",
"Client",
")",
"IntervalActionById",
"(",
"id",
"string",
")",
"(",
"action",
"contract",
".",
"IntervalAction",
",",
"err",
"error",
")",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".",
... | // Get schedule interval action by id | [
"Get",
"schedule",
"interval",
"action",
"by",
"id"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L296-L313 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | IntervalActionByName | func (c *Client) IntervalActionByName(name string) (action contract.IntervalAction, err error) {
conn := c.Pool.Get()
defer conn.Close()
err = getObjectByKey(conn, models.IntervalActionNameKey, name, &action)
return action, err
} | go | func (c *Client) IntervalActionByName(name string) (action contract.IntervalAction, err error) {
conn := c.Pool.Get()
defer conn.Close()
err = getObjectByKey(conn, models.IntervalActionNameKey, name, &action)
return action, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"IntervalActionByName",
"(",
"name",
"string",
")",
"(",
"action",
"contract",
".",
"IntervalAction",
",",
"err",
"error",
")",
"{",
"conn",
":=",
"c",
".",
"Pool",
".",
"Get",
"(",
")",
"\n",
"defer",
"conn",
".... | // Get schedule interval action by name | [
"Get",
"schedule",
"interval",
"action",
"by",
"name"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L316-L322 | train |
edgexfoundry/edgex-go | internal/pkg/db/redis/scheduler.go | AddIntervalAction | func (c *Client) AddIntervalAction(from contract.IntervalAction) (id string, err error) {
action := models.NewIntervalAction(from)
if action.ID != "" {
_, err = uuid.Parse(action.ID)
if err != nil {
return "", db.ErrInvalidObjectId
}
} else {
action.ID = uuid.New().String()
}
if action.Created == 0 {
... | go | func (c *Client) AddIntervalAction(from contract.IntervalAction) (id string, err error) {
action := models.NewIntervalAction(from)
if action.ID != "" {
_, err = uuid.Parse(action.ID)
if err != nil {
return "", db.ErrInvalidObjectId
}
} else {
action.ID = uuid.New().String()
}
if action.Created == 0 {
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddIntervalAction",
"(",
"from",
"contract",
".",
"IntervalAction",
")",
"(",
"id",
"string",
",",
"err",
"error",
")",
"{",
"action",
":=",
"models",
".",
"NewIntervalAction",
"(",
"from",
")",
"\n",
"if",
"action"... | // Add schedule interval action | [
"Add",
"schedule",
"interval",
"action"
] | c67086fe10c4d34caeefffaee5379490103dd63f | https://github.com/edgexfoundry/edgex-go/blob/c67086fe10c4d34caeefffaee5379490103dd63f/internal/pkg/db/redis/scheduler.go#L325-L355 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.