id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
139,000 | minero/minero-go | material/material.go | IsItem | func (m Material) IsItem() bool {
if m >= MinItem && m <= MaxItem {
return true
}
if m.IsDisc() {
return true
}
return false
} | go | func (m Material) IsItem() bool {
if m >= MinItem && m <= MaxItem {
return true
}
if m.IsDisc() {
return true
}
return false
} | [
"func",
"(",
"m",
"Material",
")",
"IsItem",
"(",
")",
"bool",
"{",
"if",
"m",
">=",
"MinItem",
"&&",
"m",
"<=",
"MaxItem",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"m",
".",
"IsDisc",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"ret... | // IsItem returns true if m is an item. | [
"IsItem",
"returns",
"true",
"if",
"m",
"is",
"an",
"item",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/material/material.go#L78-L86 |
139,001 | minero/minero-go | material/material.go | IsSolid | func (m Material) IsSolid() bool {
if !m.IsBlock() || m == Air {
return false
}
switch m {
case Stone, Grass, Dirt, Cobblestone, WoodPlanks, Bedrock, Sand, Gravel,
OreGold, OreIron, OreCoal, Wood, Leaves, Sponge, Glass, OreLapisLazuli,
LapisLazuli, Dispenser, Sandstone, Note, Bed, Piston, PistonExtension,
W... | go | func (m Material) IsSolid() bool {
if !m.IsBlock() || m == Air {
return false
}
switch m {
case Stone, Grass, Dirt, Cobblestone, WoodPlanks, Bedrock, Sand, Gravel,
OreGold, OreIron, OreCoal, Wood, Leaves, Sponge, Glass, OreLapisLazuli,
LapisLazuli, Dispenser, Sandstone, Note, Bed, Piston, PistonExtension,
W... | [
"func",
"(",
"m",
"Material",
")",
"IsSolid",
"(",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"IsBlock",
"(",
")",
"||",
"m",
"==",
"Air",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"m",
"{",
"case",
"Stone",
",",
"Grass",
",",
"Dirt",
",",... | // IsSolid returns true if m is solid block. | [
"IsSolid",
"returns",
"true",
"if",
"m",
"is",
"solid",
"block",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/material/material.go#L105-L132 |
139,002 | minero/minero-go | material/material.go | IsTransparent | func (m Material) IsTransparent() bool {
if !m.IsBlock() {
return false
}
switch m {
case Air, Sapling, RailPowered, RailDetector, TallGrass, DeadBush,
FlowerYellow, FlowerRed, MushroomBrown, MushroomRed, Torch, Fire,
RedstoneWire, Wheat, Ladder, Rail, Lever, RedstoneTorch,
RedstoneTorchOn, ButtonStone, Sno... | go | func (m Material) IsTransparent() bool {
if !m.IsBlock() {
return false
}
switch m {
case Air, Sapling, RailPowered, RailDetector, TallGrass, DeadBush,
FlowerYellow, FlowerRed, MushroomBrown, MushroomRed, Torch, Fire,
RedstoneWire, Wheat, Ladder, Rail, Lever, RedstoneTorch,
RedstoneTorchOn, ButtonStone, Sno... | [
"func",
"(",
"m",
"Material",
")",
"IsTransparent",
"(",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"IsBlock",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"m",
"{",
"case",
"Air",
",",
"Sapling",
",",
"RailPowered",
",",
"RailDetector",
... | // IsTransparent returns true if m is a block and does not block any light. | [
"IsTransparent",
"returns",
"true",
"if",
"m",
"is",
"a",
"block",
"and",
"does",
"not",
"block",
"any",
"light",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/material/material.go#L135-L151 |
139,003 | minero/minero-go | material/material.go | IsFlammable | func (m Material) IsFlammable() bool {
if !m.IsBlock() {
return false
}
switch m {
case WoodPlanks, Wood, Leaves, Note, Bed, TallGrass, DeadBush, Wool, Tnt,
Bookshelf, StairsWoodOak, Chest, CraftingTable, SignPost, DoorWood,
SignWall, PlateWood, Jukebox, Fence, ChestLocked, Trapdoor,
MushroomBrownHuge, Mush... | go | func (m Material) IsFlammable() bool {
if !m.IsBlock() {
return false
}
switch m {
case WoodPlanks, Wood, Leaves, Note, Bed, TallGrass, DeadBush, Wool, Tnt,
Bookshelf, StairsWoodOak, Chest, CraftingTable, SignPost, DoorWood,
SignWall, PlateWood, Jukebox, Fence, ChestLocked, Trapdoor,
MushroomBrownHuge, Mush... | [
"func",
"(",
"m",
"Material",
")",
"IsFlammable",
"(",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"IsBlock",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"m",
"{",
"case",
"WoodPlanks",
",",
"Wood",
",",
"Leaves",
",",
"Note",
",",
"B... | // IsFlammable returns true if m is a block and can catch fire. | [
"IsFlammable",
"returns",
"true",
"if",
"m",
"is",
"a",
"block",
"and",
"can",
"catch",
"fire",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/material/material.go#L154-L168 |
139,004 | minero/minero-go | material/material.go | IsBurnable | func (m Material) IsBurnable() bool {
if !m.IsBlock() {
return false
}
switch m {
case WoodPlanks, Wood, Leaves, TallGrass, Wool, Tnt, Bookshelf,
StairsWoodOak, Fence, Vine, SlabDoubleWood, SlabWood, StairsSpruceWood,
StairsBirchWood, StairsJungleWood:
return true
}
return false
} | go | func (m Material) IsBurnable() bool {
if !m.IsBlock() {
return false
}
switch m {
case WoodPlanks, Wood, Leaves, TallGrass, Wool, Tnt, Bookshelf,
StairsWoodOak, Fence, Vine, SlabDoubleWood, SlabWood, StairsSpruceWood,
StairsBirchWood, StairsJungleWood:
return true
}
return false
} | [
"func",
"(",
"m",
"Material",
")",
"IsBurnable",
"(",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"IsBlock",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"m",
"{",
"case",
"WoodPlanks",
",",
"Wood",
",",
"Leaves",
",",
"TallGrass",
",",
... | // IsBurnable returns true if m is a block and can burn away. | [
"IsBurnable",
"returns",
"true",
"if",
"m",
"is",
"a",
"block",
"and",
"can",
"burn",
"away",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/material/material.go#L171-L182 |
139,005 | minero/minero-go | material/material.go | IsOccluding | func (m Material) IsOccluding() bool {
if !m.IsBlock() {
return false
}
switch m {
case Stone, Grass, Dirt, Cobblestone, WoodPlanks, Bedrock, Sand, Gravel,
OreGold, OreIron, OreCoal, Wood, Sponge, OreLapisLazuli, LapisLazuli,
Dispenser, Sandstone, Note, Wool, Gold, Iron, SlabDouble, Brick,
Bookshelf, MossSt... | go | func (m Material) IsOccluding() bool {
if !m.IsBlock() {
return false
}
switch m {
case Stone, Grass, Dirt, Cobblestone, WoodPlanks, Bedrock, Sand, Gravel,
OreGold, OreIron, OreCoal, Wood, Sponge, OreLapisLazuli, LapisLazuli,
Dispenser, Sandstone, Note, Wool, Gold, Iron, SlabDouble, Brick,
Bookshelf, MossSt... | [
"func",
"(",
"m",
"Material",
")",
"IsOccluding",
"(",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"IsBlock",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"m",
"{",
"case",
"Stone",
",",
"Grass",
",",
"Dirt",
",",
"Cobblestone",
",",
"... | // IsOccluding returns true if m is a block and completely blocks vision. | [
"IsOccluding",
"returns",
"true",
"if",
"m",
"is",
"a",
"block",
"and",
"completely",
"blocks",
"vision",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/material/material.go#L185-L203 |
139,006 | minero/minero-go | material/material.go | HasGravity | func (m Material) HasGravity() bool {
if !m.IsBlock() {
return false
}
switch m {
case Sand, Gravel, Anvil:
return true
}
return false
} | go | func (m Material) HasGravity() bool {
if !m.IsBlock() {
return false
}
switch m {
case Sand, Gravel, Anvil:
return true
}
return false
} | [
"func",
"(",
"m",
"Material",
")",
"HasGravity",
"(",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"IsBlock",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"m",
"{",
"case",
"Sand",
",",
"Gravel",
",",
"Anvil",
":",
"return",
"true",
"\n... | // HasGravity returns true if m is affected by gravity. | [
"HasGravity",
"returns",
"true",
"if",
"m",
"is",
"affected",
"by",
"gravity",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/material/material.go#L206-L215 |
139,007 | minero/minero-go | config/config.go | Copy | func (c Config) Copy() (m Map) {
m = make(Map)
for k, v := range c.root {
m[k] = v
}
return
} | go | func (c Config) Copy() (m Map) {
m = make(Map)
for k, v := range c.root {
m[k] = v
}
return
} | [
"func",
"(",
"c",
"Config",
")",
"Copy",
"(",
")",
"(",
"m",
"Map",
")",
"{",
"m",
"=",
"make",
"(",
"Map",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"c",
".",
"root",
"{",
"m",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
... | // Copy copies this Config's underlying Map and returns that copy. | [
"Copy",
"copies",
"this",
"Config",
"s",
"underlying",
"Map",
"and",
"returns",
"that",
"copy",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/config/config.go#L39-L45 |
139,008 | minero/minero-go | config/config.go | Parse | func (c Config) Parse(s string) error {
c.file = "<string>"
c.input = s
return c.parse()
} | go | func (c Config) Parse(s string) error {
c.file = "<string>"
c.input = s
return c.parse()
} | [
"func",
"(",
"c",
"Config",
")",
"Parse",
"(",
"s",
"string",
")",
"error",
"{",
"c",
".",
"file",
"=",
"\"",
"\"",
"\n",
"c",
".",
"input",
"=",
"s",
"\n",
"return",
"c",
".",
"parse",
"(",
")",
"\n",
"}"
] | // Parse parses a string into a config. | [
"Parse",
"parses",
"a",
"string",
"into",
"a",
"config",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/config/config.go#L48-L52 |
139,009 | minero/minero-go | config/config.go | ParseFile | func (c Config) ParseFile(f string) error {
buf, err := ioutil.ReadFile(f)
if err != nil {
return fmt.Errorf("Couldn't read config file %q", f)
}
c.file = f
c.input = string(buf)
return c.parse()
} | go | func (c Config) ParseFile(f string) error {
buf, err := ioutil.ReadFile(f)
if err != nil {
return fmt.Errorf("Couldn't read config file %q", f)
}
c.file = f
c.input = string(buf)
return c.parse()
} | [
"func",
"(",
"c",
"Config",
")",
"ParseFile",
"(",
"f",
"string",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"f",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"... | // Parse parses a file's contents into a config. | [
"Parse",
"parses",
"a",
"file",
"s",
"contents",
"into",
"a",
"config",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/config/config.go#L55-L63 |
139,010 | minero/minero-go | config/config.go | Save | func (c Config) Save(file string) error {
var s = fileOutput(c.root)
return ioutil.WriteFile(file, []byte(s), 0666)
} | go | func (c Config) Save(file string) error {
var s = fileOutput(c.root)
return ioutil.WriteFile(file, []byte(s), 0666)
} | [
"func",
"(",
"c",
"Config",
")",
"Save",
"(",
"file",
"string",
")",
"error",
"{",
"var",
"s",
"=",
"fileOutput",
"(",
"c",
".",
"root",
")",
"\n",
"return",
"ioutil",
".",
"WriteFile",
"(",
"file",
",",
"[",
"]",
"byte",
"(",
"s",
")",
",",
"0... | // Save saves a config into a file. | [
"Save",
"saves",
"a",
"config",
"into",
"a",
"file",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/config/config.go#L66-L69 |
139,011 | minero/minero-go | util/must/must.go | Check | func (h *Handler) Check(err error) {
// Check iff there were no errors
if h.Err == nil {
h.Err = err
}
} | go | func (h *Handler) Check(err error) {
// Check iff there were no errors
if h.Err == nil {
h.Err = err
}
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"Check",
"(",
"err",
"error",
")",
"{",
"// Check iff there were no errors",
"if",
"h",
".",
"Err",
"==",
"nil",
"{",
"h",
".",
"Err",
"=",
"err",
"\n",
"}",
"\n",
"}"
] | // Check provides a hook for foreign functions returning errors. | [
"Check",
"provides",
"a",
"hook",
"for",
"foreign",
"functions",
"returning",
"errors",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/util/must/must.go#L10-L15 |
139,012 | minero/minero-go | proto/auth/auth.go | GenerateKeyPair | func GenerateKeyPair() *rsa.PrivateKey {
priv, err := rsa.GenerateKey(rand.Reader, 1024)
if err != nil {
return nil
}
return priv
} | go | func GenerateKeyPair() *rsa.PrivateKey {
priv, err := rsa.GenerateKey(rand.Reader, 1024)
if err != nil {
return nil
}
return priv
} | [
"func",
"GenerateKeyPair",
"(",
")",
"*",
"rsa",
".",
"PrivateKey",
"{",
"priv",
",",
"err",
":=",
"rsa",
".",
"GenerateKey",
"(",
"rand",
".",
"Reader",
",",
"1024",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"retu... | // GenerateKeyPair generates a 1024 bit RSA keypair. | [
"GenerateKeyPair",
"generates",
"a",
"1024",
"bit",
"RSA",
"keypair",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/proto/auth/auth.go#L12-L18 |
139,013 | minero/minero-go | id/id.go | Get | func (g *Generator) Get() int32 {
if !g.queue.empty() {
return g.queue.pop()
}
if g.max == math.MaxInt32 {
// Reset counter to 0? Can this be even possible?
atomic.StoreInt32(&g.max, 0)
return atomic.LoadInt32(&g.max)
}
return atomic.AddInt32(&g.max, 1)
} | go | func (g *Generator) Get() int32 {
if !g.queue.empty() {
return g.queue.pop()
}
if g.max == math.MaxInt32 {
// Reset counter to 0? Can this be even possible?
atomic.StoreInt32(&g.max, 0)
return atomic.LoadInt32(&g.max)
}
return atomic.AddInt32(&g.max, 1)
} | [
"func",
"(",
"g",
"*",
"Generator",
")",
"Get",
"(",
")",
"int32",
"{",
"if",
"!",
"g",
".",
"queue",
".",
"empty",
"(",
")",
"{",
"return",
"g",
".",
"queue",
".",
"pop",
"(",
")",
"\n",
"}",
"\n",
"if",
"g",
".",
"max",
"==",
"math",
".",... | // Get gets a free id. | [
"Get",
"gets",
"a",
"free",
"id",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/id/id.go#L20-L30 |
139,014 | minero/minero-go | id/id.go | push | func (s queue) push(v int32) {
if !s.full() {
s.Lock()
s.store = append(s.store, v)
s.len++
s.Unlock()
return
}
panic("can't push on full queue")
} | go | func (s queue) push(v int32) {
if !s.full() {
s.Lock()
s.store = append(s.store, v)
s.len++
s.Unlock()
return
}
panic("can't push on full queue")
} | [
"func",
"(",
"s",
"queue",
")",
"push",
"(",
"v",
"int32",
")",
"{",
"if",
"!",
"s",
".",
"full",
"(",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"store",
"=",
"append",
"(",
"s",
".",
"store",
",",
"v",
")",
"\n",
"s",
".",
... | // push adds an id to queue's end, will panic if queue is full. | [
"push",
"adds",
"an",
"id",
"to",
"queue",
"s",
"end",
"will",
"panic",
"if",
"queue",
"is",
"full",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/id/id.go#L62-L71 |
139,015 | minero/minero-go | id/id.go | pop | func (s queue) pop() (i int32) {
if !s.empty() {
s.Lock()
// Fetch value on top
i = s.store[0]
s.store = s.store[1:]
s.Unlock()
return
}
panic("can't pop on empty queue")
} | go | func (s queue) pop() (i int32) {
if !s.empty() {
s.Lock()
// Fetch value on top
i = s.store[0]
s.store = s.store[1:]
s.Unlock()
return
}
panic("can't pop on empty queue")
} | [
"func",
"(",
"s",
"queue",
")",
"pop",
"(",
")",
"(",
"i",
"int32",
")",
"{",
"if",
"!",
"s",
".",
"empty",
"(",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"// Fetch value on top",
"i",
"=",
"s",
".",
"store",
"[",
"0",
"]",
"\n",
"s",
"."... | // push pops deletes and returns an id from queue's start, will panic if queue
// is empty. | [
"push",
"pops",
"deletes",
"and",
"returns",
"an",
"id",
"from",
"queue",
"s",
"start",
"will",
"panic",
"if",
"queue",
"is",
"empty",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/id/id.go#L75-L85 |
139,016 | minero/minero-go | proto/nbt/util.go | Read | func Read(r io.Reader) (c *Compound, err error) {
// Read TagType
var tt TagType
if _, err = tt.ReadFrom(r); err != nil {
return nil, err
}
// TagType should be TagCompound
if tt != TagCompound {
return nil, ErrInvalidTop
}
// Read compound name
var name String
_, err = name.ReadFrom(r)
if err != nil {... | go | func Read(r io.Reader) (c *Compound, err error) {
// Read TagType
var tt TagType
if _, err = tt.ReadFrom(r); err != nil {
return nil, err
}
// TagType should be TagCompound
if tt != TagCompound {
return nil, ErrInvalidTop
}
// Read compound name
var name String
_, err = name.ReadFrom(r)
if err != nil {... | [
"func",
"Read",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"c",
"*",
"Compound",
",",
"err",
"error",
")",
"{",
"// Read TagType",
"var",
"tt",
"TagType",
"\n",
"if",
"_",
",",
"err",
"=",
"tt",
".",
"ReadFrom",
"(",
"r",
")",
";",
"err",
"!=",
"... | // Read reads an NBT compound from a byte stream. It doesn't handle compression. | [
"Read",
"reads",
"an",
"NBT",
"compound",
"from",
"a",
"byte",
"stream",
".",
"It",
"doesn",
"t",
"handle",
"compression",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/proto/nbt/util.go#L8-L35 |
139,017 | minero/minero-go | proto/nbt/util.go | Write | func Write(w io.Writer, c *Compound) (err error) {
if _, err = TagCompound.WriteTo(w); err != nil {
return
}
nameTag := &String{c.Name}
_, err = nameTag.WriteTo(w)
if err != nil {
return
}
_, err = c.WriteTo(w)
if err != nil {
return
}
return
} | go | func Write(w io.Writer, c *Compound) (err error) {
if _, err = TagCompound.WriteTo(w); err != nil {
return
}
nameTag := &String{c.Name}
_, err = nameTag.WriteTo(w)
if err != nil {
return
}
_, err = c.WriteTo(w)
if err != nil {
return
}
return
} | [
"func",
"Write",
"(",
"w",
"io",
".",
"Writer",
",",
"c",
"*",
"Compound",
")",
"(",
"err",
"error",
")",
"{",
"if",
"_",
",",
"err",
"=",
"TagCompound",
".",
"WriteTo",
"(",
"w",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
... | // Write writes an NBT compound to a byte stream. It doesn't handle compression. | [
"Write",
"writes",
"an",
"NBT",
"compound",
"to",
"a",
"byte",
"stream",
".",
"It",
"doesn",
"t",
"handle",
"compression",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/proto/nbt/util.go#L38-L55 |
139,018 | minero/minero-go | config/map.go | PrettyMap | func PrettyMap(m Map) string {
var keys []string
for k, _ := range m {
keys = append(keys, k)
}
sort.Strings(keys)
var values []string
for _, k := range keys {
values = append(values, fmt.Sprintf("%q: %s", k, m[k]))
}
r := strings.Join(values, "\n")
return fmt.Sprintf("%s", r)
} | go | func PrettyMap(m Map) string {
var keys []string
for k, _ := range m {
keys = append(keys, k)
}
sort.Strings(keys)
var values []string
for _, k := range keys {
values = append(values, fmt.Sprintf("%q: %s", k, m[k]))
}
r := strings.Join(values, "\n")
return fmt.Sprintf("%s", r)
} | [
"func",
"PrettyMap",
"(",
"m",
"Map",
")",
"string",
"{",
"var",
"keys",
"[",
"]",
"string",
"\n",
"for",
"k",
",",
"_",
":=",
"range",
"m",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"k",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
... | // PrettyMap sorts a Map by its keys and returns a pretty-printed string version. | [
"PrettyMap",
"sorts",
"a",
"Map",
"by",
"its",
"keys",
"and",
"returns",
"a",
"pretty",
"-",
"printed",
"string",
"version",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/config/map.go#L17-L30 |
139,019 | minero/minero-go | server/player/player.go | OnlineMode | func (p *Player) OnlineMode(m bool, secret []byte) {
p.crypto = m
if m {
p.Conn = cfb8.New(p.net, secret)
}
} | go | func (p *Player) OnlineMode(m bool, secret []byte) {
p.crypto = m
if m {
p.Conn = cfb8.New(p.net, secret)
}
} | [
"func",
"(",
"p",
"*",
"Player",
")",
"OnlineMode",
"(",
"m",
"bool",
",",
"secret",
"[",
"]",
"byte",
")",
"{",
"p",
".",
"crypto",
"=",
"m",
"\n",
"if",
"m",
"{",
"p",
".",
"Conn",
"=",
"cfb8",
".",
"New",
"(",
"p",
".",
"net",
",",
"secr... | // OnlineMode set's authentication on for p. Authentication is required for
// online_mode=true servers. | [
"OnlineMode",
"set",
"s",
"authentication",
"on",
"for",
"p",
".",
"Authentication",
"is",
"required",
"for",
"online_mode",
"=",
"true",
"servers",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/server/player/player.go#L53-L58 |
139,020 | minero/minero-go | server/player/player.go | SendMessage | func (p *Player) SendMessage(message string) {
pkt := &packet.ChatMessage{message}
pkt.WriteTo(p.Conn)
} | go | func (p *Player) SendMessage(message string) {
pkt := &packet.ChatMessage{message}
pkt.WriteTo(p.Conn)
} | [
"func",
"(",
"p",
"*",
"Player",
")",
"SendMessage",
"(",
"message",
"string",
")",
"{",
"pkt",
":=",
"&",
"packet",
".",
"ChatMessage",
"{",
"message",
"}",
"\n",
"pkt",
".",
"WriteTo",
"(",
"p",
".",
"Conn",
")",
"\n",
"}"
] | // SendMessage sends a chat message to p. | [
"SendMessage",
"sends",
"a",
"chat",
"message",
"to",
"p",
"."
] | 93368d43a80e4ef6ee2f0e65c84dd7bc7929135c | https://github.com/minero/minero-go/blob/93368d43a80e4ef6ee2f0e65c84dd7bc7929135c/server/player/player.go#L85-L88 |
139,021 | andreyvit/diff | trim.go | TrimLines | func TrimLines(input []string) []string {
result := make([]string, 0, len(input))
for _, el := range input {
result = append(result, strings.TrimSpace(el))
}
return result
} | go | func TrimLines(input []string) []string {
result := make([]string, 0, len(input))
for _, el := range input {
result = append(result, strings.TrimSpace(el))
}
return result
} | [
"func",
"TrimLines",
"(",
"input",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"input",
")",
")",
"\n",
"for",
"_",
",",
"el",
":=",
"range",
"input",
"{",
"resul... | // TrimLines applies TrimSpace to each string in the given array. | [
"TrimLines",
"applies",
"TrimSpace",
"to",
"each",
"string",
"in",
"the",
"given",
"array",
"."
] | c7f18ee00883bfd3b00e0a2bf7607827e0148ad4 | https://github.com/andreyvit/diff/blob/c7f18ee00883bfd3b00e0a2bf7607827e0148ad4/trim.go#L8-L14 |
139,022 | andreyvit/diff | trim.go | TrimLinesInString | func TrimLinesInString(input string) string {
return strings.Join(TrimLines(strings.Split(strings.TrimSpace(input), "\n")), "\n")
} | go | func TrimLinesInString(input string) string {
return strings.Join(TrimLines(strings.Split(strings.TrimSpace(input), "\n")), "\n")
} | [
"func",
"TrimLinesInString",
"(",
"input",
"string",
")",
"string",
"{",
"return",
"strings",
".",
"Join",
"(",
"TrimLines",
"(",
"strings",
".",
"Split",
"(",
"strings",
".",
"TrimSpace",
"(",
"input",
")",
",",
"\"",
"\\n",
"\"",
")",
")",
",",
"\"",... | // TrimLinesInString applies TrimSpace to each line in the given string, and returns the new trimmed string. Empty lines are not removed. | [
"TrimLinesInString",
"applies",
"TrimSpace",
"to",
"each",
"line",
"in",
"the",
"given",
"string",
"and",
"returns",
"the",
"new",
"trimmed",
"string",
".",
"Empty",
"lines",
"are",
"not",
"removed",
"."
] | c7f18ee00883bfd3b00e0a2bf7607827e0148ad4 | https://github.com/andreyvit/diff/blob/c7f18ee00883bfd3b00e0a2bf7607827e0148ad4/trim.go#L17-L19 |
139,023 | andreyvit/diff | diff.go | LineDiff | func LineDiff(a, b string) string {
return strings.Join(LineDiffAsLines(a, b), "\n")
} | go | func LineDiff(a, b string) string {
return strings.Join(LineDiffAsLines(a, b), "\n")
} | [
"func",
"LineDiff",
"(",
"a",
",",
"b",
"string",
")",
"string",
"{",
"return",
"strings",
".",
"Join",
"(",
"LineDiffAsLines",
"(",
"a",
",",
"b",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}"
] | // LineDiff returns a normal linewise diff between the two given strings. | [
"LineDiff",
"returns",
"a",
"normal",
"linewise",
"diff",
"between",
"the",
"two",
"given",
"strings",
"."
] | c7f18ee00883bfd3b00e0a2bf7607827e0148ad4 | https://github.com/andreyvit/diff/blob/c7f18ee00883bfd3b00e0a2bf7607827e0148ad4/diff.go#L46-L48 |
139,024 | itsjamie/gin-cors | cors.go | prepare | func (config *Config) prepare() {
config.origins = strings.Split(config.Origins, ", ")
config.methods = strings.Split(config.Methods, ", ")
config.requestHeaders = strings.Split(config.RequestHeaders, ", ")
config.maxAge = fmt.Sprintf("%.f", config.MaxAge.Seconds())
// Generates a boolean of value "true".
config... | go | func (config *Config) prepare() {
config.origins = strings.Split(config.Origins, ", ")
config.methods = strings.Split(config.Methods, ", ")
config.requestHeaders = strings.Split(config.RequestHeaders, ", ")
config.maxAge = fmt.Sprintf("%.f", config.MaxAge.Seconds())
// Generates a boolean of value "true".
config... | [
"func",
"(",
"config",
"*",
"Config",
")",
"prepare",
"(",
")",
"{",
"config",
".",
"origins",
"=",
"strings",
".",
"Split",
"(",
"config",
".",
"Origins",
",",
"\"",
"\"",
")",
"\n",
"config",
".",
"methods",
"=",
"strings",
".",
"Split",
"(",
"co... | // One time, do the conversion from our the public facing Configuration,
// to all the formats we use internally strings for headers.. slices for looping | [
"One",
"time",
"do",
"the",
"conversion",
"from",
"our",
"the",
"public",
"facing",
"Configuration",
"to",
"all",
"the",
"formats",
"we",
"use",
"internally",
"strings",
"for",
"headers",
"..",
"slices",
"for",
"looping"
] | 97b4a9da79331dfa2b6d35f4cdd1e50f5148859c | https://github.com/itsjamie/gin-cors/blob/97b4a9da79331dfa2b6d35f4cdd1e50f5148859c/cors.go#L87-L100 |
139,025 | itsjamie/gin-cors | cors.go | matchOrigin | func matchOrigin(origin string, config Config) bool {
for _, value := range config.origins {
if value == origin {
return true
}
}
return false
} | go | func matchOrigin(origin string, config Config) bool {
for _, value := range config.origins {
if value == origin {
return true
}
}
return false
} | [
"func",
"matchOrigin",
"(",
"origin",
"string",
",",
"config",
"Config",
")",
"bool",
"{",
"for",
"_",
",",
"value",
":=",
"range",
"config",
".",
"origins",
"{",
"if",
"value",
"==",
"origin",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"retu... | // Case-sensitive match of origin header | [
"Case",
"-",
"sensitive",
"match",
"of",
"origin",
"header"
] | 97b4a9da79331dfa2b6d35f4cdd1e50f5148859c | https://github.com/itsjamie/gin-cors/blob/97b4a9da79331dfa2b6d35f4cdd1e50f5148859c/cors.go#L206-L213 |
139,026 | itsjamie/gin-cors | cors.go | validateRequestMethod | func validateRequestMethod(requestMethod string, config Config) bool {
if !config.ValidateHeaders {
return true
}
if requestMethod != "" {
for _, value := range config.methods {
if value == requestMethod {
return true
}
}
}
return false
} | go | func validateRequestMethod(requestMethod string, config Config) bool {
if !config.ValidateHeaders {
return true
}
if requestMethod != "" {
for _, value := range config.methods {
if value == requestMethod {
return true
}
}
}
return false
} | [
"func",
"validateRequestMethod",
"(",
"requestMethod",
"string",
",",
"config",
"Config",
")",
"bool",
"{",
"if",
"!",
"config",
".",
"ValidateHeaders",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"if",
"requestMethod",
"!=",
"\"",
"\"",
"{",
"for",
"_",
","... | // Case-sensitive match of request method | [
"Case",
"-",
"sensitive",
"match",
"of",
"request",
"method"
] | 97b4a9da79331dfa2b6d35f4cdd1e50f5148859c | https://github.com/itsjamie/gin-cors/blob/97b4a9da79331dfa2b6d35f4cdd1e50f5148859c/cors.go#L216-L230 |
139,027 | itsjamie/gin-cors | cors.go | validateRequestHeaders | func validateRequestHeaders(requestHeaders string, config Config) bool {
if !config.ValidateHeaders {
return true
}
headers := strings.Split(requestHeaders, ",")
for _, header := range headers {
match := false
header = strings.ToLower(strings.Trim(header, " \t\r\n"))
for _, value := range config.requestH... | go | func validateRequestHeaders(requestHeaders string, config Config) bool {
if !config.ValidateHeaders {
return true
}
headers := strings.Split(requestHeaders, ",")
for _, header := range headers {
match := false
header = strings.ToLower(strings.Trim(header, " \t\r\n"))
for _, value := range config.requestH... | [
"func",
"validateRequestHeaders",
"(",
"requestHeaders",
"string",
",",
"config",
"Config",
")",
"bool",
"{",
"if",
"!",
"config",
".",
"ValidateHeaders",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"headers",
":=",
"strings",
".",
"Split",
"(",
"requestHeaders"... | // Case-insensitive match of request headers | [
"Case",
"-",
"insensitive",
"match",
"of",
"request",
"headers"
] | 97b4a9da79331dfa2b6d35f4cdd1e50f5148859c | https://github.com/itsjamie/gin-cors/blob/97b4a9da79331dfa2b6d35f4cdd1e50f5148859c/cors.go#L233-L257 |
139,028 | control-center/serviced | dfs/docker/docker.go | FindImageByHash | func (d *DockerClient) FindImageByHash(imageHash string, checkAllLayers bool) (*dockerclient.Image, error) {
opts := dockerclient.ListImagesOptions{
All: checkAllLayers,
Digests: false,
}
allImages, err := d.dc.ListImages(opts)
if err != nil {
return nil, err
}
for _, apiImage := range allImages {
i... | go | func (d *DockerClient) FindImageByHash(imageHash string, checkAllLayers bool) (*dockerclient.Image, error) {
opts := dockerclient.ListImagesOptions{
All: checkAllLayers,
Digests: false,
}
allImages, err := d.dc.ListImages(opts)
if err != nil {
return nil, err
}
for _, apiImage := range allImages {
i... | [
"func",
"(",
"d",
"*",
"DockerClient",
")",
"FindImageByHash",
"(",
"imageHash",
"string",
",",
"checkAllLayers",
"bool",
")",
"(",
"*",
"dockerclient",
".",
"Image",
",",
"error",
")",
"{",
"opts",
":=",
"dockerclient",
".",
"ListImagesOptions",
"{",
"All",... | // FindImageByHash searches all local images for an image with the given hash | [
"FindImageByHash",
"searches",
"all",
"local",
"images",
"for",
"an",
"image",
"with",
"the",
"given",
"hash"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/docker/docker.go#L313-L335 |
139,029 | control-center/serviced | domain/service/servicestore.go | Put | func (s *storeImpl) Put(ctx datastore.Context, svc *Service) error {
//No need to store ConfigFiles
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.Put"))
svc.ConfigFiles = make(map[string]servicedefinition.ConfigFile)
err := s.ds.Put(ctx, Key(svc.ID), svc)
if err == nil {
s.updateVolatileInfo(svc.ID... | go | func (s *storeImpl) Put(ctx datastore.Context, svc *Service) error {
//No need to store ConfigFiles
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.Put"))
svc.ConfigFiles = make(map[string]servicedefinition.ConfigFile)
err := s.ds.Put(ctx, Key(svc.ID), svc)
if err == nil {
s.updateVolatileInfo(svc.ID... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Put",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"svc",
"*",
"Service",
")",
"error",
"{",
"//No need to store ConfigFiles",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metrics",
... | // Put adds or updates a Service | [
"Put",
"adds",
"or",
"updates",
"a",
"Service"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L130-L140 |
139,030 | control-center/serviced | domain/service/servicestore.go | UpdateDesiredState | func (s *storeImpl) UpdateDesiredState(ctx datastore.Context, serviceID string, desiredState int) error {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"desiredState": desiredState,
}).Debug("Storing desiredState")
s.updateDesiredState(serviceID, desiredState, time.Now())
return nil
} | go | func (s *storeImpl) UpdateDesiredState(ctx datastore.Context, serviceID string, desiredState int) error {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"desiredState": desiredState,
}).Debug("Storing desiredState")
s.updateDesiredState(serviceID, desiredState, time.Now())
return nil
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"UpdateDesiredState",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceID",
"string",
",",
"desiredState",
"int",
")",
"error",
"{",
"plog",
".",
"WithFields",
"(",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",... | // UpdateDesiredState updates the DesiredState for the service by saving the information in volatile storage. | [
"UpdateDesiredState",
"updates",
"the",
"DesiredState",
"for",
"the",
"service",
"by",
"saving",
"the",
"information",
"in",
"volatile",
"storage",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L143-L150 |
139,031 | control-center/serviced | domain/service/servicestore.go | UpdateCurrentState | func (s *storeImpl) UpdateCurrentState(ctx datastore.Context, serviceID string, currentState string) error {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"currentState": currentState,
}).Debug("Storing currentState")
s.updateCurrentState(serviceID, currentState, time.Now())
return nil
} | go | func (s *storeImpl) UpdateCurrentState(ctx datastore.Context, serviceID string, currentState string) error {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"currentState": currentState,
}).Debug("Storing currentState")
s.updateCurrentState(serviceID, currentState, time.Now())
return nil
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"UpdateCurrentState",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceID",
"string",
",",
"currentState",
"string",
")",
"error",
"{",
"plog",
".",
"WithFields",
"(",
"log",
".",
"Fields",
"{",
"\"",
"\"",
"... | // UpdateCurrentState updates the CurrentState for the service by saving the information in volatile storage. | [
"UpdateCurrentState",
"updates",
"the",
"CurrentState",
"for",
"the",
"service",
"by",
"saving",
"the",
"information",
"in",
"volatile",
"storage",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L153-L160 |
139,032 | control-center/serviced | domain/service/servicestore.go | Get | func (s *storeImpl) Get(ctx datastore.Context, id string) (*Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.Get"))
// Get the service from elastic and fill additional info into the
// service object.
svc, err := s.get(ctx, id)
if err == nil {
s.fillAdditionalInfo(svc) // Mutex RLock
... | go | func (s *storeImpl) Get(ctx datastore.Context, id string) (*Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.Get"))
// Get the service from elastic and fill additional info into the
// service object.
svc, err := s.get(ctx, id)
if err == nil {
s.fillAdditionalInfo(svc) // Mutex RLock
... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"Get",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"id",
"string",
")",
"(",
"*",
"Service",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metrics",
"("... | // Get a Service by id. Return ErrNoSuchEntity if not found | [
"Get",
"a",
"Service",
"by",
"id",
".",
"Return",
"ErrNoSuchEntity",
"if",
"not",
"found"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L163-L172 |
139,033 | control-center/serviced | domain/service/servicestore.go | GetServices | func (s *storeImpl) GetServices(ctx datastore.Context) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetServices"))
return s.query(ctx, "_exists_:ID")
} | go | func (s *storeImpl) GetServices(ctx datastore.Context) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetServices"))
return s.query(ctx, "_exists_:ID")
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"GetServices",
"(",
"ctx",
"datastore",
".",
"Context",
")",
"(",
"[",
"]",
"Service",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metrics",
"(",
")",
"... | // GetServices returns all services | [
"GetServices",
"returns",
"all",
"services"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L194-L197 |
139,034 | control-center/serviced | domain/service/servicestore.go | GetUpdatedServices | func (s *storeImpl) GetUpdatedServices(ctx datastore.Context, since time.Duration) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetUpdatedServices"))
q := datastore.NewQuery(ctx)
t0 := time.Now().Add(-since)
t0s := t0.Format(time.RFC3339)
elasticQuery := search.Query().Range(sear... | go | func (s *storeImpl) GetUpdatedServices(ctx datastore.Context, since time.Duration) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetUpdatedServices"))
q := datastore.NewQuery(ctx)
t0 := time.Now().Add(-since)
t0s := t0.Format(time.RFC3339)
elasticQuery := search.Query().Range(sear... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"GetUpdatedServices",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"since",
"time",
".",
"Duration",
")",
"(",
"[",
"]",
"Service",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop... | // GetUpdatedServices returns all services updated since "since" time.Duration ago | [
"GetUpdatedServices",
"returns",
"all",
"services",
"updated",
"since",
"since",
"time",
".",
"Duration",
"ago"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L200-L218 |
139,035 | control-center/serviced | domain/service/servicestore.go | GetTaggedServices | func (s *storeImpl) GetTaggedServices(ctx datastore.Context, tags ...string) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetTaggedServices"))
if len(tags) == 0 {
return nil, errors.New("empty tags not allowed")
}
qs := strings.Join(tags, " AND ")
return s.query(ctx, qs)
} | go | func (s *storeImpl) GetTaggedServices(ctx datastore.Context, tags ...string) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetTaggedServices"))
if len(tags) == 0 {
return nil, errors.New("empty tags not allowed")
}
qs := strings.Join(tags, " AND ")
return s.query(ctx, qs)
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"GetTaggedServices",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"tags",
"...",
"string",
")",
"(",
"[",
"]",
"Service",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
... | // GetTaggedServices returns services with the given tags | [
"GetTaggedServices",
"returns",
"services",
"with",
"the",
"given",
"tags"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L221-L228 |
139,036 | control-center/serviced | domain/service/servicestore.go | GetServicesByPool | func (s *storeImpl) GetServicesByPool(ctx datastore.Context, poolID string) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetServicesByPool"))
id := strings.TrimSpace(poolID)
if id == "" {
return nil, errors.New("empty poolID not allowed")
}
q := datastore.NewQuery(ctx)
query :... | go | func (s *storeImpl) GetServicesByPool(ctx datastore.Context, poolID string) ([]Service, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetServicesByPool"))
id := strings.TrimSpace(poolID)
if id == "" {
return nil, errors.New("empty poolID not allowed")
}
q := datastore.NewQuery(ctx)
query :... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"GetServicesByPool",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"poolID",
"string",
")",
"(",
"[",
"]",
"Service",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
... | // GetServicesByPool returns services with the given pool id | [
"GetServicesByPool",
"returns",
"services",
"with",
"the",
"given",
"pool",
"id"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L231-L245 |
139,037 | control-center/serviced | domain/service/servicestore.go | GetServiceCountByImage | func (s *storeImpl) GetServiceCountByImage(ctx datastore.Context, imageID string) (int, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetServiceCountByImage"))
id := strings.TrimSpace(imageID)
if id == "" {
return 0, errors.New("empty imageID not allowed")
}
q := datastore.NewQuery(ctx)
qu... | go | func (s *storeImpl) GetServiceCountByImage(ctx datastore.Context, imageID string) (int, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetServiceCountByImage"))
id := strings.TrimSpace(imageID)
if id == "" {
return 0, errors.New("empty imageID not allowed")
}
q := datastore.NewQuery(ctx)
qu... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"GetServiceCountByImage",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"imageID",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Me... | // GetServiceCountByImage returns a count of services using a given imageid | [
"GetServiceCountByImage",
"returns",
"a",
"count",
"of",
"services",
"using",
"a",
"given",
"imageid"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L248-L262 |
139,038 | control-center/serviced | domain/service/servicestore.go | fillAdditionalInfo | func (s *storeImpl) fillAdditionalInfo(svc *Service) {
plog.WithFields(log.Fields{
"serviceId": svc.ID,
"serviceName": svc.Name,
}).Debug("Adding additional info to Elastic result")
s.fillConfig(svc)
// Update the service from volatile cached data.
cacheEntry, ok := s.getVolatileInfo(svc.ID) // Uses Mutex R... | go | func (s *storeImpl) fillAdditionalInfo(svc *Service) {
plog.WithFields(log.Fields{
"serviceId": svc.ID,
"serviceName": svc.Name,
}).Debug("Adding additional info to Elastic result")
s.fillConfig(svc)
// Update the service from volatile cached data.
cacheEntry, ok := s.getVolatileInfo(svc.ID) // Uses Mutex R... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"fillAdditionalInfo",
"(",
"svc",
"*",
"Service",
")",
"{",
"plog",
".",
"WithFields",
"(",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",
"svc",
".",
"ID",
",",
"\"",
"\"",
":",
"svc",
".",
"Name",
",",
"}",... | // fillAdditionalInfo fills the service object with additional information
// that amends or overrides what was retrieved from elastic | [
"fillAdditionalInfo",
"fills",
"the",
"service",
"object",
"with",
"additional",
"information",
"that",
"amends",
"or",
"overrides",
"what",
"was",
"retrieved",
"from",
"elastic"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L374-L389 |
139,039 | control-center/serviced | domain/service/servicestore.go | fillConfig | func (s *storeImpl) fillConfig(svc *Service) {
svc.ConfigFiles = make(map[string]servicedefinition.ConfigFile)
for key, val := range svc.OriginalConfigs {
svc.ConfigFiles[key] = val
}
} | go | func (s *storeImpl) fillConfig(svc *Service) {
svc.ConfigFiles = make(map[string]servicedefinition.ConfigFile)
for key, val := range svc.OriginalConfigs {
svc.ConfigFiles[key] = val
}
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"fillConfig",
"(",
"svc",
"*",
"Service",
")",
"{",
"svc",
".",
"ConfigFiles",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"servicedefinition",
".",
"ConfigFile",
")",
"\n",
"for",
"key",
",",
"val",
":=",
"r... | // fillConfig fills in the ConfigFiles values | [
"fillConfig",
"fills",
"in",
"the",
"ConfigFiles",
"values"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L392-L397 |
139,040 | control-center/serviced | domain/service/servicestore.go | addUpdatedServicesFromCache | func (s *storeImpl) addUpdatedServicesFromCache(ctx datastore.Context, svcs []Service, since time.Time) ([]Service, error) {
// Make a map of service ids so we don't duplicate services from our cache.
svcMap := make(map[string]struct{})
for _, svc := range svcs {
svcMap[svc.ID] = struct{}{}
}
// If getting thes... | go | func (s *storeImpl) addUpdatedServicesFromCache(ctx datastore.Context, svcs []Service, since time.Time) ([]Service, error) {
// Make a map of service ids so we don't duplicate services from our cache.
svcMap := make(map[string]struct{})
for _, svc := range svcs {
svcMap[svc.ID] = struct{}{}
}
// If getting thes... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"addUpdatedServicesFromCache",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"svcs",
"[",
"]",
"Service",
",",
"since",
"time",
".",
"Time",
")",
"(",
"[",
"]",
"Service",
",",
"error",
")",
"{",
"// Make a map of... | // Take the list of services and append services updated since 'since' | [
"Take",
"the",
"list",
"of",
"services",
"and",
"append",
"services",
"updated",
"since",
"since"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L419-L449 |
139,041 | control-center/serviced | domain/service/servicestore.go | updateServiceFromVolatileService | func (s *storeImpl) updateServiceFromVolatileService(svc *Service, cacheEntry volatileService) {
svc.DesiredState = cacheEntry.DesiredState
svc.CurrentState = cacheEntry.CurrentState
} | go | func (s *storeImpl) updateServiceFromVolatileService(svc *Service, cacheEntry volatileService) {
svc.DesiredState = cacheEntry.DesiredState
svc.CurrentState = cacheEntry.CurrentState
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"updateServiceFromVolatileService",
"(",
"svc",
"*",
"Service",
",",
"cacheEntry",
"volatileService",
")",
"{",
"svc",
".",
"DesiredState",
"=",
"cacheEntry",
".",
"DesiredState",
"\n",
"svc",
".",
"CurrentState",
"=",
... | // Update all properties of the service with data from our volatile structure. No
// mutex lock needed. | [
"Update",
"all",
"properties",
"of",
"the",
"service",
"with",
"data",
"from",
"our",
"volatile",
"structure",
".",
"No",
"mutex",
"lock",
"needed",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L453-L456 |
139,042 | control-center/serviced | domain/service/servicestore.go | updateVolatileInfo | func (s *storeImpl) updateVolatileInfo(serviceID string, desiredState int, updatedAt time.Time) error {
// Only update desired state. Current state should only be set explicitly
return s.updateDesiredState(serviceID, desiredState, updatedAt)
} | go | func (s *storeImpl) updateVolatileInfo(serviceID string, desiredState int, updatedAt time.Time) error {
// Only update desired state. Current state should only be set explicitly
return s.updateDesiredState(serviceID, desiredState, updatedAt)
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"updateVolatileInfo",
"(",
"serviceID",
"string",
",",
"desiredState",
"int",
",",
"updatedAt",
"time",
".",
"Time",
")",
"error",
"{",
"// Only update desired state. Current state should only be set explicitly",
"return",
"s",
... | // updateVolatileInfo updates the local cache for volatile information | [
"updateVolatileInfo",
"updates",
"the",
"local",
"cache",
"for",
"volatile",
"information"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L459-L462 |
139,043 | control-center/serviced | domain/service/servicestore.go | updateDesiredState | func (s *storeImpl) updateDesiredState(serviceID string, desiredState int, updatedAt time.Time) error {
// Validate desired state
if err := validation.IntIn(desiredState, int(SVCRun), int(SVCStop), int(SVCPause)); err != nil {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"desiredState": desiredState... | go | func (s *storeImpl) updateDesiredState(serviceID string, desiredState int, updatedAt time.Time) error {
// Validate desired state
if err := validation.IntIn(desiredState, int(SVCRun), int(SVCStop), int(SVCPause)); err != nil {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"desiredState": desiredState... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"updateDesiredState",
"(",
"serviceID",
"string",
",",
"desiredState",
"int",
",",
"updatedAt",
"time",
".",
"Time",
")",
"error",
"{",
"// Validate desired state",
"if",
"err",
":=",
"validation",
".",
"IntIn",
"(",
... | // updateDesiredState updates the local cache for desired state | [
"updateDesiredState",
"updates",
"the",
"local",
"cache",
"for",
"desired",
"state"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L465-L500 |
139,044 | control-center/serviced | domain/service/servicestore.go | updateCurrentState | func (s *storeImpl) updateCurrentState(serviceID string, currentState string, updatedAt time.Time) error {
// Validate desired state
if err := ServiceCurrentState(currentState).Validate(); err != nil {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"currentState": currentState,
}).Debug("Invalid Cur... | go | func (s *storeImpl) updateCurrentState(serviceID string, currentState string, updatedAt time.Time) error {
// Validate desired state
if err := ServiceCurrentState(currentState).Validate(); err != nil {
plog.WithFields(log.Fields{
"serviceID": serviceID,
"currentState": currentState,
}).Debug("Invalid Cur... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"updateCurrentState",
"(",
"serviceID",
"string",
",",
"currentState",
"string",
",",
"updatedAt",
"time",
".",
"Time",
")",
"error",
"{",
"// Validate desired state",
"if",
"err",
":=",
"ServiceCurrentState",
"(",
"curre... | // updateDesiredState updates the local cache for current state | [
"updateDesiredState",
"updates",
"the",
"local",
"cache",
"for",
"current",
"state"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L503-L538 |
139,045 | control-center/serviced | domain/service/servicestore.go | removeVolatileInfo | func (s *storeImpl) removeVolatileInfo(serviceID string) {
s.serviceCacheLock.Lock()
defer s.serviceCacheLock.Unlock()
delete(s.serviceCache, serviceID)
} | go | func (s *storeImpl) removeVolatileInfo(serviceID string) {
s.serviceCacheLock.Lock()
defer s.serviceCacheLock.Unlock()
delete(s.serviceCache, serviceID)
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"removeVolatileInfo",
"(",
"serviceID",
"string",
")",
"{",
"s",
".",
"serviceCacheLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"serviceCacheLock",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"s",
".... | // removeVolatileInfo removes the service's information from the local cache | [
"removeVolatileInfo",
"removes",
"the",
"service",
"s",
"information",
"from",
"the",
"local",
"cache"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L541-L545 |
139,046 | control-center/serviced | domain/service/servicestore.go | getVolatileInfo | func (s *storeImpl) getVolatileInfo(serviceID string) (volatileService, bool) {
s.serviceCacheLock.RLock()
defer s.serviceCacheLock.RUnlock()
cacheEntry, ok := s.serviceCache[serviceID]
if ok && cacheEntry.CurrentState == "" {
cacheEntry.CurrentState = string(SVCCSUnknown)
}
return cacheEntry, ok
} | go | func (s *storeImpl) getVolatileInfo(serviceID string) (volatileService, bool) {
s.serviceCacheLock.RLock()
defer s.serviceCacheLock.RUnlock()
cacheEntry, ok := s.serviceCache[serviceID]
if ok && cacheEntry.CurrentState == "" {
cacheEntry.CurrentState = string(SVCCSUnknown)
}
return cacheEntry, ok
} | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"getVolatileInfo",
"(",
"serviceID",
"string",
")",
"(",
"volatileService",
",",
"bool",
")",
"{",
"s",
".",
"serviceCacheLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"serviceCacheLock",
".",
"RUnlock",
... | // Returns the volatile data for a service id. | [
"Returns",
"the",
"volatile",
"data",
"for",
"a",
"service",
"id",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L548-L556 |
139,047 | control-center/serviced | domain/service/servicestore.go | getUpdatedCacheEntries | func (s *storeImpl) getUpdatedCacheEntries(since time.Time) []volatileService {
s.serviceCacheLock.RLock()
defer s.serviceCacheLock.RUnlock()
logger := plog.WithFields(log.Fields{
"since": since,
})
logger.Debug("Querying services updated since")
cacheEntries := []volatileService{}
for _, cacheEntry := range... | go | func (s *storeImpl) getUpdatedCacheEntries(since time.Time) []volatileService {
s.serviceCacheLock.RLock()
defer s.serviceCacheLock.RUnlock()
logger := plog.WithFields(log.Fields{
"since": since,
})
logger.Debug("Querying services updated since")
cacheEntries := []volatileService{}
for _, cacheEntry := range... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"getUpdatedCacheEntries",
"(",
"since",
"time",
".",
"Time",
")",
"[",
"]",
"volatileService",
"{",
"s",
".",
"serviceCacheLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"serviceCacheLock",
".",
"RUnlock",
... | // Returns the list of cache entries updated since the given time. | [
"Returns",
"the",
"list",
"of",
"cache",
"entries",
"updated",
"since",
"the",
"given",
"time",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/servicestore.go#L559-L577 |
139,048 | control-center/serviced | auth/localkeys.go | SignAsDelegate | func SignAsDelegate(message []byte) ([]byte, error) {
dKeyCond.RLock()
defer dKeyCond.RUnlock()
if delegateKeys.localPrivate == nil {
return nil, ErrNoPrivateKey
}
return delegateKeys.Sign(message)
} | go | func SignAsDelegate(message []byte) ([]byte, error) {
dKeyCond.RLock()
defer dKeyCond.RUnlock()
if delegateKeys.localPrivate == nil {
return nil, ErrNoPrivateKey
}
return delegateKeys.Sign(message)
} | [
"func",
"SignAsDelegate",
"(",
"message",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"dKeyCond",
".",
"RLock",
"(",
")",
"\n",
"defer",
"dKeyCond",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"delegateKeys",
".",
"localPrivate",
... | // SignAsDelegate signs the given message with the private key local
// to the delegate running this process. | [
"SignAsDelegate",
"signs",
"the",
"given",
"message",
"with",
"the",
"private",
"key",
"local",
"to",
"the",
"delegate",
"running",
"this",
"process",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L100-L107 |
139,049 | control-center/serviced | auth/localkeys.go | SignAsMaster | func SignAsMaster(message []byte) ([]byte, error) {
mKeyLock.RLock()
defer mKeyLock.RUnlock()
if masterKeys.private == nil {
return nil, ErrNoPrivateKey
}
return masterKeys.Sign(message)
} | go | func SignAsMaster(message []byte) ([]byte, error) {
mKeyLock.RLock()
defer mKeyLock.RUnlock()
if masterKeys.private == nil {
return nil, ErrNoPrivateKey
}
return masterKeys.Sign(message)
} | [
"func",
"SignAsMaster",
"(",
"message",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"mKeyLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"mKeyLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"masterKeys",
".",
"private",
"==",
"... | // SignAsMaster signs the given message with the master's private key
// will return an error if the delegate running this process is not the master | [
"SignAsMaster",
"signs",
"the",
"given",
"message",
"with",
"the",
"master",
"s",
"private",
"key",
"will",
"return",
"an",
"error",
"if",
"the",
"delegate",
"running",
"this",
"process",
"is",
"not",
"the",
"master"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L111-L118 |
139,050 | control-center/serviced | auth/localkeys.go | VerifyMasterSignature | func VerifyMasterSignature(message, signature []byte) error {
if err := verifyMasterSignatureAsMaster(message, signature); err != ErrNoPublicKey {
return err
}
dKeyCond.RLock()
defer dKeyCond.RUnlock()
if delegateKeys.masterPublic == nil {
return ErrNoPublicKey
}
return delegateKeys.Verify(message, signatur... | go | func VerifyMasterSignature(message, signature []byte) error {
if err := verifyMasterSignatureAsMaster(message, signature); err != ErrNoPublicKey {
return err
}
dKeyCond.RLock()
defer dKeyCond.RUnlock()
if delegateKeys.masterPublic == nil {
return ErrNoPublicKey
}
return delegateKeys.Verify(message, signatur... | [
"func",
"VerifyMasterSignature",
"(",
"message",
",",
"signature",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"verifyMasterSignatureAsMaster",
"(",
"message",
",",
"signature",
")",
";",
"err",
"!=",
"ErrNoPublicKey",
"{",
"return",
"err",
"\n",
... | // VerifyMasterSignature verifies that a given message was signed by the master
// whose public key we have. | [
"VerifyMasterSignature",
"verifies",
"that",
"a",
"given",
"message",
"was",
"signed",
"by",
"the",
"master",
"whose",
"public",
"key",
"we",
"have",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L122-L133 |
139,051 | control-center/serviced | auth/localkeys.go | LoadDelegateKeysFromFile | func LoadDelegateKeysFromFile(filename string) error {
pub, priv, err := LoadKeyPairFromFile(filename)
if err != nil {
return err
}
updateDelegateKeys(pub, priv)
return nil
} | go | func LoadDelegateKeysFromFile(filename string) error {
pub, priv, err := LoadKeyPairFromFile(filename)
if err != nil {
return err
}
updateDelegateKeys(pub, priv)
return nil
} | [
"func",
"LoadDelegateKeysFromFile",
"(",
"filename",
"string",
")",
"error",
"{",
"pub",
",",
"priv",
",",
"err",
":=",
"LoadKeyPairFromFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"updateDelegateKeys",
... | // LoadKeysFromFile loads keys from a file on disk. | [
"LoadKeysFromFile",
"loads",
"keys",
"from",
"a",
"file",
"on",
"disk",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L181-L188 |
139,052 | control-center/serviced | auth/localkeys.go | LoadMasterKeys | func LoadMasterKeys(public crypto.PublicKey, private crypto.PrivateKey) {
mKeyLock.Lock()
defer mKeyLock.Unlock()
masterKeys = MasterKeys{public, private}
} | go | func LoadMasterKeys(public crypto.PublicKey, private crypto.PrivateKey) {
mKeyLock.Lock()
defer mKeyLock.Unlock()
masterKeys = MasterKeys{public, private}
} | [
"func",
"LoadMasterKeys",
"(",
"public",
"crypto",
".",
"PublicKey",
",",
"private",
"crypto",
".",
"PrivateKey",
")",
"{",
"mKeyLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mKeyLock",
".",
"Unlock",
"(",
")",
"\n",
"masterKeys",
"=",
"MasterKeys",
"{",
... | // LoadMasterKeys sets the current master key pair to the one specified | [
"LoadMasterKeys",
"sets",
"the",
"current",
"master",
"key",
"pair",
"to",
"the",
"one",
"specified"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L191-L195 |
139,053 | control-center/serviced | auth/localkeys.go | CreateOrLoadMasterKeys | func CreateOrLoadMasterKeys(filename string) error {
if _, err := os.Stat(filename); os.IsNotExist(err) {
if err = os.MkdirAll(path.Dir(filename), os.ModeDir|0755); err != nil {
return err
}
pub, priv, err := GenerateRSAKeyPairPEM(nil)
if err != nil {
return err
}
err = DumpPEMKeyPairToFile(filename... | go | func CreateOrLoadMasterKeys(filename string) error {
if _, err := os.Stat(filename); os.IsNotExist(err) {
if err = os.MkdirAll(path.Dir(filename), os.ModeDir|0755); err != nil {
return err
}
pub, priv, err := GenerateRSAKeyPairPEM(nil)
if err != nil {
return err
}
err = DumpPEMKeyPairToFile(filename... | [
"func",
"CreateOrLoadMasterKeys",
"(",
"filename",
"string",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
";",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"if",
"err",
"=",
"os",
".",
"MkdirAll",
"(",
... | // CreateOrLoadMasterKeys will load the master keys from disk
// If the file does not exist, it will generate new keys and
// write them to disk. | [
"CreateOrLoadMasterKeys",
"will",
"load",
"the",
"master",
"keys",
"from",
"disk",
"If",
"the",
"file",
"does",
"not",
"exist",
"it",
"will",
"generate",
"new",
"keys",
"and",
"write",
"them",
"to",
"disk",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L200-L220 |
139,054 | control-center/serviced | auth/localkeys.go | LoadMasterKeyFile | func LoadMasterKeyFile(filename string) error {
publicKey, privateKey, err := LoadKeyPairFromFile(filename)
if err != nil {
return err
}
LoadMasterKeys(publicKey, privateKey)
return nil
} | go | func LoadMasterKeyFile(filename string) error {
publicKey, privateKey, err := LoadKeyPairFromFile(filename)
if err != nil {
return err
}
LoadMasterKeys(publicKey, privateKey)
return nil
} | [
"func",
"LoadMasterKeyFile",
"(",
"filename",
"string",
")",
"error",
"{",
"publicKey",
",",
"privateKey",
",",
"err",
":=",
"LoadKeyPairFromFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"LoadMasterKeys... | // LoadMasterKeyFile will load the master keys from disk if
// the file exists. If the file does not exist, it will
// return an error | [
"LoadMasterKeyFile",
"will",
"load",
"the",
"master",
"keys",
"from",
"disk",
"if",
"the",
"file",
"exists",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"it",
"will",
"return",
"an",
"error"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L225-L234 |
139,055 | control-center/serviced | auth/localkeys.go | DumpPEMKeyPairToFile | func DumpPEMKeyPairToFile(filename string, public, private []byte) error {
data, err := DumpRSAPEMKeyPair(public, private)
if err != nil {
return err
}
return ioutil.WriteFile(filename, data, 0666)
} | go | func DumpPEMKeyPairToFile(filename string, public, private []byte) error {
data, err := DumpRSAPEMKeyPair(public, private)
if err != nil {
return err
}
return ioutil.WriteFile(filename, data, 0666)
} | [
"func",
"DumpPEMKeyPairToFile",
"(",
"filename",
"string",
",",
"public",
",",
"private",
"[",
"]",
"byte",
")",
"error",
"{",
"data",
",",
"err",
":=",
"DumpRSAPEMKeyPair",
"(",
"public",
",",
"private",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // DumpPEMKeyPairToFile dumps PEM-encoded public and private keys to a single file | [
"DumpPEMKeyPairToFile",
"dumps",
"PEM",
"-",
"encoded",
"public",
"and",
"private",
"keys",
"to",
"a",
"single",
"file"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L237-L243 |
139,056 | control-center/serviced | auth/localkeys.go | LoadCommonRSAKeyPairPEM | func LoadCommonRSAKeyPairPEM(headers map[string]string) (public []byte, private []byte, err error) {
keyfile := filepath.Join(config.GetOptions().EtcPath, CommonKeyFilename)
publicKey, privateKey, err := LoadKeyPairFromFile(keyfile)
if err != nil {
return nil, nil, err
}
if private, err = PEMFromRSAPrivateKey(pr... | go | func LoadCommonRSAKeyPairPEM(headers map[string]string) (public []byte, private []byte, err error) {
keyfile := filepath.Join(config.GetOptions().EtcPath, CommonKeyFilename)
publicKey, privateKey, err := LoadKeyPairFromFile(keyfile)
if err != nil {
return nil, nil, err
}
if private, err = PEMFromRSAPrivateKey(pr... | [
"func",
"LoadCommonRSAKeyPairPEM",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"public",
"[",
"]",
"byte",
",",
"private",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"keyfile",
":=",
"filepath",
".",
"Join",
"(",
"config",
".",... | // LoadCommonRSAKeyPairPEM loads the common keys from a specific file. | [
"LoadCommonRSAKeyPairPEM",
"loads",
"the",
"common",
"keys",
"from",
"a",
"specific",
"file",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L256-L271 |
139,057 | control-center/serviced | auth/localkeys.go | LoadMasterKeysFromPEM | func LoadMasterKeysFromPEM(public, private []byte) error {
pub, priv, err := LoadRSAKeyPair(public, private)
if err != nil {
return err
}
mKeyLock.Lock()
defer mKeyLock.Unlock()
masterKeys = MasterKeys{pub, priv}
return nil
} | go | func LoadMasterKeysFromPEM(public, private []byte) error {
pub, priv, err := LoadRSAKeyPair(public, private)
if err != nil {
return err
}
mKeyLock.Lock()
defer mKeyLock.Unlock()
masterKeys = MasterKeys{pub, priv}
return nil
} | [
"func",
"LoadMasterKeysFromPEM",
"(",
"public",
",",
"private",
"[",
"]",
"byte",
")",
"error",
"{",
"pub",
",",
"priv",
",",
"err",
":=",
"LoadRSAKeyPair",
"(",
"public",
",",
"private",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",... | // LoadMasterKeysFromPEM loads the local master keys from PEM data passed in directly
// Useful mostly for writing tests | [
"LoadMasterKeysFromPEM",
"loads",
"the",
"local",
"master",
"keys",
"from",
"PEM",
"data",
"passed",
"in",
"directly",
"Useful",
"mostly",
"for",
"writing",
"tests"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L287-L297 |
139,058 | control-center/serviced | auth/localkeys.go | ClearKeys | func ClearKeys() {
mKeyLock.Lock()
masterKeys = MasterKeys{}
mKeyLock.Unlock()
updateDelegateKeys(nil, nil)
} | go | func ClearKeys() {
mKeyLock.Lock()
masterKeys = MasterKeys{}
mKeyLock.Unlock()
updateDelegateKeys(nil, nil)
} | [
"func",
"ClearKeys",
"(",
")",
"{",
"mKeyLock",
".",
"Lock",
"(",
")",
"\n",
"masterKeys",
"=",
"MasterKeys",
"{",
"}",
"\n",
"mKeyLock",
".",
"Unlock",
"(",
")",
"\n",
"updateDelegateKeys",
"(",
"nil",
",",
"nil",
")",
"\n",
"}"
] | // ClearKeys wipes the current state | [
"ClearKeys",
"wipes",
"the",
"current",
"state"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L300-L305 |
139,059 | control-center/serviced | auth/localkeys.go | WaitForDelegateKeys | func WaitForDelegateKeys(cancel <-chan interface{}) <-chan struct{} {
ch := make(chan struct{})
go func() {
for delegateKeys.localPrivate == nil || delegateKeys.masterPublic == nil {
select {
case <-dKeyCond.Wait():
case <-cancel: // Receive from nil channel never returns, so this is fine
}
}
close(... | go | func WaitForDelegateKeys(cancel <-chan interface{}) <-chan struct{} {
ch := make(chan struct{})
go func() {
for delegateKeys.localPrivate == nil || delegateKeys.masterPublic == nil {
select {
case <-dKeyCond.Wait():
case <-cancel: // Receive from nil channel never returns, so this is fine
}
}
close(... | [
"func",
"WaitForDelegateKeys",
"(",
"cancel",
"<-",
"chan",
"interface",
"{",
"}",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"ch",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"delegateKeys",
".",
... | // WaitForDelegateKeys blocks until delegate keys are defined. | [
"WaitForDelegateKeys",
"blocks",
"until",
"delegate",
"keys",
"are",
"defined",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L308-L320 |
139,060 | control-center/serviced | auth/localkeys.go | WatchDelegateKeyFile | func WatchDelegateKeyFile(filename string, cancel <-chan interface{}) error {
filename = filepath.Clean(filename)
log := log.WithFields(logrus.Fields{
"keyfile": filename,
})
loadKeys := func() {
if err := LoadDelegateKeysFromFile(filename); err != nil {
log.WithError(err).Warn("Unable to load delegate key... | go | func WatchDelegateKeyFile(filename string, cancel <-chan interface{}) error {
filename = filepath.Clean(filename)
log := log.WithFields(logrus.Fields{
"keyfile": filename,
})
loadKeys := func() {
if err := LoadDelegateKeysFromFile(filename); err != nil {
log.WithError(err).Warn("Unable to load delegate key... | [
"func",
"WatchDelegateKeyFile",
"(",
"filename",
"string",
",",
"cancel",
"<-",
"chan",
"interface",
"{",
"}",
")",
"error",
"{",
"filename",
"=",
"filepath",
".",
"Clean",
"(",
"filename",
")",
"\n\n",
"log",
":=",
"log",
".",
"WithFields",
"(",
"logrus",... | // WatchDelegateKeyFile watches the delegate key file on the filesystem and
// updates the internal delegate keys when changes are detected. | [
"WatchDelegateKeyFile",
"watches",
"the",
"delegate",
"key",
"file",
"on",
"the",
"filesystem",
"and",
"updates",
"the",
"internal",
"delegate",
"keys",
"when",
"changes",
"are",
"detected",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/localkeys.go#L328-L354 |
139,061 | control-center/serviced | cli/api/docker.go | ResetRegistry | func (a *api) ResetRegistry() error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.ResetRegistry()
} | go | func (a *api) ResetRegistry() error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.ResetRegistry()
} | [
"func",
"(",
"a",
"*",
"api",
")",
"ResetRegistry",
"(",
")",
"error",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"client",
".",
"ResetRegis... | // ResetRegistry moves all relevant images into the new docker registry | [
"ResetRegistry",
"moves",
"all",
"relevant",
"images",
"into",
"the",
"new",
"docker",
"registry"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/docker.go#L17-L23 |
139,062 | control-center/serviced | cli/api/docker.go | RegistrySync | func (a *api) RegistrySync() error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.SyncRegistry()
} | go | func (a *api) RegistrySync() error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.SyncRegistry()
} | [
"func",
"(",
"a",
"*",
"api",
")",
"RegistrySync",
"(",
")",
"error",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"client",
".",
"SyncRegistr... | // SyncRegistry walks the service tree and syncs all images from docker to local
// registry. | [
"SyncRegistry",
"walks",
"the",
"service",
"tree",
"and",
"syncs",
"all",
"images",
"from",
"docker",
"to",
"local",
"registry",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/docker.go#L27-L33 |
139,063 | control-center/serviced | cli/api/docker.go | UpgradeRegistry | func (a *api) UpgradeRegistry(endpoint string, override bool) error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.UpgradeRegistry(endpoint, override)
} | go | func (a *api) UpgradeRegistry(endpoint string, override bool) error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.UpgradeRegistry(endpoint, override)
} | [
"func",
"(",
"a",
"*",
"api",
")",
"UpgradeRegistry",
"(",
"endpoint",
"string",
",",
"override",
"bool",
")",
"error",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // UpgradeRegistry migrates images from an older or remote docker registry. | [
"UpgradeRegistry",
"migrates",
"images",
"from",
"an",
"older",
"or",
"remote",
"docker",
"registry",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/docker.go#L36-L42 |
139,064 | control-center/serviced | cli/api/docker.go | DockerOverride | func (a *api) DockerOverride(newImage string, oldImage string) error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.DockerOverride(newImage, oldImage)
} | go | func (a *api) DockerOverride(newImage string, oldImage string) error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.DockerOverride(newImage, oldImage)
} | [
"func",
"(",
"a",
"*",
"api",
")",
"DockerOverride",
"(",
"newImage",
"string",
",",
"oldImage",
"string",
")",
"error",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",... | // DockerOverride replaces an image in the docker registry with the specified image | [
"DockerOverride",
"replaces",
"an",
"image",
"in",
"the",
"docker",
"registry",
"with",
"the",
"specified",
"image"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/docker.go#L45-L51 |
139,065 | control-center/serviced | web/vhost.go | NewVHostManager | func NewVHostManager(useTLS bool) *VHostManager {
return &VHostManager{
useTLS: useTLS,
mu: &sync.RWMutex{},
vhosts: make(map[string]*VHostHandler),
}
} | go | func NewVHostManager(useTLS bool) *VHostManager {
return &VHostManager{
useTLS: useTLS,
mu: &sync.RWMutex{},
vhosts: make(map[string]*VHostHandler),
}
} | [
"func",
"NewVHostManager",
"(",
"useTLS",
"bool",
")",
"*",
"VHostManager",
"{",
"return",
"&",
"VHostManager",
"{",
"useTLS",
":",
"useTLS",
",",
"mu",
":",
"&",
"sync",
".",
"RWMutex",
"{",
"}",
",",
"vhosts",
":",
"make",
"(",
"map",
"[",
"string",
... | // NewVHostManager creates a new vhost manager for a host | [
"NewVHostManager",
"creates",
"a",
"new",
"vhost",
"manager",
"for",
"a",
"host"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L33-L39 |
139,066 | control-center/serviced | web/vhost.go | Enable | func (m *VHostManager) Enable(name string) {
m.mu.Lock()
defer m.mu.Unlock()
h, ok := m.vhosts[name]
if !ok {
h = NewVHostHandler()
m.vhosts[name] = h
}
h.Enable()
} | go | func (m *VHostManager) Enable(name string) {
m.mu.Lock()
defer m.mu.Unlock()
h, ok := m.vhosts[name]
if !ok {
h = NewVHostHandler()
m.vhosts[name] = h
}
h.Enable()
} | [
"func",
"(",
"m",
"*",
"VHostManager",
")",
"Enable",
"(",
"name",
"string",
")",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"h",
",",
"ok",
":=",
"m",
".",
"vhosts",
"[",
"name... | // Enable implements enables the vhost | [
"Enable",
"implements",
"enables",
"the",
"vhost"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L42-L52 |
139,067 | control-center/serviced | web/vhost.go | Disable | func (m *VHostManager) Disable(name string) {
m.mu.RLock()
defer m.mu.RUnlock()
h, ok := m.vhosts[name]
if ok {
h.Disable()
}
} | go | func (m *VHostManager) Disable(name string) {
m.mu.RLock()
defer m.mu.RUnlock()
h, ok := m.vhosts[name]
if ok {
h.Disable()
}
} | [
"func",
"(",
"m",
"*",
"VHostManager",
")",
"Disable",
"(",
"name",
"string",
")",
"{",
"m",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"h",
",",
"ok",
":=",
"m",
".",
"vhosts",
"[",
"n... | // Disable disables the vhost | [
"Disable",
"disables",
"the",
"vhost"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L55-L63 |
139,068 | control-center/serviced | web/vhost.go | Set | func (m *VHostManager) Set(name string, data []registry.ExportDetails) {
m.mu.Lock()
defer m.mu.Unlock()
h, ok := m.vhosts[name]
if ok {
h.SetExports(data)
} else {
h = NewVHostHandler(data...)
m.vhosts[name] = h
}
} | go | func (m *VHostManager) Set(name string, data []registry.ExportDetails) {
m.mu.Lock()
defer m.mu.Unlock()
h, ok := m.vhosts[name]
if ok {
h.SetExports(data)
} else {
h = NewVHostHandler(data...)
m.vhosts[name] = h
}
} | [
"func",
"(",
"m",
"*",
"VHostManager",
")",
"Set",
"(",
"name",
"string",
",",
"data",
"[",
"]",
"registry",
".",
"ExportDetails",
")",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
... | // Set updates the vhost endpoints | [
"Set",
"updates",
"the",
"vhost",
"endpoints"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L66-L77 |
139,069 | control-center/serviced | web/vhost.go | Handle | func (m *VHostManager) Handle(httphost string, w http.ResponseWriter, r *http.Request) bool {
m.mu.RLock()
defer m.mu.RUnlock()
// For a request to "xyz.domain.com" See if we have a vhost handler for
// either "xyz.domain.com" or "xyz"
subdomain := strings.Split(httphost, ".")[0]
return m.handle(httphost, w, r) ... | go | func (m *VHostManager) Handle(httphost string, w http.ResponseWriter, r *http.Request) bool {
m.mu.RLock()
defer m.mu.RUnlock()
// For a request to "xyz.domain.com" See if we have a vhost handler for
// either "xyz.domain.com" or "xyz"
subdomain := strings.Split(httphost, ".")[0]
return m.handle(httphost, w, r) ... | [
"func",
"(",
"m",
"*",
"VHostManager",
")",
"Handle",
"(",
"httphost",
"string",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"m",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"m... | // Handle manages a vhost request and returns true if the vhost is enabled | [
"Handle",
"manages",
"a",
"vhost",
"request",
"and",
"returns",
"true",
"if",
"the",
"vhost",
"is",
"enabled"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L80-L88 |
139,070 | control-center/serviced | web/vhost.go | NewVHostHandler | func NewVHostHandler(data ...registry.ExportDetails) *VHostHandler {
return &VHostHandler{
exports: NewRoundRobinExports(data), // default to round-robin
mu: &sync.RWMutex{},
enabled: false,
}
} | go | func NewVHostHandler(data ...registry.ExportDetails) *VHostHandler {
return &VHostHandler{
exports: NewRoundRobinExports(data), // default to round-robin
mu: &sync.RWMutex{},
enabled: false,
}
} | [
"func",
"NewVHostHandler",
"(",
"data",
"...",
"registry",
".",
"ExportDetails",
")",
"*",
"VHostHandler",
"{",
"return",
"&",
"VHostHandler",
"{",
"exports",
":",
"NewRoundRobinExports",
"(",
"data",
")",
",",
"// default to round-robin",
"mu",
":",
"&",
"sync"... | // NewVHostHandler instantiates a new vhost handler | [
"NewVHostHandler",
"instantiates",
"a",
"new",
"vhost",
"handler"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L107-L113 |
139,071 | control-center/serviced | web/vhost.go | Enable | func (h *VHostHandler) Enable() {
h.mu.Lock()
defer h.mu.Unlock()
h.enabled = true
} | go | func (h *VHostHandler) Enable() {
h.mu.Lock()
defer h.mu.Unlock()
h.enabled = true
} | [
"func",
"(",
"h",
"*",
"VHostHandler",
")",
"Enable",
"(",
")",
"{",
"h",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"h",
".",
"enabled",
"=",
"true",
"\n",
"}"
] | // Enable enables a vhost endpoint | [
"Enable",
"enables",
"a",
"vhost",
"endpoint"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L116-L120 |
139,072 | control-center/serviced | web/vhost.go | Disable | func (h *VHostHandler) Disable() {
h.mu.Lock()
defer h.mu.Unlock()
h.enabled = false
} | go | func (h *VHostHandler) Disable() {
h.mu.Lock()
defer h.mu.Unlock()
h.enabled = false
} | [
"func",
"(",
"h",
"*",
"VHostHandler",
")",
"Disable",
"(",
")",
"{",
"h",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"h",
".",
"enabled",
"=",
"false",
"\n",
"}"
] | // Disable disables a vhost endpoint | [
"Disable",
"disables",
"a",
"vhost",
"endpoint"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L123-L127 |
139,073 | control-center/serviced | web/vhost.go | SetExports | func (h *VHostHandler) SetExports(data []registry.ExportDetails) {
h.exports.Set(data)
} | go | func (h *VHostHandler) SetExports(data []registry.ExportDetails) {
h.exports.Set(data)
} | [
"func",
"(",
"h",
"*",
"VHostHandler",
")",
"SetExports",
"(",
"data",
"[",
"]",
"registry",
".",
"ExportDetails",
")",
"{",
"h",
".",
"exports",
".",
"Set",
"(",
"data",
")",
"\n",
"}"
] | // SetExports updates exports for a vhost endpoint | [
"SetExports",
"updates",
"exports",
"for",
"a",
"vhost",
"endpoint"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L130-L132 |
139,074 | control-center/serviced | web/vhost.go | Handle | func (h *VHostHandler) Handle(useTLS bool, w http.ResponseWriter, r *http.Request) bool {
h.mu.RLock()
defer h.mu.RUnlock()
// do not handle if disabled
if !h.enabled {
return false
}
// get the next available export
export := h.exports.Next()
if export == nil {
http.Error(w, "endpoint not available", htt... | go | func (h *VHostHandler) Handle(useTLS bool, w http.ResponseWriter, r *http.Request) bool {
h.mu.RLock()
defer h.mu.RUnlock()
// do not handle if disabled
if !h.enabled {
return false
}
// get the next available export
export := h.exports.Next()
if export == nil {
http.Error(w, "endpoint not available", htt... | [
"func",
"(",
"h",
"*",
"VHostHandler",
")",
"Handle",
"(",
"useTLS",
"bool",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"h",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"mu",
... | // Handle is the vhost handler, returns true if the vhost is enabled | [
"Handle",
"is",
"the",
"vhost",
"handler",
"returns",
"true",
"if",
"the",
"vhost",
"is",
"enabled"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/vhost.go#L135-L175 |
139,075 | control-center/serviced | metrics/metrics.go | Stop | func (m *Metrics) Stop(timer *MetricTimer) {
if timer != nil {
timer.Timer.UpdateSince(timer.Time)
}
} | go | func (m *Metrics) Stop(timer *MetricTimer) {
if timer != nil {
timer.Timer.UpdateSince(timer.Time)
}
} | [
"func",
"(",
"m",
"*",
"Metrics",
")",
"Stop",
"(",
"timer",
"*",
"MetricTimer",
")",
"{",
"if",
"timer",
"!=",
"nil",
"{",
"timer",
".",
"Timer",
".",
"UpdateSince",
"(",
"timer",
".",
"Time",
")",
"\n",
"}",
"\n",
"}"
] | // When stop is called, calculate the duration. | [
"When",
"stop",
"is",
"called",
"calculate",
"the",
"duration",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/metrics/metrics.go#L66-L70 |
139,076 | control-center/serviced | metrics/metrics.go | Log | func (m *Metrics) Log() {
m.Lock()
defer m.Unlock()
log.Debug("Logging all timers")
scale := time.Second
du := float64(scale)
units := scale.String()[1:]
r := m.Registry
r.Each(func(name string, i interface{}) {
switch metric := i.(type) {
// Other types/metrics shown in https://github.com/rcrowley/go-m... | go | func (m *Metrics) Log() {
m.Lock()
defer m.Unlock()
log.Debug("Logging all timers")
scale := time.Second
du := float64(scale)
units := scale.String()[1:]
r := m.Registry
r.Each(func(name string, i interface{}) {
switch metric := i.(type) {
// Other types/metrics shown in https://github.com/rcrowley/go-m... | [
"func",
"(",
"m",
"*",
"Metrics",
")",
"Log",
"(",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"scale",
":=",
"time",
".",
"Second",
"\n",
"du",... | // Log the current timers. Turns off metric logging and clears
// the metric data. Note that if we want a running tally we can
// use the go-metric log method directly, providing our registry. | [
"Log",
"the",
"current",
"timers",
".",
"Turns",
"off",
"metric",
"logging",
"and",
"clears",
"the",
"metric",
"data",
".",
"Note",
"that",
"if",
"we",
"want",
"a",
"running",
"tally",
"we",
"can",
"use",
"the",
"go",
"-",
"metric",
"log",
"method",
"d... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/metrics/metrics.go#L83-L119 |
139,077 | control-center/serviced | domain/servicedefinition/walk.go | Walk | func Walk(sd *ServiceDefinition, visit Visit) error {
if err := visit(sd); err != nil {
return err
}
for _, def := range sd.Services {
if err := Walk(&def, visit); err != nil {
return err
}
}
return nil
} | go | func Walk(sd *ServiceDefinition, visit Visit) error {
if err := visit(sd); err != nil {
return err
}
for _, def := range sd.Services {
if err := Walk(&def, visit); err != nil {
return err
}
}
return nil
} | [
"func",
"Walk",
"(",
"sd",
"*",
"ServiceDefinition",
",",
"visit",
"Visit",
")",
"error",
"{",
"if",
"err",
":=",
"visit",
"(",
"sd",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"def",
":=",
"range",
"sd"... | //Walk a ServiceDefinition hierarchy and call the Visit function at each ServiceDefinition. Returns error if any Visit
// returns an error | [
"Walk",
"a",
"ServiceDefinition",
"hierarchy",
"and",
"call",
"the",
"Visit",
"function",
"at",
"each",
"ServiceDefinition",
".",
"Returns",
"error",
"if",
"any",
"Visit",
"returns",
"an",
"error"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/walk.go#L21-L31 |
139,078 | control-center/serviced | cli/api/host.go | GetHosts | func (a *api) GetHosts() ([]host.Host, error) {
client, err := a.connectMaster()
if err != nil {
return nil, err
}
return client.GetHosts()
} | go | func (a *api) GetHosts() ([]host.Host, error) {
client, err := a.connectMaster()
if err != nil {
return nil, err
}
return client.GetHosts()
} | [
"func",
"(",
"a",
"*",
"api",
")",
"GetHosts",
"(",
")",
"(",
"[",
"]",
"host",
".",
"Host",
",",
"error",
")",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"... | // Returns a list of all hosts | [
"Returns",
"a",
"list",
"of",
"all",
"hosts"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/host.go#L93-L100 |
139,079 | control-center/serviced | cli/api/host.go | AddHost | func (a *api) AddHost(config HostConfig) (*host.Host, []byte, error) {
// if a nat is configured then we connect rpc to the nat, otherwise
// connect to the host address.
var rpcAddress string
if len(config.Nat.Host) > 0 {
rpcAddress = config.Nat.String()
} else {
rpcAddress = config.Address.String()
}
agent... | go | func (a *api) AddHost(config HostConfig) (*host.Host, []byte, error) {
// if a nat is configured then we connect rpc to the nat, otherwise
// connect to the host address.
var rpcAddress string
if len(config.Nat.Host) > 0 {
rpcAddress = config.Nat.String()
} else {
rpcAddress = config.Address.String()
}
agent... | [
"func",
"(",
"a",
"*",
"api",
")",
"AddHost",
"(",
"config",
"HostConfig",
")",
"(",
"*",
"host",
".",
"Host",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// if a nat is configured then we connect rpc to the nat, otherwise",
"// connect to the host address.",
... | // Adds a new host | [
"Adds",
"a",
"new",
"host"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/host.go#L132-L177 |
139,080 | control-center/serviced | cli/api/host.go | AddHostPrivate | func (a *api) AddHostPrivate(config HostConfig) (*host.Host, []byte, error) {
// if a nat is configured then we connect rpc to the nat, otherwise
// connect to the host address.
var rpcAddress string
if len(config.Nat.Host) > 0 {
rpcAddress = config.Nat.String()
} else {
rpcAddress = config.Address.String()
}... | go | func (a *api) AddHostPrivate(config HostConfig) (*host.Host, []byte, error) {
// if a nat is configured then we connect rpc to the nat, otherwise
// connect to the host address.
var rpcAddress string
if len(config.Nat.Host) > 0 {
rpcAddress = config.Nat.String()
} else {
rpcAddress = config.Address.String()
}... | [
"func",
"(",
"a",
"*",
"api",
")",
"AddHostPrivate",
"(",
"config",
"HostConfig",
")",
"(",
"*",
"host",
".",
"Host",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// if a nat is configured then we connect rpc to the nat, otherwise",
"// connect to the host addres... | // Adds a new host and uses a common key to register it. Returns the host and the master's public key. | [
"Adds",
"a",
"new",
"host",
"and",
"uses",
"a",
"common",
"key",
"to",
"register",
"it",
".",
"Returns",
"the",
"host",
"and",
"the",
"master",
"s",
"public",
"key",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/host.go#L180-L220 |
139,081 | control-center/serviced | cli/api/host.go | SetHostMemory | func (a *api) SetHostMemory(config HostUpdateConfig) error {
client, err := a.connectMaster()
if err != nil {
return err
}
h, err := client.GetHost(config.HostID)
if err != nil {
return err
}
if _, err := host.GetRAMLimit(config.Memory, h.Memory); err != nil {
return err
}
h.RAMLimit = config.Memory
ret... | go | func (a *api) SetHostMemory(config HostUpdateConfig) error {
client, err := a.connectMaster()
if err != nil {
return err
}
h, err := client.GetHost(config.HostID)
if err != nil {
return err
}
if _, err := host.GetRAMLimit(config.Memory, h.Memory); err != nil {
return err
}
h.RAMLimit = config.Memory
ret... | [
"func",
"(",
"a",
"*",
"api",
")",
"SetHostMemory",
"(",
"config",
"HostUpdateConfig",
")",
"error",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"h",
"... | // Sets the memory allocation for an existing host | [
"Sets",
"the",
"memory",
"allocation",
"for",
"an",
"existing",
"host"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/host.go#L233-L247 |
139,082 | control-center/serviced | cli/api/host.go | GetHostPublicKey | func (a *api) GetHostPublicKey(id string) ([]byte, error) {
client, err := a.connectMaster()
if err != nil {
return nil, err
}
return client.GetHostPublicKey(id)
} | go | func (a *api) GetHostPublicKey(id string) ([]byte, error) {
client, err := a.connectMaster()
if err != nil {
return nil, err
}
return client.GetHostPublicKey(id)
} | [
"func",
"(",
"a",
"*",
"api",
")",
"GetHostPublicKey",
"(",
"id",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // Retrieve host's public key | [
"Retrieve",
"host",
"s",
"public",
"key"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/host.go#L258-L264 |
139,083 | control-center/serviced | cli/api/host.go | WriteDelegateKey | func (a *api) WriteDelegateKey(filename string, data []byte) error {
return auth.WriteKeyToFile(filename, data)
} | go | func (a *api) WriteDelegateKey(filename string, data []byte) error {
return auth.WriteKeyToFile(filename, data)
} | [
"func",
"(",
"a",
"*",
"api",
")",
"WriteDelegateKey",
"(",
"filename",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"auth",
".",
"WriteKeyToFile",
"(",
"filename",
",",
"data",
")",
"\n",
"}"
] | // Output a delegate key file to a given location on disk | [
"Output",
"a",
"delegate",
"key",
"file",
"to",
"a",
"given",
"location",
"on",
"disk"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/host.go#L285-L287 |
139,084 | control-center/serviced | rpc/master/publicendpoint_server.go | GetAllPublicEndpoints | func (s *Server) GetAllPublicEndpoints(empty struct{}, publicEndpoints *[]service.PublicEndpoint) error {
peps, err := s.f.GetAllPublicEndpoints(s.context())
if err != nil {
return err
}
*publicEndpoints = peps
return nil
} | go | func (s *Server) GetAllPublicEndpoints(empty struct{}, publicEndpoints *[]service.PublicEndpoint) error {
peps, err := s.f.GetAllPublicEndpoints(s.context())
if err != nil {
return err
}
*publicEndpoints = peps
return nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"GetAllPublicEndpoints",
"(",
"empty",
"struct",
"{",
"}",
",",
"publicEndpoints",
"*",
"[",
"]",
"service",
".",
"PublicEndpoint",
")",
"error",
"{",
"peps",
",",
"err",
":=",
"s",
".",
"f",
".",
"GetAllPublicEndpoi... | // GetAllPublicEndpoints get all public endpoints | [
"GetAllPublicEndpoints",
"get",
"all",
"public",
"endpoints"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/publicendpoint_server.go#L75-L82 |
139,085 | control-center/serviced | cli/api/utils.go | GetAgentIP | func GetAgentIP(defaultRPCPort int) string {
options := config.GetOptions()
if options.Endpoint != "" {
return options.Endpoint
}
agentIP, err := utils.GetIPAddress()
if err != nil {
log.WithError(err).Fatal("Unable to get delegate IP address")
}
return agentIP + fmt.Sprintf(":%d", defaultRPCPort)
} | go | func GetAgentIP(defaultRPCPort int) string {
options := config.GetOptions()
if options.Endpoint != "" {
return options.Endpoint
}
agentIP, err := utils.GetIPAddress()
if err != nil {
log.WithError(err).Fatal("Unable to get delegate IP address")
}
return agentIP + fmt.Sprintf(":%d", defaultRPCPort)
} | [
"func",
"GetAgentIP",
"(",
"defaultRPCPort",
"int",
")",
"string",
"{",
"options",
":=",
"config",
".",
"GetOptions",
"(",
")",
"\n",
"if",
"options",
".",
"Endpoint",
"!=",
"\"",
"\"",
"{",
"return",
"options",
".",
"Endpoint",
"\n",
"}",
"\n",
"agentIP... | // GetAgentIP returns the agent ip address | [
"GetAgentIP",
"returns",
"the",
"agent",
"ip",
"address"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/utils.go#L30-L40 |
139,086 | control-center/serviced | health/check.go | MarshalJSON | func (hc HealthCheck) MarshalJSON() ([]byte, error) {
jhc := struct {
Script string
Timeout float64
Interval float64
Tolerance int
KillExitCodes []int `json:",omitempty"`
KillCountLimit int `json:",omitempty"`
}{
Script: hc.Script,
Timeout: hc.Timeout.Second... | go | func (hc HealthCheck) MarshalJSON() ([]byte, error) {
jhc := struct {
Script string
Timeout float64
Interval float64
Tolerance int
KillExitCodes []int `json:",omitempty"`
KillCountLimit int `json:",omitempty"`
}{
Script: hc.Script,
Timeout: hc.Timeout.Second... | [
"func",
"(",
"hc",
"HealthCheck",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"jhc",
":=",
"struct",
"{",
"Script",
"string",
"\n",
"Timeout",
"float64",
"\n",
"Interval",
"float64",
"\n",
"Tolerance",
"int",
"\n",
"Kil... | // MarshalJSON implements json.Marshaller | [
"MarshalJSON",
"implements",
"json",
".",
"Marshaller"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L123-L140 |
139,087 | control-center/serviced | health/check.go | UnmarshalJSON | func (hc *HealthCheck) UnmarshalJSON(data []byte) error {
jhc := struct {
Script string
Timeout float64
Interval float64
Tolerance int
KillExitCodes []int `json:",omitempty"`
KillCountLimit int `json:",omitempty"`
}{}
if err := json.Unmarshal(data, &jhc); err != nil {
retur... | go | func (hc *HealthCheck) UnmarshalJSON(data []byte) error {
jhc := struct {
Script string
Timeout float64
Interval float64
Tolerance int
KillExitCodes []int `json:",omitempty"`
KillCountLimit int `json:",omitempty"`
}{}
if err := json.Unmarshal(data, &jhc); err != nil {
retur... | [
"func",
"(",
"hc",
"*",
"HealthCheck",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"jhc",
":=",
"struct",
"{",
"Script",
"string",
"\n",
"Timeout",
"float64",
"\n",
"Interval",
"float64",
"\n",
"Tolerance",
"int",
"\n",
"KillE... | // UnmarshalJSON implements json.Unmarshaller | [
"UnmarshalJSON",
"implements",
"json",
".",
"Unmarshaller"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L143-L164 |
139,088 | control-center/serviced | health/check.go | GetTimeout | func (hc *HealthCheck) GetTimeout() time.Duration {
timeout := hc.Timeout
if timeout <= 0 {
timeout = DefaultTimeout
}
return timeout
} | go | func (hc *HealthCheck) GetTimeout() time.Duration {
timeout := hc.Timeout
if timeout <= 0 {
timeout = DefaultTimeout
}
return timeout
} | [
"func",
"(",
"hc",
"*",
"HealthCheck",
")",
"GetTimeout",
"(",
")",
"time",
".",
"Duration",
"{",
"timeout",
":=",
"hc",
".",
"Timeout",
"\n",
"if",
"timeout",
"<=",
"0",
"{",
"timeout",
"=",
"DefaultTimeout",
"\n",
"}",
"\n",
"return",
"timeout",
"\n"... | // GetTimeout returns the timeout duration. | [
"GetTimeout",
"returns",
"the",
"timeout",
"duration",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L167-L173 |
139,089 | control-center/serviced | health/check.go | Expires | func (hc *HealthCheck) Expires() time.Duration {
tolerance := hc.Tolerance
if tolerance <= 0 {
tolerance = DefaultTolerance
}
return time.Duration(tolerance) * (hc.GetTimeout() + hc.Interval)
} | go | func (hc *HealthCheck) Expires() time.Duration {
tolerance := hc.Tolerance
if tolerance <= 0 {
tolerance = DefaultTolerance
}
return time.Duration(tolerance) * (hc.GetTimeout() + hc.Interval)
} | [
"func",
"(",
"hc",
"*",
"HealthCheck",
")",
"Expires",
"(",
")",
"time",
".",
"Duration",
"{",
"tolerance",
":=",
"hc",
".",
"Tolerance",
"\n",
"if",
"tolerance",
"<=",
"0",
"{",
"tolerance",
"=",
"DefaultTolerance",
"\n",
"}",
"\n",
"return",
"time",
... | // Expires calculates the time to live on the cache item. | [
"Expires",
"calculates",
"the",
"time",
"to",
"live",
"on",
"the",
"cache",
"item",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L176-L182 |
139,090 | control-center/serviced | health/check.go | NotRunning | func (hc *HealthCheck) NotRunning() HealthStatus {
return HealthStatus{
Status: NotRunning,
StartedAt: time.Now(),
}
} | go | func (hc *HealthCheck) NotRunning() HealthStatus {
return HealthStatus{
Status: NotRunning,
StartedAt: time.Now(),
}
} | [
"func",
"(",
"hc",
"*",
"HealthCheck",
")",
"NotRunning",
"(",
")",
"HealthStatus",
"{",
"return",
"HealthStatus",
"{",
"Status",
":",
"NotRunning",
",",
"StartedAt",
":",
"time",
".",
"Now",
"(",
")",
",",
"}",
"\n",
"}"
] | // NotRunning returns the health status for a service instance that is not
// running. | [
"NotRunning",
"returns",
"the",
"health",
"status",
"for",
"a",
"service",
"instance",
"that",
"is",
"not",
"running",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L186-L191 |
139,091 | control-center/serviced | health/check.go | Unknown | func (hc *HealthCheck) Unknown() HealthStatus {
return HealthStatus{
Status: Unknown,
StartedAt: time.Now(),
}
} | go | func (hc *HealthCheck) Unknown() HealthStatus {
return HealthStatus{
Status: Unknown,
StartedAt: time.Now(),
}
} | [
"func",
"(",
"hc",
"*",
"HealthCheck",
")",
"Unknown",
"(",
")",
"HealthStatus",
"{",
"return",
"HealthStatus",
"{",
"Status",
":",
"Unknown",
",",
"StartedAt",
":",
"time",
".",
"Now",
"(",
")",
",",
"}",
"\n",
"}"
] | // Unknown returns the health status for a service instance whose health check
// response is unknown. | [
"Unknown",
"returns",
"the",
"health",
"status",
"for",
"a",
"service",
"instance",
"whose",
"health",
"check",
"response",
"is",
"unknown",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L195-L200 |
139,092 | control-center/serviced | health/check.go | Run | func (hc *HealthCheck) Run(key HealthStatusKey) (stat HealthStatus) {
logger := plog.WithFields(log.Fields{
"service": key.ServiceID,
"instance": key.InstanceID,
"healthcheck": key.HealthCheckName,
})
stat.StartedAt = time.Now()
cmd := exec.Command("sh", "-c", hc.Script)
cmd.Start()
timer := time.New... | go | func (hc *HealthCheck) Run(key HealthStatusKey) (stat HealthStatus) {
logger := plog.WithFields(log.Fields{
"service": key.ServiceID,
"instance": key.InstanceID,
"healthcheck": key.HealthCheckName,
})
stat.StartedAt = time.Now()
cmd := exec.Command("sh", "-c", hc.Script)
cmd.Start()
timer := time.New... | [
"func",
"(",
"hc",
"*",
"HealthCheck",
")",
"Run",
"(",
"key",
"HealthStatusKey",
")",
"(",
"stat",
"HealthStatus",
")",
"{",
"logger",
":=",
"plog",
".",
"WithFields",
"(",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",
"key",
".",
"ServiceID",
",",
"\... | // Run returns the health status as a result of running the health check
// script. | [
"Run",
"returns",
"the",
"health",
"status",
"as",
"a",
"result",
"of",
"running",
"the",
"health",
"check",
"script",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L204-L270 |
139,093 | control-center/serviced | health/check.go | Ping | func (hc *HealthCheck) Ping(cancel <-chan struct{}, key HealthStatusKey, report func(HealthStatus)) {
timer := time.NewTimer(0)
defer timer.Stop()
for {
select {
case <-timer.C:
stat := hc.Run(key)
stat.KillFlag = hc.KillCountLimit > 0 && hc.KillCounter >= hc.KillCountLimit
timer.Reset(hc.Interval)
r... | go | func (hc *HealthCheck) Ping(cancel <-chan struct{}, key HealthStatusKey, report func(HealthStatus)) {
timer := time.NewTimer(0)
defer timer.Stop()
for {
select {
case <-timer.C:
stat := hc.Run(key)
stat.KillFlag = hc.KillCountLimit > 0 && hc.KillCounter >= hc.KillCountLimit
timer.Reset(hc.Interval)
r... | [
"func",
"(",
"hc",
"*",
"HealthCheck",
")",
"Ping",
"(",
"cancel",
"<-",
"chan",
"struct",
"{",
"}",
",",
"key",
"HealthStatusKey",
",",
"report",
"func",
"(",
"HealthStatus",
")",
")",
"{",
"timer",
":=",
"time",
".",
"NewTimer",
"(",
"0",
")",
"\n"... | // Ping performs the health check on the specified interval. | [
"Ping",
"performs",
"the",
"health",
"check",
"on",
"the",
"specified",
"interval",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/health/check.go#L273-L287 |
139,094 | control-center/serviced | dfs/backupinfo.go | BackupInfo | func (dfs *DistributedFilesystem) BackupInfo(r io.Reader) (*BackupInfo, error) {
tarfile := tar.NewReader(r)
for {
header, err := tarfile.Next()
if err == io.EOF {
return nil, ErrRestoreNoInfo
} else if err != nil {
glog.Errorf("Could not read backup: %s", err)
return nil, err
}
if header.Name == B... | go | func (dfs *DistributedFilesystem) BackupInfo(r io.Reader) (*BackupInfo, error) {
tarfile := tar.NewReader(r)
for {
header, err := tarfile.Next()
if err == io.EOF {
return nil, ErrRestoreNoInfo
} else if err != nil {
glog.Errorf("Could not read backup: %s", err)
return nil, err
}
if header.Name == B... | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"BackupInfo",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"BackupInfo",
",",
"error",
")",
"{",
"tarfile",
":=",
"tar",
".",
"NewReader",
"(",
"r",
")",
"\n",
"for",
"{",
"header",
",",
"err",
... | // BackupInfo provides metadata info about the contents of a backup | [
"BackupInfo",
"provides",
"metadata",
"info",
"about",
"the",
"contents",
"of",
"a",
"backup"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/backupinfo.go#L26-L45 |
139,095 | control-center/serviced | dfs/backupinfo.go | ExtractBackupInfo | func ExtractBackupInfo(filename string) (*BackupInfo, error) {
var info BackupInfo
data, err := exec.Command("tar", "-O", "--occurrence", "-xzf", filename, BackupMetadataFile).CombinedOutput()
if err != nil {
return nil, ErrRestoreNoInfo
}
if err := json.Unmarshal(data, &info); err != nil {
return nil, ErrRest... | go | func ExtractBackupInfo(filename string) (*BackupInfo, error) {
var info BackupInfo
data, err := exec.Command("tar", "-O", "--occurrence", "-xzf", filename, BackupMetadataFile).CombinedOutput()
if err != nil {
return nil, ErrRestoreNoInfo
}
if err := json.Unmarshal(data, &info); err != nil {
return nil, ErrRest... | [
"func",
"ExtractBackupInfo",
"(",
"filename",
"string",
")",
"(",
"*",
"BackupInfo",
",",
"error",
")",
"{",
"var",
"info",
"BackupInfo",
"\n",
"data",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
... | // ExtractBackupInfo extracts the backup metadata from a tarball on disk in as
// cheaply a manner as possible. The serialized BackupInfo is stored at the
// front of the tarball to facilitate this. | [
"ExtractBackupInfo",
"extracts",
"the",
"backup",
"metadata",
"from",
"a",
"tarball",
"on",
"disk",
"in",
"as",
"cheaply",
"a",
"manner",
"as",
"possible",
".",
"The",
"serialized",
"BackupInfo",
"is",
"stored",
"at",
"the",
"front",
"of",
"the",
"tarball",
... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/backupinfo.go#L50-L60 |
139,096 | control-center/serviced | facade/addressassignment.go | GetServiceAddressAssignments | func (f *Facade) GetServiceAddressAssignments(ctx datastore.Context, serviceID string) ([]addressassignment.AddressAssignment, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetServiceAddressAssignments"))
store := addressassignment.NewStore()
return store.GetServiceAddressAssignments(ctx, serviceID)
... | go | func (f *Facade) GetServiceAddressAssignments(ctx datastore.Context, serviceID string) ([]addressassignment.AddressAssignment, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetServiceAddressAssignments"))
store := addressassignment.NewStore()
return store.GetServiceAddressAssignments(ctx, serviceID)
... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"GetServiceAddressAssignments",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceID",
"string",
")",
"(",
"[",
"]",
"addressassignment",
".",
"AddressAssignment",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metric... | // GetServiceAddressAssignments fills in all address assignments for the specified service id. | [
"GetServiceAddressAssignments",
"fills",
"in",
"all",
"address",
"assignments",
"for",
"the",
"specified",
"service",
"id",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/addressassignment.go#L131-L135 |
139,097 | control-center/serviced | facade/addressassignment.go | RemoveAddressAssignment | func (f *Facade) RemoveAddressAssignment(ctx datastore.Context, id string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RemoveAddressAssignment"))
alog := f.auditLogger.Message(ctx, "Removing AddressAssignment").Action(audit.Remove).
ID(id).Type(addressassignment.GetType())
store := addressassignme... | go | func (f *Facade) RemoveAddressAssignment(ctx datastore.Context, id string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RemoveAddressAssignment"))
alog := f.auditLogger.Message(ctx, "Removing AddressAssignment").Action(audit.Remove).
ID(id).Type(addressassignment.GetType())
store := addressassignme... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"RemoveAddressAssignment",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"id",
"string",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Start... | // RemoveAddressAssignment Removes an AddressAssignment by id | [
"RemoveAddressAssignment",
"Removes",
"an",
"AddressAssignment",
"by",
"id"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/addressassignment.go#L157-L181 |
139,098 | control-center/serviced | utils/isatty.go | Isatty | func Isatty(f *os.File) bool {
var t syscall.Termios
_, _, errno := syscall.Syscall6(syscall.SYS_IOCTL,
f.Fd(), ioctlTermioFlag,
uintptr(unsafe.Pointer(&t)), 0, 0, 0)
return errno == 0
} | go | func Isatty(f *os.File) bool {
var t syscall.Termios
_, _, errno := syscall.Syscall6(syscall.SYS_IOCTL,
f.Fd(), ioctlTermioFlag,
uintptr(unsafe.Pointer(&t)), 0, 0, 0)
return errno == 0
} | [
"func",
"Isatty",
"(",
"f",
"*",
"os",
".",
"File",
")",
"bool",
"{",
"var",
"t",
"syscall",
".",
"Termios",
"\n",
"_",
",",
"_",
",",
"errno",
":=",
"syscall",
".",
"Syscall6",
"(",
"syscall",
".",
"SYS_IOCTL",
",",
"f",
".",
"Fd",
"(",
")",
"... | // Isatty returns true if f is a TTY, false otherwise. | [
"Isatty",
"returns",
"true",
"if",
"f",
"is",
"a",
"TTY",
"false",
"otherwise",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/isatty.go#L10-L16 |
139,099 | control-center/serviced | stats/fd.go | GetOpenFileDescriptorCount | func GetOpenFileDescriptorCount() (int64, error) {
files, err := filepath.Glob("/proc/self/fd/*")
if err != nil {
return 0, err
}
return int64(len(files)), nil
} | go | func GetOpenFileDescriptorCount() (int64, error) {
files, err := filepath.Glob("/proc/self/fd/*")
if err != nil {
return 0, err
}
return int64(len(files)), nil
} | [
"func",
"GetOpenFileDescriptorCount",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"filepath",
".",
"Glob",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"return... | // GetOpenFileDescriptorCount returns the number of open file descriptors for the process id of the caller. | [
"GetOpenFileDescriptorCount",
"returns",
"the",
"number",
"of",
"open",
"file",
"descriptors",
"for",
"the",
"process",
"id",
"of",
"the",
"caller",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/stats/fd.go#L22-L28 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.