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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
152,000
tsuna/gohbase
rpc.go
clientDown
func (c *client) clientDown(client hrpc.RegionClient) { downregions := c.clients.clientDown(client) for downreg := range downregions { if downreg.MarkUnavailable() { downreg.SetClient(nil) go c.reestablishRegion(downreg) } } }
go
func (c *client) clientDown(client hrpc.RegionClient) { downregions := c.clients.clientDown(client) for downreg := range downregions { if downreg.MarkUnavailable() { downreg.SetClient(nil) go c.reestablishRegion(downreg) } } }
[ "func", "(", "c", "*", "client", ")", "clientDown", "(", "client", "hrpc", ".", "RegionClient", ")", "{", "downregions", ":=", "c", ".", "clients", ".", "clientDown", "(", "client", ")", "\n", "for", "downreg", ":=", "range", "downregions", "{", "if", ...
// clientDown removes client from cache and marks // all the regions sharing this region's // client as unavailable, and start a goroutine // to reconnect for each of them.
[ "clientDown", "removes", "client", "from", "cache", "and", "marks", "all", "the", "regions", "sharing", "this", "region", "s", "client", "as", "unavailable", "and", "start", "a", "goroutine", "to", "reconnect", "for", "each", "of", "them", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/rpc.go#L186-L194
152,001
tsuna/gohbase
rpc.go
getRegionFromCache
func (c *client) getRegionFromCache(table, key []byte) hrpc.RegionInfo { if c.clientType == adminClient { return c.adminRegionInfo } else if bytes.Equal(table, metaTableName) { return c.metaRegionInfo } regionName := createRegionSearchKey(table, key) _, region := c.regions.get(regionName) if region == nil { return nil } // make sure the returned region is for the same table if !bytes.Equal(fullyQualifiedTable(region), table) { // not the same table, can happen if we got the last region return nil } if len(region.StopKey()) != 0 && // If the stop key is an empty byte array, it means this region is the // last region for this table and this key ought to be in that region. bytes.Compare(key, region.StopKey()) >= 0 { return nil } return region }
go
func (c *client) getRegionFromCache(table, key []byte) hrpc.RegionInfo { if c.clientType == adminClient { return c.adminRegionInfo } else if bytes.Equal(table, metaTableName) { return c.metaRegionInfo } regionName := createRegionSearchKey(table, key) _, region := c.regions.get(regionName) if region == nil { return nil } // make sure the returned region is for the same table if !bytes.Equal(fullyQualifiedTable(region), table) { // not the same table, can happen if we got the last region return nil } if len(region.StopKey()) != 0 && // If the stop key is an empty byte array, it means this region is the // last region for this table and this key ought to be in that region. bytes.Compare(key, region.StopKey()) >= 0 { return nil } return region }
[ "func", "(", "c", "*", "client", ")", "getRegionFromCache", "(", "table", ",", "key", "[", "]", "byte", ")", "hrpc", ".", "RegionInfo", "{", "if", "c", ".", "clientType", "==", "adminClient", "{", "return", "c", ".", "adminRegionInfo", "\n", "}", "else...
// Searches in the regions cache for the region hosting the given row.
[ "Searches", "in", "the", "regions", "cache", "for", "the", "region", "hosting", "the", "given", "row", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/rpc.go#L301-L327
152,002
tsuna/gohbase
rpc.go
createRegionSearchKey
func createRegionSearchKey(table, key []byte) []byte { metaKey := make([]byte, 0, len(table)+len(key)+3) metaKey = append(metaKey, table...) metaKey = append(metaKey, ',') metaKey = append(metaKey, key...) metaKey = append(metaKey, ',') // ':' is the first byte greater than '9'. We always want to find the // entry with the greatest timestamp, so by looking right before ':' // we'll find it. metaKey = append(metaKey, ':') return metaKey }
go
func createRegionSearchKey(table, key []byte) []byte { metaKey := make([]byte, 0, len(table)+len(key)+3) metaKey = append(metaKey, table...) metaKey = append(metaKey, ',') metaKey = append(metaKey, key...) metaKey = append(metaKey, ',') // ':' is the first byte greater than '9'. We always want to find the // entry with the greatest timestamp, so by looking right before ':' // we'll find it. metaKey = append(metaKey, ':') return metaKey }
[ "func", "createRegionSearchKey", "(", "table", ",", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "metaKey", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "len", "(", "table", ")", "+", "len", "(", "key", ")", "+", "3", ")", "\n", ...
// Creates the META key to search for in order to locate the given key.
[ "Creates", "the", "META", "key", "to", "search", "for", "in", "order", "to", "locate", "the", "given", "key", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/rpc.go#L330-L341
152,003
tsuna/gohbase
rpc.go
metaLookup
func (c *client) metaLookup(ctx context.Context, table, key []byte) (hrpc.RegionInfo, string, error) { metaKey := createRegionSearchKey(table, key) rpc, err := hrpc.NewScanRange(ctx, metaTableName, metaKey, table, hrpc.Families(infoFamily), hrpc.Reversed(), hrpc.CloseScanner(), hrpc.NumberOfRows(1)) if err != nil { return nil, "", err } scanner := c.Scan(rpc) resp, err := scanner.Next() if err == io.EOF { return nil, "", TableNotFound } if err != nil { return nil, "", err } reg, addr, err := region.ParseRegionInfo(resp) if err != nil { return nil, "", err } if !bytes.Equal(table, fullyQualifiedTable(reg)) { // This would indicate a bug in HBase. return nil, "", fmt.Errorf("wtf: meta returned an entry for the wrong table!"+ " Looked up table=%q key=%q got region=%s", table, key, reg) } else if len(reg.StopKey()) != 0 && bytes.Compare(key, reg.StopKey()) >= 0 { // This would indicate a hole in the meta table. return nil, "", fmt.Errorf("wtf: meta returned an entry for the wrong region!"+ " Looked up table=%q key=%q got region=%s", table, key, reg) } return reg, addr, nil }
go
func (c *client) metaLookup(ctx context.Context, table, key []byte) (hrpc.RegionInfo, string, error) { metaKey := createRegionSearchKey(table, key) rpc, err := hrpc.NewScanRange(ctx, metaTableName, metaKey, table, hrpc.Families(infoFamily), hrpc.Reversed(), hrpc.CloseScanner(), hrpc.NumberOfRows(1)) if err != nil { return nil, "", err } scanner := c.Scan(rpc) resp, err := scanner.Next() if err == io.EOF { return nil, "", TableNotFound } if err != nil { return nil, "", err } reg, addr, err := region.ParseRegionInfo(resp) if err != nil { return nil, "", err } if !bytes.Equal(table, fullyQualifiedTable(reg)) { // This would indicate a bug in HBase. return nil, "", fmt.Errorf("wtf: meta returned an entry for the wrong table!"+ " Looked up table=%q key=%q got region=%s", table, key, reg) } else if len(reg.StopKey()) != 0 && bytes.Compare(key, reg.StopKey()) >= 0 { // This would indicate a hole in the meta table. return nil, "", fmt.Errorf("wtf: meta returned an entry for the wrong region!"+ " Looked up table=%q key=%q got region=%s", table, key, reg) } return reg, addr, nil }
[ "func", "(", "c", "*", "client", ")", "metaLookup", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "[", "]", "byte", ")", "(", "hrpc", ".", "RegionInfo", ",", "string", ",", "error", ")", "{", "metaKey", ":=", "createRegionSearchKey",...
// metaLookup checks meta table for the region in which the given row key for the given table is.
[ "metaLookup", "checks", "meta", "table", "for", "the", "region", "in", "which", "the", "given", "row", "key", "for", "the", "given", "table", "is", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/rpc.go#L370-L406
152,004
tsuna/gohbase
rpc.go
probeKey
func probeKey(reg hrpc.RegionInfo) []byte { // now we create a probe key: reg.StartKey() + 17 zeros probe := make([]byte, len(reg.StartKey())+17) copy(probe, reg.StartKey()) return probe }
go
func probeKey(reg hrpc.RegionInfo) []byte { // now we create a probe key: reg.StartKey() + 17 zeros probe := make([]byte, len(reg.StartKey())+17) copy(probe, reg.StartKey()) return probe }
[ "func", "probeKey", "(", "reg", "hrpc", ".", "RegionInfo", ")", "[", "]", "byte", "{", "// now we create a probe key: reg.StartKey() + 17 zeros", "probe", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "reg", ".", "StartKey", "(", ")", ")", "+", "17...
// probeKey returns a key in region that is unlikely to have data at it // in order to test if the region is online. This prevents the Get request // to actually fetch the data from the storage which consumes resources // of the region server
[ "probeKey", "returns", "a", "key", "in", "region", "that", "is", "unlikely", "to", "have", "data", "at", "it", "in", "order", "to", "test", "if", "the", "region", "is", "online", ".", "This", "prevents", "the", "Get", "request", "to", "actually", "fetch"...
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/rpc.go#L437-L442
152,005
tsuna/gohbase
rpc.go
isRegionEstablished
func isRegionEstablished(rc hrpc.RegionClient, reg hrpc.RegionInfo) error { probe, err := hrpc.NewGet(context.Background(), fullyQualifiedTable(reg), probeKey(reg), hrpc.SkipBatch()) if err != nil { panic(fmt.Sprintf("should not happen: %s", err)) } probe.ExistsOnly() probe.SetRegion(reg) res, err := sendBlocking(rc, probe) if err != nil { panic(fmt.Sprintf("should not happen: %s", err)) } switch res.Error.(type) { case region.ServerError, region.NotServingRegionError, region.RetryableError: return res.Error default: return nil } }
go
func isRegionEstablished(rc hrpc.RegionClient, reg hrpc.RegionInfo) error { probe, err := hrpc.NewGet(context.Background(), fullyQualifiedTable(reg), probeKey(reg), hrpc.SkipBatch()) if err != nil { panic(fmt.Sprintf("should not happen: %s", err)) } probe.ExistsOnly() probe.SetRegion(reg) res, err := sendBlocking(rc, probe) if err != nil { panic(fmt.Sprintf("should not happen: %s", err)) } switch res.Error.(type) { case region.ServerError, region.NotServingRegionError, region.RetryableError: return res.Error default: return nil } }
[ "func", "isRegionEstablished", "(", "rc", "hrpc", ".", "RegionClient", ",", "reg", "hrpc", ".", "RegionInfo", ")", "error", "{", "probe", ",", "err", ":=", "hrpc", ".", "NewGet", "(", "context", ".", "Background", "(", ")", ",", "fullyQualifiedTable", "(",...
// isRegionEstablished checks whether regionserver accepts rpcs for the region. // Returns the cause if not established.
[ "isRegionEstablished", "checks", "whether", "regionserver", "accepts", "rpcs", "for", "the", "region", ".", "Returns", "the", "cause", "if", "not", "established", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/rpc.go#L446-L466
152,006
tsuna/gohbase
rpc.go
zkLookup
func (c *client) zkLookup(ctx context.Context, resource zk.ResourceName) (string, error) { // We make this a buffered channel so that if we stop waiting due to a // timeout, we won't block the zkLookupSync() that we start in a // separate goroutine. reschan := make(chan zkResult, 1) go func() { addr, err := c.zkClient.LocateResource(resource.Prepend(c.zkRoot)) // This is guaranteed to never block as the channel is always buffered. reschan <- zkResult{addr, err} }() select { case res := <-reschan: return res.addr, res.err case <-ctx.Done(): return "", ctx.Err() } }
go
func (c *client) zkLookup(ctx context.Context, resource zk.ResourceName) (string, error) { // We make this a buffered channel so that if we stop waiting due to a // timeout, we won't block the zkLookupSync() that we start in a // separate goroutine. reschan := make(chan zkResult, 1) go func() { addr, err := c.zkClient.LocateResource(resource.Prepend(c.zkRoot)) // This is guaranteed to never block as the channel is always buffered. reschan <- zkResult{addr, err} }() select { case res := <-reschan: return res.addr, res.err case <-ctx.Done(): return "", ctx.Err() } }
[ "func", "(", "c", "*", "client", ")", "zkLookup", "(", "ctx", "context", ".", "Context", ",", "resource", "zk", ".", "ResourceName", ")", "(", "string", ",", "error", ")", "{", "// We make this a buffered channel so that if we stop waiting due to a", "// timeout, we...
// zkLookup asynchronously looks up the meta region or HMaster in ZooKeeper.
[ "zkLookup", "asynchronously", "looks", "up", "the", "meta", "region", "or", "HMaster", "in", "ZooKeeper", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/rpc.go#L638-L654
152,007
tsuna/gohbase
hrpc/get.go
baseGet
func baseGet(ctx context.Context, table []byte, key []byte, options ...func(Call) error) (*Get, error) { g := &Get{ base: base{ key: key, table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, baseQuery: newBaseQuery(), } err := applyOptions(g, options...) if err != nil { return nil, err } return g, nil }
go
func baseGet(ctx context.Context, table []byte, key []byte, options ...func(Call) error) (*Get, error) { g := &Get{ base: base{ key: key, table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, baseQuery: newBaseQuery(), } err := applyOptions(g, options...) if err != nil { return nil, err } return g, nil }
[ "func", "baseGet", "(", "ctx", "context", ".", "Context", ",", "table", "[", "]", "byte", ",", "key", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Get", ",", "error", ")", "{", "g", ":=", "&", "Get...
// baseGet returns a Get struct with default values set.
[ "baseGet", "returns", "a", "Get", "struct", "with", "default", "values", "set", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/get.go#L26-L42
152,008
tsuna/gohbase
hrpc/get.go
NewGet
func NewGet(ctx context.Context, table, key []byte, options ...func(Call) error) (*Get, error) { return baseGet(ctx, table, key, options...) }
go
func NewGet(ctx context.Context, table, key []byte, options ...func(Call) error) (*Get, error) { return baseGet(ctx, table, key, options...) }
[ "func", "NewGet", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Get", ",", "error", ")", "{", "return", "baseGet", "(", "ctx", ",", "ta...
// NewGet creates a new Get request for the given table and row key.
[ "NewGet", "creates", "a", "new", "Get", "request", "for", "the", "given", "table", "and", "row", "key", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/get.go#L45-L48
152,009
tsuna/gohbase
hrpc/get.go
NewGetStr
func NewGetStr(ctx context.Context, table, key string, options ...func(Call) error) (*Get, error) { return NewGet(ctx, []byte(table), []byte(key), options...) }
go
func NewGetStr(ctx context.Context, table, key string, options ...func(Call) error) (*Get, error) { return NewGet(ctx, []byte(table), []byte(key), options...) }
[ "func", "NewGetStr", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "string", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Get", ",", "error", ")", "{", "return", "NewGet", "(", "ctx", ",", "[", "]", ...
// NewGetStr creates a new Get request for the given table and row key.
[ "NewGetStr", "creates", "a", "new", "Get", "request", "for", "the", "given", "table", "and", "row", "key", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/get.go#L51-L54
152,010
tsuna/gohbase
hrpc/get.go
ToProto
func (g *Get) ToProto() proto.Message { get := &pb.GetRequest{ Region: g.regionSpecifier(), Get: &pb.Get{ Row: g.key, Column: familiesToColumn(g.families), TimeRange: &pb.TimeRange{}, }, } /* added support for limit number of cells per row */ if g.storeLimit != DefaultMaxResultsPerColumnFamily { get.Get.StoreLimit = &g.storeLimit } if g.storeOffset != 0 { get.Get.StoreOffset = &g.storeOffset } if g.maxVersions != DefaultMaxVersions { get.Get.MaxVersions = &g.maxVersions } if g.fromTimestamp != MinTimestamp { get.Get.TimeRange.From = &g.fromTimestamp } if g.toTimestamp != MaxTimestamp { get.Get.TimeRange.To = &g.toTimestamp } if g.existsOnly { get.Get.ExistenceOnly = proto.Bool(true) } get.Get.Filter = g.filter return get }
go
func (g *Get) ToProto() proto.Message { get := &pb.GetRequest{ Region: g.regionSpecifier(), Get: &pb.Get{ Row: g.key, Column: familiesToColumn(g.families), TimeRange: &pb.TimeRange{}, }, } /* added support for limit number of cells per row */ if g.storeLimit != DefaultMaxResultsPerColumnFamily { get.Get.StoreLimit = &g.storeLimit } if g.storeOffset != 0 { get.Get.StoreOffset = &g.storeOffset } if g.maxVersions != DefaultMaxVersions { get.Get.MaxVersions = &g.maxVersions } if g.fromTimestamp != MinTimestamp { get.Get.TimeRange.From = &g.fromTimestamp } if g.toTimestamp != MaxTimestamp { get.Get.TimeRange.To = &g.toTimestamp } if g.existsOnly { get.Get.ExistenceOnly = proto.Bool(true) } get.Get.Filter = g.filter return get }
[ "func", "(", "g", "*", "Get", ")", "ToProto", "(", ")", "proto", ".", "Message", "{", "get", ":=", "&", "pb", ".", "GetRequest", "{", "Region", ":", "g", ".", "regionSpecifier", "(", ")", ",", "Get", ":", "&", "pb", ".", "Get", "{", "Row", ":",...
// ToProto converts this RPC into a protobuf message.
[ "ToProto", "converts", "this", "RPC", "into", "a", "protobuf", "message", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/get.go#L78-L110
152,011
tsuna/gohbase
hrpc/get.go
DeserializeCellBlocks
func (g *Get) DeserializeCellBlocks(m proto.Message, b []byte) (uint32, error) { resp := m.(*pb.GetResponse) if resp.Result == nil { // TODO: is this possible? return 0, nil } cells, read, err := deserializeCellBlocks(b, uint32(resp.Result.GetAssociatedCellCount())) if err != nil { return 0, err } resp.Result.Cell = append(resp.Result.Cell, cells...) return read, nil }
go
func (g *Get) DeserializeCellBlocks(m proto.Message, b []byte) (uint32, error) { resp := m.(*pb.GetResponse) if resp.Result == nil { // TODO: is this possible? return 0, nil } cells, read, err := deserializeCellBlocks(b, uint32(resp.Result.GetAssociatedCellCount())) if err != nil { return 0, err } resp.Result.Cell = append(resp.Result.Cell, cells...) return read, nil }
[ "func", "(", "g", "*", "Get", ")", "DeserializeCellBlocks", "(", "m", "proto", ".", "Message", ",", "b", "[", "]", "byte", ")", "(", "uint32", ",", "error", ")", "{", "resp", ":=", "m", ".", "(", "*", "pb", ".", "GetResponse", ")", "\n", "if", ...
// DeserializeCellBlocks deserializes get result from cell blocks
[ "DeserializeCellBlocks", "deserializes", "get", "result", "from", "cell", "blocks" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/get.go#L119-L131
152,012
tsuna/gohbase
hrpc/get.go
familiesToColumn
func familiesToColumn(families map[string][]string) []*pb.Column { cols := make([]*pb.Column, len(families)) counter := 0 for family, qualifiers := range families { bytequals := make([][]byte, len(qualifiers)) for i, qual := range qualifiers { bytequals[i] = []byte(qual) } cols[counter] = &pb.Column{ Family: []byte(family), Qualifier: bytequals, } counter++ } return cols }
go
func familiesToColumn(families map[string][]string) []*pb.Column { cols := make([]*pb.Column, len(families)) counter := 0 for family, qualifiers := range families { bytequals := make([][]byte, len(qualifiers)) for i, qual := range qualifiers { bytequals[i] = []byte(qual) } cols[counter] = &pb.Column{ Family: []byte(family), Qualifier: bytequals, } counter++ } return cols }
[ "func", "familiesToColumn", "(", "families", "map", "[", "string", "]", "[", "]", "string", ")", "[", "]", "*", "pb", ".", "Column", "{", "cols", ":=", "make", "(", "[", "]", "*", "pb", ".", "Column", ",", "len", "(", "families", ")", ")", "\n", ...
// familiesToColumn takes a map from strings to lists of strings, and converts // them into protobuf Columns
[ "familiesToColumn", "takes", "a", "map", "from", "strings", "to", "lists", "of", "strings", "and", "converts", "them", "into", "protobuf", "Columns" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/get.go#L135-L150
152,013
tsuna/gohbase
zk/client.go
Prepend
func (r ResourceName) Prepend(prefix string) ResourceName { return ResourceName(path.Join(prefix, string(r))) }
go
func (r ResourceName) Prepend(prefix string) ResourceName { return ResourceName(path.Join(prefix, string(r))) }
[ "func", "(", "r", "ResourceName", ")", "Prepend", "(", "prefix", "string", ")", "ResourceName", "{", "return", "ResourceName", "(", "path", ".", "Join", "(", "prefix", ",", "string", "(", "r", ")", ")", ")", "\n", "}" ]
// Prepend creates a new ResourceName with prefix prepended to the former ResourceName.
[ "Prepend", "creates", "a", "new", "ResourceName", "with", "prefix", "prepended", "to", "the", "former", "ResourceName", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/zk/client.go#L39-L41
152,014
tsuna/gohbase
zk/client.go
NewClient
func NewClient(zkquorum string, st time.Duration) Client { return &client{ zks: strings.Split(zkquorum, ","), sessionTimeout: st, } }
go
func NewClient(zkquorum string, st time.Duration) Client { return &client{ zks: strings.Split(zkquorum, ","), sessionTimeout: st, } }
[ "func", "NewClient", "(", "zkquorum", "string", ",", "st", "time", ".", "Duration", ")", "Client", "{", "return", "&", "client", "{", "zks", ":", "strings", ".", "Split", "(", "zkquorum", ",", "\"", "\"", ")", ",", "sessionTimeout", ":", "st", ",", "...
// NewClient establishes connection to zookeeper and returns the client
[ "NewClient", "establishes", "connection", "to", "zookeeper", "and", "returns", "the", "client" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/zk/client.go#L64-L69
152,015
tsuna/gohbase
zk/client.go
LocateResource
func (c *client) LocateResource(resource ResourceName) (string, error) { conn, _, err := zk.Connect(c.zks, c.sessionTimeout) if err != nil { return "", fmt.Errorf("error connecting to ZooKeeper at %v: %s", c.zks, err) } defer conn.Close() buf, _, err := conn.Get(string(resource)) if err != nil { return "", fmt.Errorf("failed to read the %s znode: %s", resource, err) } if len(buf) == 0 { log.Fatalf("%s was empty!", resource) } else if buf[0] != 0xFF { return "", fmt.Errorf("the first byte of %s was 0x%x, not 0xFF", resource, buf[0]) } metadataLen := binary.BigEndian.Uint32(buf[1:]) if metadataLen < 1 || metadataLen > 65000 { return "", fmt.Errorf("invalid metadata length for %s: %d", resource, metadataLen) } buf = buf[1+4+metadataLen:] magic := binary.BigEndian.Uint32(buf) const pbufMagic = 1346524486 // 4 bytes: "PBUF" if magic != pbufMagic { return "", fmt.Errorf("invalid magic number for %s: %d", resource, magic) } buf = buf[4:] var server *pb.ServerName if resource == Meta { meta := &pb.MetaRegionServer{} err = proto.UnmarshalMerge(buf, meta) if err != nil { return "", fmt.Errorf("failed to deserialize the MetaRegionServer entry from ZK: %s", err) } server = meta.Server } else { master := &pb.Master{} err = proto.UnmarshalMerge(buf, master) if err != nil { return "", fmt.Errorf("failed to deserialize the Master entry from ZK: %s", err) } server = master.Master } return net.JoinHostPort(*server.HostName, fmt.Sprint(*server.Port)), nil }
go
func (c *client) LocateResource(resource ResourceName) (string, error) { conn, _, err := zk.Connect(c.zks, c.sessionTimeout) if err != nil { return "", fmt.Errorf("error connecting to ZooKeeper at %v: %s", c.zks, err) } defer conn.Close() buf, _, err := conn.Get(string(resource)) if err != nil { return "", fmt.Errorf("failed to read the %s znode: %s", resource, err) } if len(buf) == 0 { log.Fatalf("%s was empty!", resource) } else if buf[0] != 0xFF { return "", fmt.Errorf("the first byte of %s was 0x%x, not 0xFF", resource, buf[0]) } metadataLen := binary.BigEndian.Uint32(buf[1:]) if metadataLen < 1 || metadataLen > 65000 { return "", fmt.Errorf("invalid metadata length for %s: %d", resource, metadataLen) } buf = buf[1+4+metadataLen:] magic := binary.BigEndian.Uint32(buf) const pbufMagic = 1346524486 // 4 bytes: "PBUF" if magic != pbufMagic { return "", fmt.Errorf("invalid magic number for %s: %d", resource, magic) } buf = buf[4:] var server *pb.ServerName if resource == Meta { meta := &pb.MetaRegionServer{} err = proto.UnmarshalMerge(buf, meta) if err != nil { return "", fmt.Errorf("failed to deserialize the MetaRegionServer entry from ZK: %s", err) } server = meta.Server } else { master := &pb.Master{} err = proto.UnmarshalMerge(buf, master) if err != nil { return "", fmt.Errorf("failed to deserialize the Master entry from ZK: %s", err) } server = master.Master } return net.JoinHostPort(*server.HostName, fmt.Sprint(*server.Port)), nil }
[ "func", "(", "c", "*", "client", ")", "LocateResource", "(", "resource", "ResourceName", ")", "(", "string", ",", "error", ")", "{", "conn", ",", "_", ",", "err", ":=", "zk", ".", "Connect", "(", "c", ".", "zks", ",", "c", ".", "sessionTimeout", ")...
// LocateResource returns address of the server for the specified resource.
[ "LocateResource", "returns", "address", "of", "the", "server", "for", "the", "specified", "resource", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/zk/client.go#L72-L118
152,016
tsuna/gohbase
hrpc/enable.go
NewEnableTable
func NewEnableTable(ctx context.Context, table []byte) *EnableTable { return &EnableTable{ base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, } }
go
func NewEnableTable(ctx context.Context, table []byte) *EnableTable { return &EnableTable{ base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, } }
[ "func", "NewEnableTable", "(", "ctx", "context", ".", "Context", ",", "table", "[", "]", "byte", ")", "*", "EnableTable", "{", "return", "&", "EnableTable", "{", "base", "{", "table", ":", "table", ",", "ctx", ":", "ctx", ",", "resultch", ":", "make", ...
// NewEnableTable creates a new EnableTable request that will enable the // given table in HBase. For use by the admin client.
[ "NewEnableTable", "creates", "a", "new", "EnableTable", "request", "that", "will", "enable", "the", "given", "table", "in", "HBase", ".", "For", "use", "by", "the", "admin", "client", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/enable.go#L22-L30
152,017
tsuna/gohbase
hrpc/mutate.go
TTL
func TTL(t time.Duration) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'TTL' option can only be used with mutation queries") } buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, uint64(t.Nanoseconds()/1e6)) m.ttl = buf return nil } }
go
func TTL(t time.Duration) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'TTL' option can only be used with mutation queries") } buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, uint64(t.Nanoseconds()/1e6)) m.ttl = buf return nil } }
[ "func", "TTL", "(", "t", "time", ".", "Duration", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "o", "Call", ")", "error", "{", "m", ",", "ok", ":=", "o", ".", "(", "*", "Mutate", ")", "\n", "if", "!", "ok", "{", "return...
// TTL sets a time-to-live for mutation queries. // The value will be in millisecond resolution.
[ "TTL", "sets", "a", "time", "-", "to", "-", "live", "for", "mutation", "queries", ".", "The", "value", "will", "be", "in", "millisecond", "resolution", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L68-L81
152,018
tsuna/gohbase
hrpc/mutate.go
Timestamp
func Timestamp(ts time.Time) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'Timestamp' option can only be used with mutation queries") } m.timestamp = uint64(ts.UnixNano() / 1e6) return nil } }
go
func Timestamp(ts time.Time) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'Timestamp' option can only be used with mutation queries") } m.timestamp = uint64(ts.UnixNano() / 1e6) return nil } }
[ "func", "Timestamp", "(", "ts", "time", ".", "Time", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "o", "Call", ")", "error", "{", "m", ",", "ok", ":=", "o", ".", "(", "*", "Mutate", ")", "\n", "if", "!", "ok", "{", "ret...
// Timestamp sets timestamp for mutation queries. // The time object passed will be rounded to a millisecond resolution, as by default, // if no timestamp is provided, HBase sets it to current time in milliseconds. // In order to have custom time precision, use TimestampUint64 call option for // mutation requests and corresponding TimeRangeUint64 for retrieval requests.
[ "Timestamp", "sets", "timestamp", "for", "mutation", "queries", ".", "The", "time", "object", "passed", "will", "be", "rounded", "to", "a", "millisecond", "resolution", "as", "by", "default", "if", "no", "timestamp", "is", "provided", "HBase", "sets", "it", ...
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L88-L97
152,019
tsuna/gohbase
hrpc/mutate.go
TimestampUint64
func TimestampUint64(ts uint64) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'TimestampUint64' option can only be used with mutation queries") } m.timestamp = ts return nil } }
go
func TimestampUint64(ts uint64) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'TimestampUint64' option can only be used with mutation queries") } m.timestamp = ts return nil } }
[ "func", "TimestampUint64", "(", "ts", "uint64", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "o", "Call", ")", "error", "{", "m", ",", "ok", ":=", "o", ".", "(", "*", "Mutate", ")", "\n", "if", "!", "ok", "{", "return", "...
// TimestampUint64 sets timestamp for mutation queries.
[ "TimestampUint64", "sets", "timestamp", "for", "mutation", "queries", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L100-L109
152,020
tsuna/gohbase
hrpc/mutate.go
Durability
func Durability(d DurabilityType) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'Durability' option can only be used with mutation queries") } if d < UseDefault || d > FsyncWal { return errors.New("invalid durability value") } m.durability = d return nil } }
go
func Durability(d DurabilityType) func(Call) error { return func(o Call) error { m, ok := o.(*Mutate) if !ok { return errors.New("'Durability' option can only be used with mutation queries") } if d < UseDefault || d > FsyncWal { return errors.New("invalid durability value") } m.durability = d return nil } }
[ "func", "Durability", "(", "d", "DurabilityType", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "o", "Call", ")", "error", "{", "m", ",", "ok", ":=", "o", ".", "(", "*", "Mutate", ")", "\n", "if", "!", "ok", "{", "return", ...
// Durability sets durability for mutation queries.
[ "Durability", "sets", "durability", "for", "mutation", "queries", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L112-L124
152,021
tsuna/gohbase
hrpc/mutate.go
baseMutate
func baseMutate(ctx context.Context, table, key []byte, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { m := &Mutate{ base: base{ table: table, key: key, ctx: ctx, resultch: make(chan RPCResult, 1), }, values: values, timestamp: MaxTimestamp, } err := applyOptions(m, options...) if err != nil { return nil, err } return m, nil }
go
func baseMutate(ctx context.Context, table, key []byte, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { m := &Mutate{ base: base{ table: table, key: key, ctx: ctx, resultch: make(chan RPCResult, 1), }, values: values, timestamp: MaxTimestamp, } err := applyOptions(m, options...) if err != nil { return nil, err } return m, nil }
[ "func", "baseMutate", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "[", "]", "byte", ",", "values", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error"...
// baseMutate returns a Mutate struct without the mutationType filled in.
[ "baseMutate", "returns", "a", "Mutate", "struct", "without", "the", "mutationType", "filled", "in", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L144-L161
152,022
tsuna/gohbase
hrpc/mutate.go
NewPutStr
func NewPutStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewPut(ctx, []byte(table), []byte(key), values, options...) }
go
func NewPutStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewPut(ctx, []byte(table), []byte(key), values, options...) }
[ "func", "NewPutStr", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "string", ",", "values", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(...
// NewPutStr is just like NewPut but takes table and key as strings.
[ "NewPutStr", "is", "just", "like", "NewPut", "but", "takes", "table", "and", "key", "as", "strings", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L176-L179
152,023
tsuna/gohbase
hrpc/mutate.go
NewDelStr
func NewDelStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewDel(ctx, []byte(table), []byte(key), values, options...) }
go
func NewDelStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewDel(ctx, []byte(table), []byte(key), values, options...) }
[ "func", "NewDelStr", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "string", ",", "values", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(...
// NewDelStr is just like NewDel but takes table and key as strings.
[ "NewDelStr", "is", "just", "like", "NewDel", "but", "takes", "table", "and", "key", "as", "strings", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L223-L226
152,024
tsuna/gohbase
hrpc/mutate.go
NewAppStr
func NewAppStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewApp(ctx, []byte(table), []byte(key), values, options...) }
go
func NewAppStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewApp(ctx, []byte(table), []byte(key), values, options...) }
[ "func", "NewAppStr", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "string", ",", "values", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(...
// NewAppStr is just like NewApp but takes table and key as strings.
[ "NewAppStr", "is", "just", "like", "NewApp", "but", "takes", "table", "and", "key", "as", "strings", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L242-L245
152,025
tsuna/gohbase
hrpc/mutate.go
NewIncSingle
func NewIncSingle(ctx context.Context, table, key []byte, family, qualifier string, amount int64, options ...func(Call) error) (*Mutate, error) { buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, uint64(amount)) value := map[string]map[string][]byte{family: map[string][]byte{qualifier: buf}} return NewInc(ctx, table, key, value, options...) }
go
func NewIncSingle(ctx context.Context, table, key []byte, family, qualifier string, amount int64, options ...func(Call) error) (*Mutate, error) { buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, uint64(amount)) value := map[string]map[string][]byte{family: map[string][]byte{qualifier: buf}} return NewInc(ctx, table, key, value, options...) }
[ "func", "NewIncSingle", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "[", "]", "byte", ",", "family", ",", "qualifier", "string", ",", "amount", "int64", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Mu...
// NewIncSingle creates a new Mutation request that will increment the given value // by amount in HBase under the given table, key, family and qualifier.
[ "NewIncSingle", "creates", "a", "new", "Mutation", "request", "that", "will", "increment", "the", "given", "value", "by", "amount", "in", "HBase", "under", "the", "given", "table", "key", "family", "and", "qualifier", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L249-L255
152,026
tsuna/gohbase
hrpc/mutate.go
NewIncStrSingle
func NewIncStrSingle(ctx context.Context, table, key, family, qualifier string, amount int64, options ...func(Call) error) (*Mutate, error) { return NewIncSingle(ctx, []byte(table), []byte(key), family, qualifier, amount, options...) }
go
func NewIncStrSingle(ctx context.Context, table, key, family, qualifier string, amount int64, options ...func(Call) error) (*Mutate, error) { return NewIncSingle(ctx, []byte(table), []byte(key), family, qualifier, amount, options...) }
[ "func", "NewIncStrSingle", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", ",", "family", ",", "qualifier", "string", ",", "amount", "int64", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Mutate", ",", "erro...
// NewIncStrSingle is just like NewIncSingle but takes table and key as strings.
[ "NewIncStrSingle", "is", "just", "like", "NewIncSingle", "but", "takes", "table", "and", "key", "as", "strings", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L258-L261
152,027
tsuna/gohbase
hrpc/mutate.go
NewInc
func NewInc(ctx context.Context, table, key []byte, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { m, err := baseMutate(ctx, table, key, values, options...) if err != nil { return nil, err } m.mutationType = pb.MutationProto_INCREMENT return m, nil }
go
func NewInc(ctx context.Context, table, key []byte, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { m, err := baseMutate(ctx, table, key, values, options...) if err != nil { return nil, err } m.mutationType = pb.MutationProto_INCREMENT return m, nil }
[ "func", "NewInc", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "[", "]", "byte", ",", "values", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ...
// NewInc creates a new Mutation request that will increment the given values // in HBase under the given table and key.
[ "NewInc", "creates", "a", "new", "Mutation", "request", "that", "will", "increment", "the", "given", "values", "in", "HBase", "under", "the", "given", "table", "and", "key", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L265-L273
152,028
tsuna/gohbase
hrpc/mutate.go
NewIncStr
func NewIncStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewInc(ctx, []byte(table), []byte(key), values, options...) }
go
func NewIncStr(ctx context.Context, table, key string, values map[string]map[string][]byte, options ...func(Call) error) (*Mutate, error) { return NewInc(ctx, []byte(table), []byte(key), values, options...) }
[ "func", "NewIncStr", "(", "ctx", "context", ".", "Context", ",", "table", ",", "key", "string", ",", "values", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(...
// NewIncStr is just like NewInc but takes table and key as strings.
[ "NewIncStr", "is", "just", "like", "NewInc", "but", "takes", "table", "and", "key", "as", "strings", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L276-L279
152,029
tsuna/gohbase
hrpc/mutate.go
DeserializeCellBlocks
func (m *Mutate) DeserializeCellBlocks(pm proto.Message, b []byte) (uint32, error) { resp := pm.(*pb.MutateResponse) if resp.Result == nil { // TODO: is this possible? return 0, nil } cells, read, err := deserializeCellBlocks(b, uint32(resp.Result.GetAssociatedCellCount())) if err != nil { return 0, err } resp.Result.Cell = append(resp.Result.Cell, cells...) return read, nil }
go
func (m *Mutate) DeserializeCellBlocks(pm proto.Message, b []byte) (uint32, error) { resp := pm.(*pb.MutateResponse) if resp.Result == nil { // TODO: is this possible? return 0, nil } cells, read, err := deserializeCellBlocks(b, uint32(resp.Result.GetAssociatedCellCount())) if err != nil { return 0, err } resp.Result.Cell = append(resp.Result.Cell, cells...) return read, nil }
[ "func", "(", "m", "*", "Mutate", ")", "DeserializeCellBlocks", "(", "pm", "proto", ".", "Message", ",", "b", "[", "]", "byte", ")", "(", "uint32", ",", "error", ")", "{", "resp", ":=", "pm", ".", "(", "*", "pb", ".", "MutateResponse", ")", "\n", ...
// DeserializeCellBlocks deserializes mutate result from cell blocks
[ "DeserializeCellBlocks", "deserializes", "mutate", "result", "from", "cell", "blocks" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/mutate.go#L385-L397
152,030
tsuna/gohbase
region/new.go
NewClient
func NewClient(ctx context.Context, addr string, ctype ClientType, queueSize int, flushInterval time.Duration, effectiveUser string, readTimeout time.Duration) (hrpc.RegionClient, error) { var d net.Dialer conn, err := d.DialContext(ctx, "tcp", addr) if err != nil { return nil, fmt.Errorf("failed to connect to the RegionServer at %s: %s", addr, err) } c := &client{ addr: addr, conn: conn, rpcs: make(chan hrpc.Call), done: make(chan struct{}), sent: make(map[uint32]hrpc.Call), rpcQueueSize: queueSize, flushInterval: flushInterval, effectiveUser: effectiveUser, readTimeout: readTimeout, } // time out send hello if it take long // TODO: do we even need to bother, we are going to retry anyway? if deadline, ok := ctx.Deadline(); ok { conn.SetWriteDeadline(deadline) } if err := c.sendHello(ctype); err != nil { conn.Close() return nil, fmt.Errorf("failed to send hello to the RegionServer at %s: %s", addr, err) } // reset write deadline conn.SetWriteDeadline(time.Time{}) if ctype == RegionClient { go c.processRPCs() // Batching goroutine } go c.receiveRPCs() // Reader goroutine return c, nil }
go
func NewClient(ctx context.Context, addr string, ctype ClientType, queueSize int, flushInterval time.Duration, effectiveUser string, readTimeout time.Duration) (hrpc.RegionClient, error) { var d net.Dialer conn, err := d.DialContext(ctx, "tcp", addr) if err != nil { return nil, fmt.Errorf("failed to connect to the RegionServer at %s: %s", addr, err) } c := &client{ addr: addr, conn: conn, rpcs: make(chan hrpc.Call), done: make(chan struct{}), sent: make(map[uint32]hrpc.Call), rpcQueueSize: queueSize, flushInterval: flushInterval, effectiveUser: effectiveUser, readTimeout: readTimeout, } // time out send hello if it take long // TODO: do we even need to bother, we are going to retry anyway? if deadline, ok := ctx.Deadline(); ok { conn.SetWriteDeadline(deadline) } if err := c.sendHello(ctype); err != nil { conn.Close() return nil, fmt.Errorf("failed to send hello to the RegionServer at %s: %s", addr, err) } // reset write deadline conn.SetWriteDeadline(time.Time{}) if ctype == RegionClient { go c.processRPCs() // Batching goroutine } go c.receiveRPCs() // Reader goroutine return c, nil }
[ "func", "NewClient", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ",", "ctype", "ClientType", ",", "queueSize", "int", ",", "flushInterval", "time", ".", "Duration", ",", "effectiveUser", "string", ",", "readTimeout", "time", ".", "Duration", ...
// NewClient creates a new RegionClient.
[ "NewClient", "creates", "a", "new", "RegionClient", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/new.go#L20-L56
152,031
tsuna/gohbase
hrpc/query.go
newBaseQuery
func newBaseQuery() baseQuery { return baseQuery{ storeLimit: DefaultMaxResultsPerColumnFamily, fromTimestamp: MinTimestamp, toTimestamp: MaxTimestamp, maxVersions: DefaultMaxVersions, } }
go
func newBaseQuery() baseQuery { return baseQuery{ storeLimit: DefaultMaxResultsPerColumnFamily, fromTimestamp: MinTimestamp, toTimestamp: MaxTimestamp, maxVersions: DefaultMaxVersions, } }
[ "func", "newBaseQuery", "(", ")", "baseQuery", "{", "return", "baseQuery", "{", "storeLimit", ":", "DefaultMaxResultsPerColumnFamily", ",", "fromTimestamp", ":", "MinTimestamp", ",", "toTimestamp", ":", "MaxTimestamp", ",", "maxVersions", ":", "DefaultMaxVersions", ",...
// newBaseQuery return baseQuery with all default values
[ "newBaseQuery", "return", "baseQuery", "with", "all", "default", "values" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/query.go#L29-L36
152,032
tsuna/gohbase
hrpc/query.go
Families
func Families(f map[string][]string) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { c.setFamilies(f) return nil } return errors.New("'Families' option can only be used with Get or Scan request") } }
go
func Families(f map[string][]string) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { c.setFamilies(f) return nil } return errors.New("'Families' option can only be used with Get or Scan request") } }
[ "func", "Families", "(", "f", "map", "[", "string", "]", "[", "]", "string", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "hc", "Call", ")", "error", "{", "if", "c", ",", "ok", ":=", "hc", ".", "(", "hasQueryOptions", ")", ...
// Families option adds families constraint to a Scan or Get request.
[ "Families", "option", "adds", "families", "constraint", "to", "a", "Scan", "or", "Get", "request", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/query.go#L59-L67
152,033
tsuna/gohbase
hrpc/query.go
Filters
func Filters(f filter.Filter) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { pbF, err := f.ConstructPBFilter() if err != nil { return err } c.setFilter(pbF) return nil } return errors.New("'Filters' option can only be used with Get or Scan request") } }
go
func Filters(f filter.Filter) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { pbF, err := f.ConstructPBFilter() if err != nil { return err } c.setFilter(pbF) return nil } return errors.New("'Filters' option can only be used with Get or Scan request") } }
[ "func", "Filters", "(", "f", "filter", ".", "Filter", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "hc", "Call", ")", "error", "{", "if", "c", ",", "ok", ":=", "hc", ".", "(", "hasQueryOptions", ")", ";", "ok", "{", "pbF", ...
// Filters option adds filters constraint to a Scan or Get request.
[ "Filters", "option", "adds", "filters", "constraint", "to", "a", "Scan", "or", "Get", "request", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/query.go#L70-L82
152,034
tsuna/gohbase
hrpc/query.go
MaxVersions
func MaxVersions(versions uint32) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { if versions > math.MaxInt32 { return errors.New("'MaxVersions' exceeds supported number of versions") } c.setMaxVersions(versions) return nil } return errors.New("'MaxVersions' option can only be used with Get or Scan request") } }
go
func MaxVersions(versions uint32) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { if versions > math.MaxInt32 { return errors.New("'MaxVersions' exceeds supported number of versions") } c.setMaxVersions(versions) return nil } return errors.New("'MaxVersions' option can only be used with Get or Scan request") } }
[ "func", "MaxVersions", "(", "versions", "uint32", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "hc", "Call", ")", "error", "{", "if", "c", ",", "ok", ":=", "hc", ".", "(", "hasQueryOptions", ")", ";", "ok", "{", "if", "versio...
// MaxVersions is used as a parameter for request creation. // Adds MaxVersions constraint to a request.
[ "MaxVersions", "is", "used", "as", "a", "parameter", "for", "request", "creation", ".", "Adds", "MaxVersions", "constraint", "to", "a", "request", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/query.go#L110-L121
152,035
tsuna/gohbase
hrpc/query.go
MaxResultsPerColumnFamily
func MaxResultsPerColumnFamily(maxresults uint32) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { if maxresults > math.MaxInt32 { return errors.New( "'MaxResultsPerColumnFamily' exceeds supported number of value results") } c.setMaxResultsPerColumnFamily(maxresults) return nil } return errors.New( "'MaxResultsPerColumnFamily' option can only be used with Get or Scan request") } }
go
func MaxResultsPerColumnFamily(maxresults uint32) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { if maxresults > math.MaxInt32 { return errors.New( "'MaxResultsPerColumnFamily' exceeds supported number of value results") } c.setMaxResultsPerColumnFamily(maxresults) return nil } return errors.New( "'MaxResultsPerColumnFamily' option can only be used with Get or Scan request") } }
[ "func", "MaxResultsPerColumnFamily", "(", "maxresults", "uint32", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "hc", "Call", ")", "error", "{", "if", "c", ",", "ok", ":=", "hc", ".", "(", "hasQueryOptions", ")", ";", "ok", "{", ...
// MaxResultsPerColumnFamily is an option for Get or Scan requests that sets the maximum // number of cells returned per column family in a row.
[ "MaxResultsPerColumnFamily", "is", "an", "option", "for", "Get", "or", "Scan", "requests", "that", "sets", "the", "maximum", "number", "of", "cells", "returned", "per", "column", "family", "in", "a", "row", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/query.go#L125-L138
152,036
tsuna/gohbase
hrpc/query.go
ResultOffset
func ResultOffset(offset uint32) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { if offset > math.MaxInt32 { return errors.New("'ResultOffset' exceeds supported offset value") } c.setResultOffset(offset) return nil } return errors.New("'ResultOffset' option can only be used with Get or Scan request") } }
go
func ResultOffset(offset uint32) func(Call) error { return func(hc Call) error { if c, ok := hc.(hasQueryOptions); ok { if offset > math.MaxInt32 { return errors.New("'ResultOffset' exceeds supported offset value") } c.setResultOffset(offset) return nil } return errors.New("'ResultOffset' option can only be used with Get or Scan request") } }
[ "func", "ResultOffset", "(", "offset", "uint32", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "hc", "Call", ")", "error", "{", "if", "c", ",", "ok", ":=", "hc", ".", "(", "hasQueryOptions", ")", ";", "ok", "{", "if", "offset"...
// ResultOffset is a option for Scan or Get requests that sets the offset for cells // within a column family.
[ "ResultOffset", "is", "a", "option", "for", "Scan", "or", "Get", "requests", "that", "sets", "the", "offset", "for", "cells", "within", "a", "column", "family", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/query.go#L142-L153
152,037
tsuna/gohbase
hrpc/status.go
NewClusterStatus
func NewClusterStatus() *ClusterStatus { return &ClusterStatus{ base{ ctx: context.Background(), table: []byte{}, resultch: make(chan RPCResult, 1), }, } }
go
func NewClusterStatus() *ClusterStatus { return &ClusterStatus{ base{ ctx: context.Background(), table: []byte{}, resultch: make(chan RPCResult, 1), }, } }
[ "func", "NewClusterStatus", "(", ")", "*", "ClusterStatus", "{", "return", "&", "ClusterStatus", "{", "base", "{", "ctx", ":", "context", ".", "Background", "(", ")", ",", "table", ":", "[", "]", "byte", "{", "}", ",", "resultch", ":", "make", "(", "...
// NewClusterStatus creates a new ClusterStatusStruct with default fields
[ "NewClusterStatus", "creates", "a", "new", "ClusterStatusStruct", "with", "default", "fields" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/status.go#L16-L24
152,038
tsuna/gohbase
hrpc/scan.go
baseScan
func baseScan(ctx context.Context, table []byte, options ...func(Call) error) (*Scan, error) { s := &Scan{ base: base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, baseQuery: newBaseQuery(), scannerID: math.MaxUint64, maxResultSize: DefaultMaxResultSize, numberOfRows: DefaultNumberOfRows, reversed: false, } err := applyOptions(s, options...) if err != nil { return nil, err } return s, nil }
go
func baseScan(ctx context.Context, table []byte, options ...func(Call) error) (*Scan, error) { s := &Scan{ base: base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, baseQuery: newBaseQuery(), scannerID: math.MaxUint64, maxResultSize: DefaultMaxResultSize, numberOfRows: DefaultNumberOfRows, reversed: false, } err := applyOptions(s, options...) if err != nil { return nil, err } return s, nil }
[ "func", "baseScan", "(", "ctx", "context", ".", "Context", ",", "table", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Scan", ",", "error", ")", "{", "s", ":=", "&", "Scan", "{", "base", ":", "base", ...
// baseScan returns a Scan struct with default values set.
[ "baseScan", "returns", "a", "Scan", "struct", "with", "default", "values", "set", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L74-L93
152,039
tsuna/gohbase
hrpc/scan.go
NewScan
func NewScan(ctx context.Context, table []byte, options ...func(Call) error) (*Scan, error) { return baseScan(ctx, table, options...) }
go
func NewScan(ctx context.Context, table []byte, options ...func(Call) error) (*Scan, error) { return baseScan(ctx, table, options...) }
[ "func", "NewScan", "(", "ctx", "context", ".", "Context", ",", "table", "[", "]", "byte", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Scan", ",", "error", ")", "{", "return", "baseScan", "(", "ctx", ",", "table", ",", ...
// NewScan creates a scanner for the given table.
[ "NewScan", "creates", "a", "scanner", "for", "the", "given", "table", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L105-L107
152,040
tsuna/gohbase
hrpc/scan.go
NewScanStr
func NewScanStr(ctx context.Context, table string, options ...func(Call) error) (*Scan, error) { return NewScan(ctx, []byte(table), options...) }
go
func NewScanStr(ctx context.Context, table string, options ...func(Call) error) (*Scan, error) { return NewScan(ctx, []byte(table), options...) }
[ "func", "NewScanStr", "(", "ctx", "context", ".", "Context", ",", "table", "string", ",", "options", "...", "func", "(", "Call", ")", "error", ")", "(", "*", "Scan", ",", "error", ")", "{", "return", "NewScan", "(", "ctx", ",", "[", "]", "byte", "(...
// NewScanStr creates a scanner for the given table.
[ "NewScanStr", "creates", "a", "scanner", "for", "the", "given", "table", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L125-L127
152,041
tsuna/gohbase
hrpc/scan.go
ToProto
func (s *Scan) ToProto() proto.Message { scan := &pb.ScanRequest{ Region: s.regionSpecifier(), CloseScanner: &s.closeScanner, NumberOfRows: &s.numberOfRows, // tell server that we can process results that are only part of a row ClientHandlesPartials: proto.Bool(true), // tell server that we "handle" heartbeats by ignoring them // since we don't really time out our scans (unless context was cancelled) ClientHandlesHeartbeats: proto.Bool(true), } if s.scannerID != math.MaxUint64 { scan.ScannerId = &s.scannerID return scan } scan.Scan = &pb.Scan{ Column: familiesToColumn(s.families), StartRow: s.startRow, StopRow: s.stopRow, TimeRange: &pb.TimeRange{}, MaxResultSize: &s.maxResultSize, } if s.maxVersions != DefaultMaxVersions { scan.Scan.MaxVersions = &s.maxVersions } /* added support for limit number of cells per row */ if s.storeLimit != DefaultMaxResultsPerColumnFamily { scan.Scan.StoreLimit = &s.storeLimit } if s.storeOffset != 0 { scan.Scan.StoreOffset = &s.storeOffset } if s.fromTimestamp != MinTimestamp { scan.Scan.TimeRange.From = &s.fromTimestamp } if s.toTimestamp != MaxTimestamp { scan.Scan.TimeRange.To = &s.toTimestamp } if s.reversed { scan.Scan.Reversed = &s.reversed } scan.Scan.Filter = s.filter return scan }
go
func (s *Scan) ToProto() proto.Message { scan := &pb.ScanRequest{ Region: s.regionSpecifier(), CloseScanner: &s.closeScanner, NumberOfRows: &s.numberOfRows, // tell server that we can process results that are only part of a row ClientHandlesPartials: proto.Bool(true), // tell server that we "handle" heartbeats by ignoring them // since we don't really time out our scans (unless context was cancelled) ClientHandlesHeartbeats: proto.Bool(true), } if s.scannerID != math.MaxUint64 { scan.ScannerId = &s.scannerID return scan } scan.Scan = &pb.Scan{ Column: familiesToColumn(s.families), StartRow: s.startRow, StopRow: s.stopRow, TimeRange: &pb.TimeRange{}, MaxResultSize: &s.maxResultSize, } if s.maxVersions != DefaultMaxVersions { scan.Scan.MaxVersions = &s.maxVersions } /* added support for limit number of cells per row */ if s.storeLimit != DefaultMaxResultsPerColumnFamily { scan.Scan.StoreLimit = &s.storeLimit } if s.storeOffset != 0 { scan.Scan.StoreOffset = &s.storeOffset } if s.fromTimestamp != MinTimestamp { scan.Scan.TimeRange.From = &s.fromTimestamp } if s.toTimestamp != MaxTimestamp { scan.Scan.TimeRange.To = &s.toTimestamp } if s.reversed { scan.Scan.Reversed = &s.reversed } scan.Scan.Filter = s.filter return scan }
[ "func", "(", "s", "*", "Scan", ")", "ToProto", "(", ")", "proto", ".", "Message", "{", "scan", ":=", "&", "pb", ".", "ScanRequest", "{", "Region", ":", "s", ".", "regionSpecifier", "(", ")", ",", "CloseScanner", ":", "&", "s", ".", "closeScanner", ...
// ToProto converts this Scan into a protobuf message
[ "ToProto", "converts", "this", "Scan", "into", "a", "protobuf", "message" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L174-L219
152,042
tsuna/gohbase
hrpc/scan.go
DeserializeCellBlocks
func (s *Scan) DeserializeCellBlocks(m proto.Message, b []byte) (uint32, error) { scanResp := m.(*pb.ScanResponse) partials := scanResp.GetPartialFlagPerResult() scanResp.Results = make([]*pb.Result, len(partials)) var readLen uint32 for i, numCells := range scanResp.GetCellsPerResult() { cells, l, err := deserializeCellBlocks(b[readLen:], numCells) if err != nil { return 0, err } scanResp.Results[i] = &pb.Result{ Cell: cells, Partial: proto.Bool(partials[i]), } readLen += l } return readLen, nil }
go
func (s *Scan) DeserializeCellBlocks(m proto.Message, b []byte) (uint32, error) { scanResp := m.(*pb.ScanResponse) partials := scanResp.GetPartialFlagPerResult() scanResp.Results = make([]*pb.Result, len(partials)) var readLen uint32 for i, numCells := range scanResp.GetCellsPerResult() { cells, l, err := deserializeCellBlocks(b[readLen:], numCells) if err != nil { return 0, err } scanResp.Results[i] = &pb.Result{ Cell: cells, Partial: proto.Bool(partials[i]), } readLen += l } return readLen, nil }
[ "func", "(", "s", "*", "Scan", ")", "DeserializeCellBlocks", "(", "m", "proto", ".", "Message", ",", "b", "[", "]", "byte", ")", "(", "uint32", ",", "error", ")", "{", "scanResp", ":=", "m", ".", "(", "*", "pb", ".", "ScanResponse", ")", "\n", "p...
// DeserializeCellBlocks deserializes scan results from cell blocks
[ "DeserializeCellBlocks", "deserializes", "scan", "results", "from", "cell", "blocks" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L228-L245
152,043
tsuna/gohbase
hrpc/scan.go
ScannerID
func ScannerID(id uint64) func(Call) error { return func(s Call) error { scan, ok := s.(*Scan) if !ok { return errors.New("'ScannerID' option can only be used with Scan queries") } scan.scannerID = id return nil } }
go
func ScannerID(id uint64) func(Call) error { return func(s Call) error { scan, ok := s.(*Scan) if !ok { return errors.New("'ScannerID' option can only be used with Scan queries") } scan.scannerID = id return nil } }
[ "func", "ScannerID", "(", "id", "uint64", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "s", "Call", ")", "error", "{", "scan", ",", "ok", ":=", "s", ".", "(", "*", "Scan", ")", "\n", "if", "!", "ok", "{", "return", "error...
// ScannerID is an option for scan requests. // This is an internal option to fetch the next set of results for an ongoing scan.
[ "ScannerID", "is", "an", "option", "for", "scan", "requests", ".", "This", "is", "an", "internal", "option", "to", "fetch", "the", "next", "set", "of", "results", "for", "an", "ongoing", "scan", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L249-L258
152,044
tsuna/gohbase
hrpc/scan.go
CloseScanner
func CloseScanner() func(Call) error { return func(s Call) error { scan, ok := s.(*Scan) if !ok { return errors.New("'Close' option can only be used with Scan queries") } scan.closeScanner = true return nil } }
go
func CloseScanner() func(Call) error { return func(s Call) error { scan, ok := s.(*Scan) if !ok { return errors.New("'Close' option can only be used with Scan queries") } scan.closeScanner = true return nil } }
[ "func", "CloseScanner", "(", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "s", "Call", ")", "error", "{", "scan", ",", "ok", ":=", "s", ".", "(", "*", "Scan", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New...
// CloseScanner is an option for scan requests. // Closes scanner after the first result is returned. This is an internal option // but could be useful if you know that your scan result fits into one response // in order to save an extra request.
[ "CloseScanner", "is", "an", "option", "for", "scan", "requests", ".", "Closes", "scanner", "after", "the", "first", "result", "is", "returned", ".", "This", "is", "an", "internal", "option", "but", "could", "be", "useful", "if", "you", "know", "that", "you...
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L264-L273
152,045
tsuna/gohbase
hrpc/scan.go
MaxResultSize
func MaxResultSize(n uint64) func(Call) error { return func(g Call) error { scan, ok := g.(*Scan) if !ok { return errors.New("'MaxResultSize' option can only be used with Scan queries") } if n == 0 { return errors.New("'MaxResultSize' option must be greater than 0") } scan.maxResultSize = n return nil } }
go
func MaxResultSize(n uint64) func(Call) error { return func(g Call) error { scan, ok := g.(*Scan) if !ok { return errors.New("'MaxResultSize' option can only be used with Scan queries") } if n == 0 { return errors.New("'MaxResultSize' option must be greater than 0") } scan.maxResultSize = n return nil } }
[ "func", "MaxResultSize", "(", "n", "uint64", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "g", "Call", ")", "error", "{", "scan", ",", "ok", ":=", "g", ".", "(", "*", "Scan", ")", "\n", "if", "!", "ok", "{", "return", "er...
// MaxResultSize is an option for scan requests. // Maximum number of bytes fetched when calling a scanner's next method. // MaxResultSize takes priority over NumberOfRows.
[ "MaxResultSize", "is", "an", "option", "for", "scan", "requests", ".", "Maximum", "number", "of", "bytes", "fetched", "when", "calling", "a", "scanner", "s", "next", "method", ".", "MaxResultSize", "takes", "priority", "over", "NumberOfRows", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L278-L290
152,046
tsuna/gohbase
hrpc/scan.go
NumberOfRows
func NumberOfRows(n uint32) func(Call) error { return func(g Call) error { scan, ok := g.(*Scan) if !ok { return errors.New("'NumberOfRows' option can only be used with Scan queries") } scan.numberOfRows = n return nil } }
go
func NumberOfRows(n uint32) func(Call) error { return func(g Call) error { scan, ok := g.(*Scan) if !ok { return errors.New("'NumberOfRows' option can only be used with Scan queries") } scan.numberOfRows = n return nil } }
[ "func", "NumberOfRows", "(", "n", "uint32", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "g", "Call", ")", "error", "{", "scan", ",", "ok", ":=", "g", ".", "(", "*", "Scan", ")", "\n", "if", "!", "ok", "{", "return", "err...
// NumberOfRows is an option for scan requests. // Specifies how many rows are fetched with each request to regionserver. // Should be > 0, avoid extremely low values such as 1 because a request // to regionserver will be made for every row.
[ "NumberOfRows", "is", "an", "option", "for", "scan", "requests", ".", "Specifies", "how", "many", "rows", "are", "fetched", "with", "each", "request", "to", "regionserver", ".", "Should", "be", ">", "0", "avoid", "extremely", "low", "values", "such", "as", ...
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L296-L305
152,047
tsuna/gohbase
hrpc/scan.go
Reversed
func Reversed() func(Call) error { return func(g Call) error { scan, ok := g.(*Scan) if !ok { return errors.New("'Reversed' option can only be used with Scan queries") } scan.reversed = true return nil } }
go
func Reversed() func(Call) error { return func(g Call) error { scan, ok := g.(*Scan) if !ok { return errors.New("'Reversed' option can only be used with Scan queries") } scan.reversed = true return nil } }
[ "func", "Reversed", "(", ")", "func", "(", "Call", ")", "error", "{", "return", "func", "(", "g", "Call", ")", "error", "{", "scan", ",", "ok", ":=", "g", ".", "(", "*", "Scan", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New", ...
// Reversed is a Scan-only option which allows you to scan in reverse key order // To use it the startKey would be greater than the end key
[ "Reversed", "is", "a", "Scan", "-", "only", "option", "which", "allows", "you", "to", "scan", "in", "reverse", "key", "order", "To", "use", "it", "the", "startKey", "would", "be", "greater", "than", "the", "end", "key" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/scan.go#L324-L333
152,048
tsuna/gohbase
admin_client.go
ClusterStatus
func (c *client) ClusterStatus() (*pb.ClusterStatus, error) { pbmsg, err := c.SendRPC(hrpc.NewClusterStatus()) if err != nil { return nil, err } r, ok := pbmsg.(*pb.GetClusterStatusResponse) if !ok { return nil, fmt.Errorf("sendRPC returned not a ClusterStatusResponse") } return r.GetClusterStatus(), nil }
go
func (c *client) ClusterStatus() (*pb.ClusterStatus, error) { pbmsg, err := c.SendRPC(hrpc.NewClusterStatus()) if err != nil { return nil, err } r, ok := pbmsg.(*pb.GetClusterStatusResponse) if !ok { return nil, fmt.Errorf("sendRPC returned not a ClusterStatusResponse") } return r.GetClusterStatus(), nil }
[ "func", "(", "c", "*", "client", ")", "ClusterStatus", "(", ")", "(", "*", "pb", ".", "ClusterStatus", ",", "error", ")", "{", "pbmsg", ",", "err", ":=", "c", ".", "SendRPC", "(", "hrpc", ".", "NewClusterStatus", "(", ")", ")", "\n", "if", "err", ...
//Get the status of the cluster
[ "Get", "the", "status", "of", "the", "cluster" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/admin_client.go#L58-L70
152,049
y0ssar1an/q
args.go
argWidth
func argWidth(arg string) int { // Strip zero-width characters. replacer := strings.NewReplacer( "\n", "", "\t", "", "\r", "", "\f", "", "\v", "", string(bold), "", string(yellow), "", string(cyan), "", string(endColor), "", ) s := replacer.Replace(arg) return utf8.RuneCountInString(s) }
go
func argWidth(arg string) int { // Strip zero-width characters. replacer := strings.NewReplacer( "\n", "", "\t", "", "\r", "", "\f", "", "\v", "", string(bold), "", string(yellow), "", string(cyan), "", string(endColor), "", ) s := replacer.Replace(arg) return utf8.RuneCountInString(s) }
[ "func", "argWidth", "(", "arg", "string", ")", "int", "{", "// Strip zero-width characters.", "replacer", ":=", "strings", ".", "NewReplacer", "(", "\"", "\\n", "\"", ",", "\"", "\"", ",", "\"", "\\t", "\"", ",", "\"", "\"", ",", "\"", "\\r", "\"", ","...
// argWidth returns the number of characters that will be seen when the given // argument is printed at the terminal.
[ "argWidth", "returns", "the", "number", "of", "characters", "that", "will", "be", "seen", "when", "the", "given", "argument", "is", "printed", "at", "the", "terminal", "." ]
befa58832e0b7483b4246ec6b31c007e0a358353
https://github.com/y0ssar1an/q/blob/befa58832e0b7483b4246ec6b31c007e0a358353/args.go#L90-L105
152,050
y0ssar1an/q
args.go
colorize
func colorize(text string, c color) string { return string(c) + text + string(endColor) }
go
func colorize(text string, c color) string { return string(c) + text + string(endColor) }
[ "func", "colorize", "(", "text", "string", ",", "c", "color", ")", "string", "{", "return", "string", "(", "c", ")", "+", "text", "+", "string", "(", "endColor", ")", "\n", "}" ]
// colorize returns the given text encapsulated in ANSI escape codes that // give the text color in the terminal.
[ "colorize", "returns", "the", "given", "text", "encapsulated", "in", "ANSI", "escape", "codes", "that", "give", "the", "text", "color", "in", "the", "terminal", "." ]
befa58832e0b7483b4246ec6b31c007e0a358353
https://github.com/y0ssar1an/q/blob/befa58832e0b7483b4246ec6b31c007e0a358353/args.go#L109-L111
152,051
y0ssar1an/q
args.go
formatArgs
func formatArgs(args ...interface{}) []string { formatted := make([]string, 0, len(args)) for _, a := range args { s := colorize(pretty.Sprint(a), cyan) formatted = append(formatted, s) } return formatted }
go
func formatArgs(args ...interface{}) []string { formatted := make([]string, 0, len(args)) for _, a := range args { s := colorize(pretty.Sprint(a), cyan) formatted = append(formatted, s) } return formatted }
[ "func", "formatArgs", "(", "args", "...", "interface", "{", "}", ")", "[", "]", "string", "{", "formatted", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "args", ")", ")", "\n", "for", "_", ",", "a", ":=", "range", "args", "...
// formatArgs converts the given args to pretty-printed, colorized strings.
[ "formatArgs", "converts", "the", "given", "args", "to", "pretty", "-", "printed", "colorized", "strings", "." ]
befa58832e0b7483b4246ec6b31c007e0a358353
https://github.com/y0ssar1an/q/blob/befa58832e0b7483b4246ec6b31c007e0a358353/args.go#L127-L134
152,052
y0ssar1an/q
logger.go
flush
func (l *logger) flush() (err error) { path := filepath.Join(os.TempDir(), "q") f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) if err != nil { return fmt.Errorf("failed to open %q: %v", path, err) } defer func() { if cerr := f.Close(); err == nil { err = cerr } l.lastWrite = time.Now() }() _, err = io.Copy(f, &l.buf) l.buf.Reset() if err != nil { return fmt.Errorf("failed to flush q buffer: %v", err) } return nil }
go
func (l *logger) flush() (err error) { path := filepath.Join(os.TempDir(), "q") f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) if err != nil { return fmt.Errorf("failed to open %q: %v", path, err) } defer func() { if cerr := f.Close(); err == nil { err = cerr } l.lastWrite = time.Now() }() _, err = io.Copy(f, &l.buf) l.buf.Reset() if err != nil { return fmt.Errorf("failed to flush q buffer: %v", err) } return nil }
[ "func", "(", "l", "*", "logger", ")", "flush", "(", ")", "(", "err", "error", ")", "{", "path", ":=", "filepath", ".", "Join", "(", "os", ".", "TempDir", "(", ")", ",", "\"", "\"", ")", "\n", "f", ",", "err", ":=", "os", ".", "OpenFile", "(",...
// flush writes the logger's buffer to disk.
[ "flush", "writes", "the", "logger", "s", "buffer", "to", "disk", "." ]
befa58832e0b7483b4246ec6b31c007e0a358353
https://github.com/y0ssar1an/q/blob/befa58832e0b7483b4246ec6b31c007e0a358353/logger.go#L74-L94
152,053
xyproto/permissions2
permissions.go
AddAdminPath
func (perm *Permissions) AddAdminPath(prefix string) { perm.adminPathPrefixes = append(perm.adminPathPrefixes, prefix) }
go
func (perm *Permissions) AddAdminPath(prefix string) { perm.adminPathPrefixes = append(perm.adminPathPrefixes, prefix) }
[ "func", "(", "perm", "*", "Permissions", ")", "AddAdminPath", "(", "prefix", "string", ")", "{", "perm", ".", "adminPathPrefixes", "=", "append", "(", "perm", ".", "adminPathPrefixes", ",", "prefix", ")", "\n", "}" ]
// AddAdminPath registers a path prefix for URLs that shall only be reached by logged in administrators
[ "AddAdminPath", "registers", "a", "path", "prefix", "for", "URLs", "that", "shall", "only", "be", "reached", "by", "logged", "in", "administrators" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/permissions.go#L92-L94
152,054
xyproto/permissions2
permissions.go
AddUserPath
func (perm *Permissions) AddUserPath(prefix string) { perm.userPathPrefixes = append(perm.userPathPrefixes, prefix) }
go
func (perm *Permissions) AddUserPath(prefix string) { perm.userPathPrefixes = append(perm.userPathPrefixes, prefix) }
[ "func", "(", "perm", "*", "Permissions", ")", "AddUserPath", "(", "prefix", "string", ")", "{", "perm", ".", "userPathPrefixes", "=", "append", "(", "perm", ".", "userPathPrefixes", ",", "prefix", ")", "\n", "}" ]
// AddUserPath registers a path prefix for URLs that shall only be reached by logged in users
[ "AddUserPath", "registers", "a", "path", "prefix", "for", "URLs", "that", "shall", "only", "be", "reached", "by", "logged", "in", "users" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/permissions.go#L97-L99
152,055
xyproto/permissions2
permissions.go
AddPublicPath
func (perm *Permissions) AddPublicPath(prefix string) { perm.publicPathPrefixes = append(perm.publicPathPrefixes, prefix) }
go
func (perm *Permissions) AddPublicPath(prefix string) { perm.publicPathPrefixes = append(perm.publicPathPrefixes, prefix) }
[ "func", "(", "perm", "*", "Permissions", ")", "AddPublicPath", "(", "prefix", "string", ")", "{", "perm", ".", "publicPathPrefixes", "=", "append", "(", "perm", ".", "publicPathPrefixes", ",", "prefix", ")", "\n", "}" ]
// AddPublicPath registers a path prefix for URLs that can be reached by anyone
[ "AddPublicPath", "registers", "a", "path", "prefix", "for", "URLs", "that", "can", "be", "reached", "by", "anyone" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/permissions.go#L102-L104
152,056
xyproto/permissions2
permissions.go
PermissionDenied
func PermissionDenied(w http.ResponseWriter, req *http.Request) { http.Error(w, "Permission denied.", http.StatusForbidden) }
go
func PermissionDenied(w http.ResponseWriter, req *http.Request) { http.Error(w, "Permission denied.", http.StatusForbidden) }
[ "func", "PermissionDenied", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "http", ".", "Error", "(", "w", ",", "\"", "\"", ",", "http", ".", "StatusForbidden", ")", "\n", "}" ]
// The default "permission denied" http handler.
[ "The", "default", "permission", "denied", "http", "handler", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/permissions.go#L122-L124
152,057
xyproto/permissions2
hashing.go
hashBcrypt
func hashBcrypt(password string) []byte { hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) if err != nil { panic("Permissions: bcrypt password hashing unsuccessful") } return hash }
go
func hashBcrypt(password string) []byte { hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) if err != nil { panic("Permissions: bcrypt password hashing unsuccessful") } return hash }
[ "func", "hashBcrypt", "(", "password", "string", ")", "[", "]", "byte", "{", "hash", ",", "err", ":=", "bcrypt", ".", "GenerateFromPassword", "(", "[", "]", "byte", "(", "password", ")", ",", "bcrypt", ".", "DefaultCost", ")", "\n", "if", "err", "!=", ...
// Hash the password with bcrypt
[ "Hash", "the", "password", "with", "bcrypt" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/hashing.go#L20-L26
152,058
xyproto/permissions2
hashing.go
correctBcrypt
func correctBcrypt(hash []byte, password string) bool { // prevents timing attack return bcrypt.CompareHashAndPassword(hash, []byte(password)) == nil }
go
func correctBcrypt(hash []byte, password string) bool { // prevents timing attack return bcrypt.CompareHashAndPassword(hash, []byte(password)) == nil }
[ "func", "correctBcrypt", "(", "hash", "[", "]", "byte", ",", "password", "string", ")", "bool", "{", "// prevents timing attack", "return", "bcrypt", ".", "CompareHashAndPassword", "(", "hash", ",", "[", "]", "byte", "(", "password", ")", ")", "==", "nil", ...
// Check if a given password is correct, for a given bcrypt hash
[ "Check", "if", "a", "given", "password", "is", "correct", "for", "a", "given", "bcrypt", "hash" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/hashing.go#L40-L43
152,059
xyproto/permissions2
userstate.go
NewUserStateWithPassword
func NewUserStateWithPassword(hostname, password string) *UserState { // db index 0, initialize random generator after generating the cookie secret, password var connectTo string switch { case (password == "") && (strings.Count(hostname, ":") == 0): connectTo = hostname + ":6379" case strings.Count(hostname, ":") > 0: connectTo = password + "@" + hostname default: connectTo = password + "@" + hostname + ":6379" } // Create a new UserState with database index 0, "true" for seeding the // random number generator and host string return NewUserState(0, true, connectTo) }
go
func NewUserStateWithPassword(hostname, password string) *UserState { // db index 0, initialize random generator after generating the cookie secret, password var connectTo string switch { case (password == "") && (strings.Count(hostname, ":") == 0): connectTo = hostname + ":6379" case strings.Count(hostname, ":") > 0: connectTo = password + "@" + hostname default: connectTo = password + "@" + hostname + ":6379" } // Create a new UserState with database index 0, "true" for seeding the // random number generator and host string return NewUserState(0, true, connectTo) }
[ "func", "NewUserStateWithPassword", "(", "hostname", ",", "password", "string", ")", "*", "UserState", "{", "// db index 0, initialize random generator after generating the cookie secret, password", "var", "connectTo", "string", "\n", "switch", "{", "case", "(", "password", ...
// Same as NewUserStateSimple, but takes a hostname and a password. // Use NewUserState for control over the database index and port number. // Calls log.Fatal if things go wrong.
[ "Same", "as", "NewUserStateSimple", "but", "takes", "a", "hostname", "and", "a", "password", ".", "Use", "NewUserState", "for", "control", "over", "the", "database", "index", "and", "port", "number", ".", "Calls", "log", ".", "Fatal", "if", "things", "go", ...
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L63-L77
152,060
xyproto/permissions2
userstate.go
NewUserStateWithPassword2
func NewUserStateWithPassword2(hostname, password string) (*UserState, error) { // db index 0, initialize random generator after generating the cookie secret, password var connectTo string if (password == "") && (strings.Count(hostname, ":") == 0) { connectTo = hostname + ":6379" } else if strings.Count(hostname, ":") > 0 { connectTo = password + "@" + hostname } else { connectTo = password + "@" + hostname + ":6379" } // Create a new UserState with database index 0, "true" for seeding the // random number generator and host string return NewUserState2(0, true, connectTo) }
go
func NewUserStateWithPassword2(hostname, password string) (*UserState, error) { // db index 0, initialize random generator after generating the cookie secret, password var connectTo string if (password == "") && (strings.Count(hostname, ":") == 0) { connectTo = hostname + ":6379" } else if strings.Count(hostname, ":") > 0 { connectTo = password + "@" + hostname } else { connectTo = password + "@" + hostname + ":6379" } // Create a new UserState with database index 0, "true" for seeding the // random number generator and host string return NewUserState2(0, true, connectTo) }
[ "func", "NewUserStateWithPassword2", "(", "hostname", ",", "password", "string", ")", "(", "*", "UserState", ",", "error", ")", "{", "// db index 0, initialize random generator after generating the cookie secret, password", "var", "connectTo", "string", "\n", "if", "(", "...
// Same as NewUserStateSimple, but takes a hostname and a password. // Use NewUserState for control over the database index and port number. // Returns an error if things go wrong.
[ "Same", "as", "NewUserStateSimple", "but", "takes", "a", "hostname", "and", "a", "password", ".", "Use", "NewUserState", "for", "control", "over", "the", "database", "index", "and", "port", "number", ".", "Returns", "an", "error", "if", "things", "go", "wron...
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L82-L95
152,061
xyproto/permissions2
userstate.go
HasUser
func (state *UserState) HasUser(username string) bool { val, err := state.usernames.Has(username) if err != nil { // This happened at concurrent connections before introducing the connection pool panic("ERROR: Lost connection to Redis?") } return val }
go
func (state *UserState) HasUser(username string) bool { val, err := state.usernames.Has(username) if err != nil { // This happened at concurrent connections before introducing the connection pool panic("ERROR: Lost connection to Redis?") } return val }
[ "func", "(", "state", "*", "UserState", ")", "HasUser", "(", "username", "string", ")", "bool", "{", "val", ",", "err", ":=", "state", ".", "usernames", ".", "Has", "(", "username", ")", "\n", "if", "err", "!=", "nil", "{", "// This happened at concurren...
// HasUser checks if the given username exists.
[ "HasUser", "checks", "if", "the", "given", "username", "exists", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L259-L266
152,062
xyproto/permissions2
userstate.go
HasUser2
func (state *UserState) HasUser2(username string) (bool, error) { val, err := state.usernames.Has(username) if err != nil { // This happened at concurrent connections before introducing the connection pool return false, errors.New("Lost connection to Redis?") } return val, nil }
go
func (state *UserState) HasUser2(username string) (bool, error) { val, err := state.usernames.Has(username) if err != nil { // This happened at concurrent connections before introducing the connection pool return false, errors.New("Lost connection to Redis?") } return val, nil }
[ "func", "(", "state", "*", "UserState", ")", "HasUser2", "(", "username", "string", ")", "(", "bool", ",", "error", ")", "{", "val", ",", "err", ":=", "state", ".", "usernames", ".", "Has", "(", "username", ")", "\n", "if", "err", "!=", "nil", "{",...
// HasUser2 checks if the given username exists.
[ "HasUser2", "checks", "if", "the", "given", "username", "exists", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L269-L276
152,063
xyproto/permissions2
userstate.go
BooleanField
func (state *UserState) BooleanField(username, fieldname string) bool { hasUser := state.HasUser(username) if !hasUser { return false } value, err := state.users.Get(username, fieldname) if err != nil { return false } return value == "true" }
go
func (state *UserState) BooleanField(username, fieldname string) bool { hasUser := state.HasUser(username) if !hasUser { return false } value, err := state.users.Get(username, fieldname) if err != nil { return false } return value == "true" }
[ "func", "(", "state", "*", "UserState", ")", "BooleanField", "(", "username", ",", "fieldname", "string", ")", "bool", "{", "hasUser", ":=", "state", ".", "HasUser", "(", "username", ")", "\n", "if", "!", "hasUser", "{", "return", "false", "\n", "}", "...
// BooleanField returns the boolean value for a given username and field name. // If the user or field is missing, false will be returned. // Useful for states where it makes sense that the returned value is not true // unless everything is in order.
[ "BooleanField", "returns", "the", "boolean", "value", "for", "a", "given", "username", "and", "field", "name", ".", "If", "the", "user", "or", "field", "is", "missing", "false", "will", "be", "returned", ".", "Useful", "for", "states", "where", "it", "make...
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L304-L314
152,064
xyproto/permissions2
userstate.go
SetBooleanField
func (state *UserState) SetBooleanField(username, fieldname string, val bool) { strval := "false" if val { strval = "true" } state.users.Set(username, fieldname, strval) }
go
func (state *UserState) SetBooleanField(username, fieldname string, val bool) { strval := "false" if val { strval = "true" } state.users.Set(username, fieldname, strval) }
[ "func", "(", "state", "*", "UserState", ")", "SetBooleanField", "(", "username", ",", "fieldname", "string", ",", "val", "bool", ")", "{", "strval", ":=", "\"", "\"", "\n", "if", "val", "{", "strval", "=", "\"", "\"", "\n", "}", "\n", "state", ".", ...
// Store a boolean value for the given username and custom fieldname.
[ "Store", "a", "boolean", "value", "for", "the", "given", "username", "and", "custom", "fieldname", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L317-L323
152,065
xyproto/permissions2
userstate.go
IsLoggedIn
func (state *UserState) IsLoggedIn(username string) bool { if !state.HasUser(username) { return false } status, err := state.users.Get(username, "loggedin") if err != nil { // Returns "no" if the status can not be retrieved return false } return status == "true" }
go
func (state *UserState) IsLoggedIn(username string) bool { if !state.HasUser(username) { return false } status, err := state.users.Get(username, "loggedin") if err != nil { // Returns "no" if the status can not be retrieved return false } return status == "true" }
[ "func", "(", "state", "*", "UserState", ")", "IsLoggedIn", "(", "username", "string", ")", "bool", "{", "if", "!", "state", ".", "HasUser", "(", "username", ")", "{", "return", "false", "\n", "}", "\n", "status", ",", "err", ":=", "state", ".", "user...
// IsLoggedIn checks if the given username is logged in.
[ "IsLoggedIn", "checks", "if", "the", "given", "username", "is", "logged", "in", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L331-L341
152,066
xyproto/permissions2
userstate.go
AdminRights
func (state *UserState) AdminRights(req *http.Request) bool { username, err := state.UsernameCookie(req) if err != nil { return false } return state.IsLoggedIn(username) && state.IsAdmin(username) }
go
func (state *UserState) AdminRights(req *http.Request) bool { username, err := state.UsernameCookie(req) if err != nil { return false } return state.IsLoggedIn(username) && state.IsAdmin(username) }
[ "func", "(", "state", "*", "UserState", ")", "AdminRights", "(", "req", "*", "http", ".", "Request", ")", "bool", "{", "username", ",", "err", ":=", "state", ".", "UsernameCookie", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fals...
// AdminRights checks if the current user is logged in and has administrator rights.
[ "AdminRights", "checks", "if", "the", "current", "user", "is", "logged", "in", "and", "has", "administrator", "rights", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L344-L350
152,067
xyproto/permissions2
userstate.go
Email
func (state *UserState) Email(username string) (string, error) { return state.users.Get(username, "email") }
go
func (state *UserState) Email(username string) (string, error) { return state.users.Get(username, "email") }
[ "func", "(", "state", "*", "UserState", ")", "Email", "(", "username", "string", ")", "(", "string", ",", "error", ")", "{", "return", "state", ".", "users", ".", "Get", "(", "username", ",", "\"", "\"", ")", "\n", "}" ]
// Email returns the email address for the given username.
[ "Email", "returns", "the", "email", "address", "for", "the", "given", "username", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L424-L426
152,068
xyproto/permissions2
userstate.go
PasswordHash
func (state *UserState) PasswordHash(username string) (string, error) { return state.users.Get(username, "password") }
go
func (state *UserState) PasswordHash(username string) (string, error) { return state.users.Get(username, "password") }
[ "func", "(", "state", "*", "UserState", ")", "PasswordHash", "(", "username", "string", ")", "(", "string", ",", "error", ")", "{", "return", "state", ".", "users", ".", "Get", "(", "username", ",", "\"", "\"", ")", "\n", "}" ]
// PasswordHash returns the password hash for the given username.
[ "PasswordHash", "returns", "the", "password", "hash", "for", "the", "given", "username", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L429-L431
152,069
xyproto/permissions2
userstate.go
ConfirmationCode
func (state *UserState) ConfirmationCode(username string) (string, error) { return state.users.Get(username, "confirmationCode") }
go
func (state *UserState) ConfirmationCode(username string) (string, error) { return state.users.Get(username, "confirmationCode") }
[ "func", "(", "state", "*", "UserState", ")", "ConfirmationCode", "(", "username", "string", ")", "(", "string", ",", "error", ")", "{", "return", "state", ".", "users", ".", "Get", "(", "username", ",", "\"", "\"", ")", "\n", "}" ]
// ConfirmationCode gets the confirmation code for a specific user.
[ "ConfirmationCode", "gets", "the", "confirmation", "code", "for", "a", "specific", "user", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L439-L441
152,070
xyproto/permissions2
userstate.go
AddUnconfirmed
func (state *UserState) AddUnconfirmed(username, confirmationCode string) { state.unconfirmed.Add(username) state.users.Set(username, "confirmationCode", confirmationCode) }
go
func (state *UserState) AddUnconfirmed(username, confirmationCode string) { state.unconfirmed.Add(username) state.users.Set(username, "confirmationCode", confirmationCode) }
[ "func", "(", "state", "*", "UserState", ")", "AddUnconfirmed", "(", "username", ",", "confirmationCode", "string", ")", "{", "state", ".", "unconfirmed", ".", "Add", "(", "username", ")", "\n", "state", ".", "users", ".", "Set", "(", "username", ",", "\"...
// AddUnconfirmed adds a user that is registered but not confirmed.
[ "AddUnconfirmed", "adds", "a", "user", "that", "is", "registered", "but", "not", "confirmed", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L449-L452
152,071
xyproto/permissions2
userstate.go
RemoveUnconfirmed
func (state *UserState) RemoveUnconfirmed(username string) { state.unconfirmed.Del(username) state.users.DelKey(username, "confirmationCode") }
go
func (state *UserState) RemoveUnconfirmed(username string) { state.unconfirmed.Del(username) state.users.DelKey(username, "confirmationCode") }
[ "func", "(", "state", "*", "UserState", ")", "RemoveUnconfirmed", "(", "username", "string", ")", "{", "state", ".", "unconfirmed", ".", "Del", "(", "username", ")", "\n", "state", ".", "users", ".", "DelKey", "(", "username", ",", "\"", "\"", ")", "\n...
// RemoveUnconfirmed removes a user that is registered but not confirmed.
[ "RemoveUnconfirmed", "removes", "a", "user", "that", "is", "registered", "but", "not", "confirmed", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L455-L458
152,072
xyproto/permissions2
userstate.go
RemoveUser
func (state *UserState) RemoveUser(username string) { state.usernames.Del(username) // Remove additional data as well // TODO: Ideally, remove all keys belonging to the user. state.users.DelKey(username, "loggedin") }
go
func (state *UserState) RemoveUser(username string) { state.usernames.Del(username) // Remove additional data as well // TODO: Ideally, remove all keys belonging to the user. state.users.DelKey(username, "loggedin") }
[ "func", "(", "state", "*", "UserState", ")", "RemoveUser", "(", "username", "string", ")", "{", "state", ".", "usernames", ".", "Del", "(", "username", ")", "\n", "// Remove additional data as well", "// TODO: Ideally, remove all keys belonging to the user.", "state", ...
// RemoveUser removes user and login status.
[ "RemoveUser", "removes", "user", "and", "login", "status", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L466-L471
152,073
xyproto/permissions2
userstate.go
SetToken
func (state *UserState) SetToken(username, token string, expire time.Duration) { state.users.SetExpire(username, "token", token, expire) }
go
func (state *UserState) SetToken(username, token string, expire time.Duration) { state.users.SetExpire(username, "token", token, expire) }
[ "func", "(", "state", "*", "UserState", ")", "SetToken", "(", "username", ",", "token", "string", ",", "expire", "time", ".", "Duration", ")", "{", "state", ".", "users", ".", "SetExpire", "(", "username", ",", "\"", "\"", ",", "token", ",", "expire", ...
// SetToken sets a token for a user, for a given expiry time
[ "SetToken", "sets", "a", "token", "for", "a", "user", "for", "a", "given", "expiry", "time" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L484-L486
152,074
xyproto/permissions2
userstate.go
GetToken
func (state *UserState) GetToken(username string) (string, error) { return state.users.Get(username, "token") }
go
func (state *UserState) GetToken(username string) (string, error) { return state.users.Get(username, "token") }
[ "func", "(", "state", "*", "UserState", ")", "GetToken", "(", "username", "string", ")", "(", "string", ",", "error", ")", "{", "return", "state", ".", "users", ".", "Get", "(", "username", ",", "\"", "\"", ")", "\n", "}" ]
// GetToken retrieves the token for a user
[ "GetToken", "retrieves", "the", "token", "for", "a", "user" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L489-L491
152,075
xyproto/permissions2
userstate.go
SetPassword
func (state *UserState) SetPassword(username, password string) { state.users.Set(username, "password", state.HashPassword(username, password)) }
go
func (state *UserState) SetPassword(username, password string) { state.users.Set(username, "password", state.HashPassword(username, password)) }
[ "func", "(", "state", "*", "UserState", ")", "SetPassword", "(", "username", ",", "password", "string", ")", "{", "state", ".", "users", ".", "Set", "(", "username", ",", "\"", "\"", ",", "state", ".", "HashPassword", "(", "username", ",", "password", ...
// SetPassword sets the password for a user. The given password string will be hashed. // No validation or check of the given password is performed.
[ "SetPassword", "sets", "the", "password", "for", "a", "user", ".", "The", "given", "password", "string", "will", "be", "hashed", ".", "No", "validation", "or", "check", "of", "the", "given", "password", "is", "performed", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L500-L502
152,076
xyproto/permissions2
userstate.go
AddUser
func (state *UserState) AddUser(username, password, email string) { passwordHash := state.HashPassword(username, password) state.addUserUnchecked(username, passwordHash, email) }
go
func (state *UserState) AddUser(username, password, email string) { passwordHash := state.HashPassword(username, password) state.addUserUnchecked(username, passwordHash, email) }
[ "func", "(", "state", "*", "UserState", ")", "AddUser", "(", "username", ",", "password", ",", "email", "string", ")", "{", "passwordHash", ":=", "state", ".", "HashPassword", "(", "username", ",", "password", ")", "\n", "state", ".", "addUserUnchecked", "...
// Creates a user and hashes the password, does not check for rights. // The given data must be valid.
[ "Creates", "a", "user", "and", "hashes", "the", "password", "does", "not", "check", "for", "rights", ".", "The", "given", "data", "must", "be", "valid", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L522-L525
152,077
xyproto/permissions2
userstate.go
Login
func (state *UserState) Login(w http.ResponseWriter, username string) error { state.SetLoggedIn(username) return state.SetUsernameCookie(w, username) }
go
func (state *UserState) Login(w http.ResponseWriter, username string) error { state.SetLoggedIn(username) return state.SetUsernameCookie(w, username) }
[ "func", "(", "state", "*", "UserState", ")", "Login", "(", "w", "http", ".", "ResponseWriter", ",", "username", "string", ")", "error", "{", "state", ".", "SetLoggedIn", "(", "username", ")", "\n", "return", "state", ".", "SetUsernameCookie", "(", "w", "...
// Convenience function for logging a user in and storing the username in a cookie. // Returns an error if the cookie could not be set.
[ "Convenience", "function", "for", "logging", "a", "user", "in", "and", "storing", "the", "username", "in", "a", "cookie", ".", "Returns", "an", "error", "if", "the", "cookie", "could", "not", "be", "set", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L539-L542
152,078
xyproto/permissions2
userstate.go
CorrectPassword
func (state *UserState) CorrectPassword(username, password string) bool { if !state.HasUser(username) { return false } // Retrieve the stored password hash hash := state.storedHash(username) if len(hash) == 0 { return false } // Check the password with the right password algorithm switch state.passwordAlgorithm { case "sha256": return correctSha256(hash, state.cookieSecret, username, password) case "bcrypt": return correctBcrypt(hash, password) case "bcrypt+": // for backwards compatibility with sha256 if isSha256(hash) && correctSha256(hash, state.cookieSecret, username, password) { return true } return correctBcrypt(hash, password) } return false }
go
func (state *UserState) CorrectPassword(username, password string) bool { if !state.HasUser(username) { return false } // Retrieve the stored password hash hash := state.storedHash(username) if len(hash) == 0 { return false } // Check the password with the right password algorithm switch state.passwordAlgorithm { case "sha256": return correctSha256(hash, state.cookieSecret, username, password) case "bcrypt": return correctBcrypt(hash, password) case "bcrypt+": // for backwards compatibility with sha256 if isSha256(hash) && correctSha256(hash, state.cookieSecret, username, password) { return true } return correctBcrypt(hash, password) } return false }
[ "func", "(", "state", "*", "UserState", ")", "CorrectPassword", "(", "username", ",", "password", "string", ")", "bool", "{", "if", "!", "state", ".", "HasUser", "(", "username", ")", "{", "return", "false", "\n", "}", "\n\n", "// Retrieve the stored passwor...
// CorrectPassword checks if a password is correct. username is needed because it is part of the hash.
[ "CorrectPassword", "checks", "if", "a", "password", "is", "correct", ".", "username", "is", "needed", "because", "it", "is", "part", "of", "the", "hash", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L629-L654
152,079
xyproto/permissions2
userstate.go
AlreadyHasConfirmationCode
func (state *UserState) AlreadyHasConfirmationCode(confirmationCode string) bool { unconfirmedUsernames, err := state.AllUnconfirmedUsernames() if err != nil { return false } for _, aUsername := range unconfirmedUsernames { aConfirmationCode, err := state.ConfirmationCode(aUsername) if err != nil { // If the confirmation code can not be found, that's okay too return false } if confirmationCode == aConfirmationCode { // Found it return true } } return false }
go
func (state *UserState) AlreadyHasConfirmationCode(confirmationCode string) bool { unconfirmedUsernames, err := state.AllUnconfirmedUsernames() if err != nil { return false } for _, aUsername := range unconfirmedUsernames { aConfirmationCode, err := state.ConfirmationCode(aUsername) if err != nil { // If the confirmation code can not be found, that's okay too return false } if confirmationCode == aConfirmationCode { // Found it return true } } return false }
[ "func", "(", "state", "*", "UserState", ")", "AlreadyHasConfirmationCode", "(", "confirmationCode", "string", ")", "bool", "{", "unconfirmedUsernames", ",", "err", ":=", "state", ".", "AllUnconfirmedUsernames", "(", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// AlreadyHasConfirmationCode runs through all confirmation codes of all unconfirmed // users and checks if this confirmationCode is already in use.
[ "AlreadyHasConfirmationCode", "runs", "through", "all", "confirmation", "codes", "of", "all", "unconfirmed", "users", "and", "checks", "if", "this", "confirmationCode", "is", "already", "in", "use", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L658-L675
152,080
xyproto/permissions2
userstate.go
Confirm
func (state *UserState) Confirm(username string) { // Remove from the list of unconfirmed usernames state.RemoveUnconfirmed(username) // Mark user as confirmed state.MarkConfirmed(username) }
go
func (state *UserState) Confirm(username string) { // Remove from the list of unconfirmed usernames state.RemoveUnconfirmed(username) // Mark user as confirmed state.MarkConfirmed(username) }
[ "func", "(", "state", "*", "UserState", ")", "Confirm", "(", "username", "string", ")", "{", "// Remove from the list of unconfirmed usernames", "state", ".", "RemoveUnconfirmed", "(", "username", ")", "\n\n", "// Mark user as confirmed", "state", ".", "MarkConfirmed", ...
// Confirm removes the username from the list of unconfirmed users and mark the user as confirmed.
[ "Confirm", "removes", "the", "username", "from", "the", "list", "of", "unconfirmed", "users", "and", "mark", "the", "user", "as", "confirmed", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L712-L718
152,081
xyproto/permissions2
userstate.go
Creator
func (state *UserState) Creator() pinterface.ICreator { return simpleredis.NewCreator(state.pool, state.dbindex) }
go
func (state *UserState) Creator() pinterface.ICreator { return simpleredis.NewCreator(state.pool, state.dbindex) }
[ "func", "(", "state", "*", "UserState", ")", "Creator", "(", ")", "pinterface", ".", "ICreator", "{", "return", "simpleredis", ".", "NewCreator", "(", "state", ".", "pool", ",", "state", ".", "dbindex", ")", "\n", "}" ]
// Creator returns a struct for creating data structures with
[ "Creator", "returns", "a", "struct", "for", "creating", "data", "structures", "with" ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L773-L775
152,082
xyproto/permissions2
userstate.go
Properties
func (state *UserState) Properties(username string) []string { props, err := state.users.Keys(username) if err != nil { return []string{} } return props }
go
func (state *UserState) Properties(username string) []string { props, err := state.users.Keys(username) if err != nil { return []string{} } return props }
[ "func", "(", "state", "*", "UserState", ")", "Properties", "(", "username", "string", ")", "[", "]", "string", "{", "props", ",", "err", ":=", "state", ".", "users", ".", "Keys", "(", "username", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Properties returns a list of user properties. // Returns an empty list if the user has no properties, or if there are errors.
[ "Properties", "returns", "a", "list", "of", "user", "properties", ".", "Returns", "an", "empty", "list", "if", "the", "user", "has", "no", "properties", "or", "if", "there", "are", "errors", "." ]
f47b0751729e767ee4c9dcc64a00e4720b95c8e0
https://github.com/xyproto/permissions2/blob/f47b0751729e767ee4c9dcc64a00e4720b95c8e0/userstate.go#L779-L785
152,083
denverdino/aliyungo
cms/client.go
NewCMSClient
func NewCMSClient(accessKeyId, accessKeySecret string) *CMSClient { endpoint := os.Getenv("CMS_ENDPOINT") if endpoint == "" { endpoint = CMSDefaultEndpoint } return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret) }
go
func NewCMSClient(accessKeyId, accessKeySecret string) *CMSClient { endpoint := os.Getenv("CMS_ENDPOINT") if endpoint == "" { endpoint = CMSDefaultEndpoint } return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret) }
[ "func", "NewCMSClient", "(", "accessKeyId", ",", "accessKeySecret", "string", ")", "*", "CMSClient", "{", "endpoint", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "endpoint", "==", "\"", "\"", "{", "endpoint", "=", "CMSDefaultEndpoint", "\n...
// NewClient creates a new instance of CMS client
[ "NewClient", "creates", "a", "new", "instance", "of", "CMS", "client" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/cms/client.go#L77-L83
152,084
denverdino/aliyungo
kms/client.go
NewClient
func NewClient(accessKeyId, accessKeySecret string) *Client { endpoint := os.Getenv("KMS_ENDPOINT") if endpoint == "" { endpoint = KMSDefaultEndpoint } return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret) }
go
func NewClient(accessKeyId, accessKeySecret string) *Client { endpoint := os.Getenv("KMS_ENDPOINT") if endpoint == "" { endpoint = KMSDefaultEndpoint } return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret) }
[ "func", "NewClient", "(", "accessKeyId", ",", "accessKeySecret", "string", ")", "*", "Client", "{", "endpoint", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "endpoint", "==", "\"", "\"", "{", "endpoint", "=", "KMSDefaultEndpoint", "\n", "...
// NewClient creates a new instance of KMS client
[ "NewClient", "creates", "a", "new", "instance", "of", "KMS", "client" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/kms/client.go#L21-L27
152,085
denverdino/aliyungo
ess/configuration.go
DeactivateScalingConfiguration
func (client *Client) DeactivateScalingConfiguration(args *DeactivateScalingConfigurationArgs) (resp *DeactivateScalingConfigurationResponse, err error) { response := DeactivateScalingConfigurationResponse{} err = client.InvokeByFlattenMethod("DeactivateScalingConfiguration", args, &response) if err != nil { return nil, err } return &response, nil }
go
func (client *Client) DeactivateScalingConfiguration(args *DeactivateScalingConfigurationArgs) (resp *DeactivateScalingConfigurationResponse, err error) { response := DeactivateScalingConfigurationResponse{} err = client.InvokeByFlattenMethod("DeactivateScalingConfiguration", args, &response) if err != nil { return nil, err } return &response, nil }
[ "func", "(", "client", "*", "Client", ")", "DeactivateScalingConfiguration", "(", "args", "*", "DeactivateScalingConfigurationArgs", ")", "(", "resp", "*", "DeactivateScalingConfigurationResponse", ",", "err", "error", ")", "{", "response", ":=", "DeactivateScalingConfi...
// DeactivateScalingConfiguration deactivate scaling configuration //
[ "DeactivateScalingConfiguration", "deactivate", "scaling", "configuration" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ess/configuration.go#L161-L169
152,086
denverdino/aliyungo
slb/servers.go
SetBackendServers
func (client *Client) SetBackendServers(loadBalancerId string, backendServers []BackendServerType) (result []BackendServerType, err error) { bytes, _ := json.Marshal(backendServers) args := &SetBackendServersArgs{ LoadBalancerId: loadBalancerId, BackendServers: string(bytes), } response := &SetBackendServersResponse{} err = client.Invoke("SetBackendServers", args, response) if err != nil { return nil, err } return response.BackendServers.BackendServer, err }
go
func (client *Client) SetBackendServers(loadBalancerId string, backendServers []BackendServerType) (result []BackendServerType, err error) { bytes, _ := json.Marshal(backendServers) args := &SetBackendServersArgs{ LoadBalancerId: loadBalancerId, BackendServers: string(bytes), } response := &SetBackendServersResponse{} err = client.Invoke("SetBackendServers", args, response) if err != nil { return nil, err } return response.BackendServers.BackendServer, err }
[ "func", "(", "client", "*", "Client", ")", "SetBackendServers", "(", "loadBalancerId", "string", ",", "backendServers", "[", "]", "BackendServerType", ")", "(", "result", "[", "]", "BackendServerType", ",", "err", "error", ")", "{", "bytes", ",", "_", ":=", ...
// SetBackendServers set weight of backend servers
[ "SetBackendServers", "set", "weight", "of", "backend", "servers" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/slb/servers.go#L27-L41
152,087
denverdino/aliyungo
util/encoding.go
ConvertToQueryValues
func ConvertToQueryValues(ifc interface{}) url.Values { values := url.Values{} SetQueryValues(ifc, &values) return values }
go
func ConvertToQueryValues(ifc interface{}) url.Values { values := url.Values{} SetQueryValues(ifc, &values) return values }
[ "func", "ConvertToQueryValues", "(", "ifc", "interface", "{", "}", ")", "url", ".", "Values", "{", "values", ":=", "url", ".", "Values", "{", "}", "\n", "SetQueryValues", "(", "ifc", ",", "&", "values", ")", "\n", "return", "values", "\n", "}" ]
//ConvertToQueryValues converts the struct to url.Values
[ "ConvertToQueryValues", "converts", "the", "struct", "to", "url", ".", "Values" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/util/encoding.go#L31-L35
152,088
denverdino/aliyungo
ecs/router_interface.go
WaitForRouterInterfaceAsyn
func (client *Client) WaitForRouterInterfaceAsyn(regionId common.Region, interfaceId string, status InterfaceStatus, timeout int) error { if timeout <= 0 { timeout = InstanceDefaultTimeout } for { interfaces, err := client.DescribeRouterInterfaces(&DescribeRouterInterfacesArgs{ RegionId: regionId, Filter: []Filter{{Key: "RouterInterfaceId", Value: []string{interfaceId}}}, }) if err != nil { return err } else if interfaces != nil && InterfaceStatus(interfaces.RouterInterfaceSet.RouterInterfaceType[0].Status) == status { //TODO break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
go
func (client *Client) WaitForRouterInterfaceAsyn(regionId common.Region, interfaceId string, status InterfaceStatus, timeout int) error { if timeout <= 0 { timeout = InstanceDefaultTimeout } for { interfaces, err := client.DescribeRouterInterfaces(&DescribeRouterInterfacesArgs{ RegionId: regionId, Filter: []Filter{{Key: "RouterInterfaceId", Value: []string{interfaceId}}}, }) if err != nil { return err } else if interfaces != nil && InterfaceStatus(interfaces.RouterInterfaceSet.RouterInterfaceType[0].Status) == status { //TODO break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
[ "func", "(", "client", "*", "Client", ")", "WaitForRouterInterfaceAsyn", "(", "regionId", "common", ".", "Region", ",", "interfaceId", "string", ",", "status", "InterfaceStatus", ",", "timeout", "int", ")", "error", "{", "if", "timeout", "<=", "0", "{", "tim...
// WaitForRouterInterface waits for router interface to given status
[ "WaitForRouterInterface", "waits", "for", "router", "interface", "to", "given", "status" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ecs/router_interface.go#L234-L257
152,089
denverdino/aliyungo
slb/zones.go
DescribeZones
func (client *Client) DescribeZones(regionId common.Region) (zones []ZoneType, err error) { response, err := client.DescribeZonesWithRaw(regionId) if err == nil { return response.Zones.Zone, nil } return []ZoneType{}, err }
go
func (client *Client) DescribeZones(regionId common.Region) (zones []ZoneType, err error) { response, err := client.DescribeZonesWithRaw(regionId) if err == nil { return response.Zones.Zone, nil } return []ZoneType{}, err }
[ "func", "(", "client", "*", "Client", ")", "DescribeZones", "(", "regionId", "common", ".", "Region", ")", "(", "zones", "[", "]", "ZoneType", ",", "err", "error", ")", "{", "response", ",", "err", ":=", "client", ".", "DescribeZonesWithRaw", "(", "regio...
// DescribeZones describes zones
[ "DescribeZones", "describes", "zones" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/slb/zones.go#L29-L36
152,090
denverdino/aliyungo
rds/instances.go
CreateOrder
func (client *Client) CreateOrder(args *CreateOrderArgs) (resp CreateOrderResponse, err error) { response := CreateOrderResponse{} err = client.Invoke("CreateOrder", args, &response) return response, err }
go
func (client *Client) CreateOrder(args *CreateOrderArgs) (resp CreateOrderResponse, err error) { response := CreateOrderResponse{} err = client.Invoke("CreateOrder", args, &response) return response, err }
[ "func", "(", "client", "*", "Client", ")", "CreateOrder", "(", "args", "*", "CreateOrderArgs", ")", "(", "resp", "CreateOrderResponse", ",", "err", "error", ")", "{", "response", ":=", "CreateOrderResponse", "{", "}", "\n", "err", "=", "client", ".", "Invo...
// CreateOrder create db instance order
[ "CreateOrder", "create", "db", "instance", "order" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/rds/instances.go#L208-L212
152,091
denverdino/aliyungo
cs/clusters.go
ResizeKubernetes
func (client *Client) ResizeKubernetes(clusterID string, args *KubernetesCreationArgs) error { return client.Invoke("", http.MethodPut, "/clusters/"+clusterID, nil, args, nil) }
go
func (client *Client) ResizeKubernetes(clusterID string, args *KubernetesCreationArgs) error { return client.Invoke("", http.MethodPut, "/clusters/"+clusterID, nil, args, nil) }
[ "func", "(", "client", "*", "Client", ")", "ResizeKubernetes", "(", "clusterID", "string", ",", "args", "*", "KubernetesCreationArgs", ")", "error", "{", "return", "client", ".", "Invoke", "(", "\"", "\"", ",", "http", ".", "MethodPut", ",", "\"", "\"", ...
// deprecated // use ResizeKubernetesCluster instead
[ "deprecated", "use", "ResizeKubernetesCluster", "instead" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/cs/clusters.go#L410-L412
152,092
denverdino/aliyungo
cs/clusters.go
WaitForClusterAsyn
func (client *Client) WaitForClusterAsyn(clusterId string, status ClusterState, timeout int) error { if timeout <= 0 { timeout = ClusterDefaultTimeout } // Sleep 20 second to check cluster creating or failed sleep := math.Min(float64(timeout), float64(DefaultPreCheckSleepTime)) time.Sleep(time.Duration(sleep) * time.Second) cluster, err := client.DescribeCluster(clusterId) if err != nil { return err } else if cluster.State == Failed { return fmt.Errorf("Waitting for cluster %s %s failed. Looking the specified reason in the web console.", clusterId, status) } else if cluster.State == status { //TODO return nil } // Create or Reset cluster usually cost at least 4 min, so there will sleep a long time before polling sleep = math.Min(float64(timeout), float64(DefaultPreSleepTime)) time.Sleep(time.Duration(sleep) * time.Second) for { cluster, err := client.DescribeCluster(clusterId) if err != nil { return err } else if cluster.State == Failed { return fmt.Errorf("Waitting for cluster %s %s failed. Looking the specified reason in the web console.", clusterId, status) } else if cluster.State == status { //TODO break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
go
func (client *Client) WaitForClusterAsyn(clusterId string, status ClusterState, timeout int) error { if timeout <= 0 { timeout = ClusterDefaultTimeout } // Sleep 20 second to check cluster creating or failed sleep := math.Min(float64(timeout), float64(DefaultPreCheckSleepTime)) time.Sleep(time.Duration(sleep) * time.Second) cluster, err := client.DescribeCluster(clusterId) if err != nil { return err } else if cluster.State == Failed { return fmt.Errorf("Waitting for cluster %s %s failed. Looking the specified reason in the web console.", clusterId, status) } else if cluster.State == status { //TODO return nil } // Create or Reset cluster usually cost at least 4 min, so there will sleep a long time before polling sleep = math.Min(float64(timeout), float64(DefaultPreSleepTime)) time.Sleep(time.Duration(sleep) * time.Second) for { cluster, err := client.DescribeCluster(clusterId) if err != nil { return err } else if cluster.State == Failed { return fmt.Errorf("Waitting for cluster %s %s failed. Looking the specified reason in the web console.", clusterId, status) } else if cluster.State == status { //TODO break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
[ "func", "(", "client", "*", "Client", ")", "WaitForClusterAsyn", "(", "clusterId", "string", ",", "status", "ClusterState", ",", "timeout", "int", ")", "error", "{", "if", "timeout", "<=", "0", "{", "timeout", "=", "ClusterDefaultTimeout", "\n", "}", "\n\n",...
// WaitForCluster waits for instance to given status // when instance.NotFound wait until timeout
[ "WaitForCluster", "waits", "for", "instance", "to", "given", "status", "when", "instance", ".", "NotFound", "wait", "until", "timeout" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/cs/clusters.go#L513-L553
152,093
denverdino/aliyungo
ess/group.go
WaitForScalingGroup
func (client *Client) WaitForScalingGroup(regionId common.Region, groupId string, status LifecycleState, timeout int) error { if timeout <= 0 { timeout = DefaultWaitTimeout } for { sgs, _, err := client.DescribeScalingGroups(&DescribeScalingGroupsArgs{ RegionId: regionId, ScalingGroupId: []string{groupId}, }) if err != nil { return err } if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } timeout = timeout - DefaultWaitForInterval time.Sleep(DefaultWaitForInterval * time.Second) if len(sgs) < 1 { return common.GetClientErrorFromString("Not found") } if sgs[0].LifecycleState == status { break } } return nil }
go
func (client *Client) WaitForScalingGroup(regionId common.Region, groupId string, status LifecycleState, timeout int) error { if timeout <= 0 { timeout = DefaultWaitTimeout } for { sgs, _, err := client.DescribeScalingGroups(&DescribeScalingGroupsArgs{ RegionId: regionId, ScalingGroupId: []string{groupId}, }) if err != nil { return err } if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } timeout = timeout - DefaultWaitForInterval time.Sleep(DefaultWaitForInterval * time.Second) if len(sgs) < 1 { return common.GetClientErrorFromString("Not found") } if sgs[0].LifecycleState == status { break } } return nil }
[ "func", "(", "client", "*", "Client", ")", "WaitForScalingGroup", "(", "regionId", "common", ".", "Region", ",", "groupId", "string", ",", "status", "LifecycleState", ",", "timeout", "int", ")", "error", "{", "if", "timeout", "<=", "0", "{", "timeout", "="...
// WaitForScalingGroup waits for group to given status
[ "WaitForScalingGroup", "waits", "for", "group", "to", "given", "status" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ess/group.go#L311-L340
152,094
denverdino/aliyungo
ecs/images.go
WaitForImageReady
func (client *Client) WaitForImageReady(regionId common.Region, imageId string, timeout int) error { if timeout <= 0 { timeout = ImageDefaultTimeout } for { args := DescribeImagesArgs{ RegionId: regionId, ImageId: imageId, Status: ImageStatusCreating, } images, _, err := client.DescribeImages(&args) if err != nil { return err } if images == nil || len(images) == 0 { args.Status = ImageStatusAvailable images, _, er := client.DescribeImages(&args) if er == nil && len(images) == 1 { break } else { return common.GetClientErrorFromString("Not found") } } if images[0].Progress == "100%" { break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
go
func (client *Client) WaitForImageReady(regionId common.Region, imageId string, timeout int) error { if timeout <= 0 { timeout = ImageDefaultTimeout } for { args := DescribeImagesArgs{ RegionId: regionId, ImageId: imageId, Status: ImageStatusCreating, } images, _, err := client.DescribeImages(&args) if err != nil { return err } if images == nil || len(images) == 0 { args.Status = ImageStatusAvailable images, _, er := client.DescribeImages(&args) if er == nil && len(images) == 1 { break } else { return common.GetClientErrorFromString("Not found") } } if images[0].Progress == "100%" { break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
[ "func", "(", "client", "*", "Client", ")", "WaitForImageReady", "(", "regionId", "common", ".", "Region", ",", "imageId", "string", ",", "timeout", "int", ")", "error", "{", "if", "timeout", "<=", "0", "{", "timeout", "=", "ImageDefaultTimeout", "\n", "}",...
//Wait Image ready
[ "Wait", "Image", "ready" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ecs/images.go#L301-L335
152,095
denverdino/aliyungo
oss/regions.go
GetInternetEndpoint
func (r Region) GetInternetEndpoint(bucket string, secure bool) string { protocol := getProtocol(secure) if bucket == "" { return fmt.Sprintf("%s://oss.aliyuncs.com", protocol) } return fmt.Sprintf("%s://%s.%s.aliyuncs.com", protocol, bucket, string(r)) }
go
func (r Region) GetInternetEndpoint(bucket string, secure bool) string { protocol := getProtocol(secure) if bucket == "" { return fmt.Sprintf("%s://oss.aliyuncs.com", protocol) } return fmt.Sprintf("%s://%s.%s.aliyuncs.com", protocol, bucket, string(r)) }
[ "func", "(", "r", "Region", ")", "GetInternetEndpoint", "(", "bucket", "string", ",", "secure", "bool", ")", "string", "{", "protocol", ":=", "getProtocol", "(", "secure", ")", "\n", "if", "bucket", "==", "\"", "\"", "{", "return", "fmt", ".", "Sprintf",...
// GetInternetEndpoint returns internet endpoint of region
[ "GetInternetEndpoint", "returns", "internet", "endpoint", "of", "region" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/regions.go#L52-L58
152,096
denverdino/aliyungo
ecs/snapshots.go
WaitForSnapShotReady
func (client *Client) WaitForSnapShotReady(regionId common.Region, snapshotId string, timeout int) error { if timeout <= 0 { timeout = SnapshotDefaultTimeout } for { args := DescribeSnapshotsArgs{ RegionId: regionId, SnapshotIds: []string{snapshotId}, } snapshots, _, err := client.DescribeSnapshots(&args) if err != nil { return err } if snapshots == nil || len(snapshots) == 0 { return common.GetClientErrorFromString("Not found") } if snapshots[0].Progress == "100%" { break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
go
func (client *Client) WaitForSnapShotReady(regionId common.Region, snapshotId string, timeout int) error { if timeout <= 0 { timeout = SnapshotDefaultTimeout } for { args := DescribeSnapshotsArgs{ RegionId: regionId, SnapshotIds: []string{snapshotId}, } snapshots, _, err := client.DescribeSnapshots(&args) if err != nil { return err } if snapshots == nil || len(snapshots) == 0 { return common.GetClientErrorFromString("Not found") } if snapshots[0].Progress == "100%" { break } timeout = timeout - DefaultWaitForInterval if timeout <= 0 { return common.GetClientErrorFromString("Timeout") } time.Sleep(DefaultWaitForInterval * time.Second) } return nil }
[ "func", "(", "client", "*", "Client", ")", "WaitForSnapShotReady", "(", "regionId", "common", ".", "Region", ",", "snapshotId", "string", ",", "timeout", "int", ")", "error", "{", "if", "timeout", "<=", "0", "{", "timeout", "=", "SnapshotDefaultTimeout", "\n...
// WaitForSnapShotReady waits for snapshot ready
[ "WaitForSnapShotReady", "waits", "for", "snapshot", "ready" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ecs/snapshots.go#L115-L142
152,097
denverdino/aliyungo
sls/client.go
NewClient
func NewClient(region common.Region, internal bool, accessKeyId, accessKeySecret string) *Client { endpoint := os.Getenv("SLS_ENDPOINT") if endpoint == "" { endpoint = SLSDefaultEndpoint } return NewClientWithEndpoint(endpoint, region, internal, accessKeyId, accessKeySecret) }
go
func NewClient(region common.Region, internal bool, accessKeyId, accessKeySecret string) *Client { endpoint := os.Getenv("SLS_ENDPOINT") if endpoint == "" { endpoint = SLSDefaultEndpoint } return NewClientWithEndpoint(endpoint, region, internal, accessKeyId, accessKeySecret) }
[ "func", "NewClient", "(", "region", "common", ".", "Region", ",", "internal", "bool", ",", "accessKeyId", ",", "accessKeySecret", "string", ")", "*", "Client", "{", "endpoint", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "endpoint", "=="...
// NewClient creates a new instance of ECS client
[ "NewClient", "creates", "a", "new", "instance", "of", "ECS", "client" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/sls/client.go#L70-L76
152,098
denverdino/aliyungo
ros/client.go
NewClient
func NewClient(accessKeyId, accessKeySecret string) *Client { return &Client{ AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, endpoint: ROSDefaultEndpoint, Version: ROSAPIVersion, httpClient: &http.Client{}, } }
go
func NewClient(accessKeyId, accessKeySecret string) *Client { return &Client{ AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, endpoint: ROSDefaultEndpoint, Version: ROSAPIVersion, httpClient: &http.Client{}, } }
[ "func", "NewClient", "(", "accessKeyId", ",", "accessKeySecret", "string", ")", "*", "Client", "{", "return", "&", "Client", "{", "AccessKeyId", ":", "accessKeyId", ",", "AccessKeySecret", ":", "accessKeySecret", ",", "endpoint", ":", "ROSDefaultEndpoint", ",", ...
// NewClient creates a new instance of ROS client
[ "NewClient", "creates", "a", "new", "instance", "of", "ROS", "client" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ros/client.go#L43-L51
152,099
denverdino/aliyungo
cdn/auth/sign_url.go
NewURLSigner
func NewURLSigner(authType string, privKey string) *URLSigner { return &URLSigner{ authType: authType, privKey: privKey, } }
go
func NewURLSigner(authType string, privKey string) *URLSigner { return &URLSigner{ authType: authType, privKey: privKey, } }
[ "func", "NewURLSigner", "(", "authType", "string", ",", "privKey", "string", ")", "*", "URLSigner", "{", "return", "&", "URLSigner", "{", "authType", ":", "authType", ",", "privKey", ":", "privKey", ",", "}", "\n", "}" ]
// NewURLSigner returns a new signer object.
[ "NewURLSigner", "returns", "a", "new", "signer", "object", "." ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/cdn/auth/sign_url.go#L19-L24