query
stringlengths
7
3.85k
document
stringlengths
11
430k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
GinLogrus is a logger middleware, which use the logrus replace gin default logger
func GinLogrus() gin.HandlerFunc { return func(c *gin.Context) { start := time.Now() // some evil middlewares modify this values path := c.Request.URL.Path c.Next() end := time.Since(start) status := c.Writer.Status() entry := logrus.WithFields(logrus.Fields{ "path": path, "method": c.Request.Method, "clientIP": c.ClientIP(), "userAgent": c.Request.UserAgent(), "requestID": c.MustGet(RequestIDKey), "status": status, "size": c.Writer.Size(), "latency": fmt.Sprintf("%fms", float64(end.Seconds())*1000.0), }) if len(c.Errors) > 0 { // Append error field if this is an erroneous request. entry.Error(c.Errors.String()) } else { if status > 499 { entry.Error() } else { entry.Info() } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Logrus() echo.MiddlewareFunc {\n\treturn LogrusDefaultConfig(DefaultLoggerConfig)\n}", "func GinLogger(log *logrus.Logger) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\n\t\t// other handler can change c.Path so:\n\t\tpath := c.Request.URL.Path\n\t\tmethod := c.Request.Method\n\t\tstart := time.Now()...
[ "0.7025706", "0.6979332", "0.6601648", "0.6236444", "0.61680114", "0.6146722", "0.602604", "0.5978633", "0.59643364", "0.5946916", "0.59344643", "0.5901862", "0.5896292", "0.5896292", "0.57851714", "0.5780678", "0.5773026", "0.57373214", "0.57046056", "0.5691755", "0.5688423"...
0.75822556
0
NewPage create new page
func (d *Dir) NewPage(f os.FileInfo) (*Page, error) { prs, err := parser.New(f.Name()) if err != nil || strings.HasPrefix(f.Name(), "_") { return nil, errors.New(fmt.Sprintf("Not allowed file format %s\n", f.Name())) } cont, err := ioutil.ReadFile(getPath(d.mdDir, f.Name())) if (err != nil) { return nil, err } title := prs.GetTitle(f.Name()) html := prs.Parse(cont) p := &Page{} p.Title = title p.Seo = &Seo{ Title: "", Description: "", Keywords: "", } p.Body = template.HTML(html) p.Path = getPath(d.htmlDir, getUrl(p.Title) + ".html") p.Url = getPath(d.path, getUrl(p.Title) + ".html") p.Template = d.template return p, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *SimPDF) NewPage(page models.Pages) {\n\ts.Page = page\n\ts.PDF.AddPageFormat(page.ToPDFOrientation(), gofpdf.SizeType{Wd: page.Width, Ht: page.Height})\n}", "func NewPage(ctx *sweetygo.Context) error {\n\tctx.Set(\"title\", \"New\")\n\tctx.Set(\"editor\", true)\n\treturn ctx.Render(200, \"posts/new\")\n...
[ "0.7086286", "0.69852895", "0.6925897", "0.67609227", "0.66914123", "0.65977377", "0.65409267", "0.6484053", "0.6477484", "0.6449281", "0.63723683", "0.63473636", "0.6308704", "0.62883514", "0.60617995", "0.60510904", "0.5933118", "0.5927139", "0.5916846", "0.58892477", "0.58...
0.6275084
14
getUrl returns generated url
func getUrl(title string) string { url := title if title == "README" { url = "index" } return url }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t *Tracker) getURL(r *request) string {\n\treturn baseURL + t.serviceID + r.String()\n}", "func (s Store) GetURL(id string) string {\n\treturn s.get(id)\n}", "func (d dvd) GetURL(req *http.Request, s *site) *url.URL {\n\treturn makeURL(d, req, s, []string{\"name\", d.Name})\n}", "func (session *Session...
[ "0.695418", "0.6780465", "0.67709434", "0.6749998", "0.6744279", "0.67276794", "0.6697484", "0.6657503", "0.66535795", "0.66500205", "0.6645439", "0.66204995", "0.6618371", "0.6612726", "0.6570689", "0.6536291", "0.65258366", "0.6483786", "0.6464578", "0.64532846", "0.6451657...
0.60749775
74
save saving current page to filesystem
func (p *Page) save(d *Dir) error { p.Sidebar = d.sidebar p.Items = d.pages file, err := os.Create(p.Path) if (err != nil) { return err } fmt.Printf("Create new page: %s\n \tby link:%s\n", p.Title, p.Path) return p.render(file) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *Page) save() error {\n\tbody := fmt.Sprintf(\"<!-- Ingredients -->\\n%s\\n<!-- Instructions -->\\n%s\", p.Ingredients, p.Instructions)\n\treturn ioutil.WriteFile(filepath.Join(pagesDir, p.Filename+\".txt\"), []byte(body), 0600)\n}", "func (p *Page) save() error {\n\tfilename := \"./pages/\" + p.Title + ...
[ "0.75267327", "0.7403389", "0.7397416", "0.7375422", "0.7351893", "0.73325723", "0.7299355", "0.72905964", "0.7201987", "0.7189554", "0.7094197", "0.7000149", "0.69070685", "0.67373985", "0.6554937", "0.647469", "0.64519274", "0.6404184", "0.63746774", "0.6366096", "0.6352044...
0.76523435
0
render rendering current page template
func (p *Page) render(f *os.File) error { t, err := template.ParseFiles(p.Template) if (err != nil) { return err } return t.Execute(f, p) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func render(w http.ResponseWriter, context PageContext) {\n\tfuncMap := template.FuncMap{\n\t\t\"title\": strings.Title,\n\t\t\"HumanizeBytes\": HumanizeBytes,\n\t\t\"HumanizeBigBytes\": HumanizeBigBytes,\n\t\t\"CommifyFloat\": CommifyFloat,\n\t\t\"Float2Int\": IntFromFloat64,\n\t\t\"OkToB...
[ "0.7419679", "0.69988775", "0.6976363", "0.6867108", "0.676085", "0.6621656", "0.65539324", "0.65483695", "0.65003127", "0.6480978", "0.6468482", "0.6449129", "0.6338193", "0.6334071", "0.6327223", "0.6316062", "0.6288715", "0.6266251", "0.62608874", "0.6256042", "0.62559956"...
0.6413044
12
public static native int floatToRawIntBits(float value);
func floatToRawIntBits(frame *rtda.Frame) { floatVal := frame.LocalVars().GetFloat(0) frame.OperandStack().PushInt(int32(math.Float32bits(floatVal))) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func JDK_java_lang_Float_floatToRawIntBits(value Float) Int {\n\tbits := math.Float32bits(float32(value))\n\treturn Int(int32(bits))\n}", "func float32bits(f float32) uint32 { return *(*uint32)(unsafe.Pointer(&f)) }", "func floatBits(f float64) uint64 {\n\t// Take f parameter and determine bit pattern.\n\t// T...
[ "0.8932094", "0.73746973", "0.7082981", "0.6395846", "0.6257228", "0.6139659", "0.60942435", "0.6084789", "0.60047704", "0.5823916", "0.5806024", "0.57731223", "0.57533044", "0.5684423", "0.5669247", "0.5609524", "0.5561731", "0.55265313", "0.5512581", "0.54936963", "0.546031...
0.82935
1
Describe writes all the descriptors to the prometheus desc channel.
func (collector *MetricsCollector) Describe(ch chan<- *prometheus.Desc) { for k := range collector.metrics { for idxMColl := range collector.metrics[k] { ch <- collector.metrics[k][idxMColl].metricDesc } } collector.defMetrics.describe(ch) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Collector) Describe(chan<- *prometheus.Desc) {}", "func (c *collector) Describe(ch chan<- *prometheus.Desc) {\n\tfor _, d := range descriptors {\n\t\tch <- d\n\t}\n}", "func (c *filebeatCollector) Describe(ch chan<- *prometheus.Desc) {\n\n\tfor _, metric := range c.metrics {\n\t\tch <- metric.desc\n\t...
[ "0.8205519", "0.81644803", "0.79042935", "0.789001", "0.7877866", "0.7847287", "0.7846724", "0.78357315", "0.78223747", "0.78189427", "0.78070813", "0.7794344", "0.7790456", "0.77866", "0.776235", "0.7761977", "0.77538306", "0.7751365", "0.7747985", "0.7731575", "0.772384", ...
0.7817006
10
Collect update all the descriptors is values
func (collector *MetricsCollector) Collect(ch chan<- prometheus.Metric) { filterMetricsByKind := func(kind string, orgMetrics []constMetric) (filteredMetrics []constMetric) { for _, metric := range orgMetrics { if metric.kind == kind { filteredMetrics = append(filteredMetrics, metric) } } return filteredMetrics } collector.defMetrics.reset() for k := range collector.metrics { counters := filterMetricsByKind(config.KeyMetricTypeCounter, collector.metrics[k]) gauges := filterMetricsByKind(config.KeyMetricTypeGauge, collector.metrics[k]) histograms := filterMetricsByKind(config.KeyMetricTypeHistogram, collector.metrics[k]) collectCounters(counters, collector.defMetrics, ch) collectGauges(gauges, collector.defMetrics, ch) collectHistograms(histograms, collector.defMetrics, ch) collector.cache.Reset() } collector.defMetrics.collectDefaultMetrics(ch) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m MessageDescriptorMap) Updated() (updated []string) {\n\tfor id, descriptor := range m {\n\t\tif descriptor.Updated() {\n\t\t\tupdated = append(updated, id)\n\t\t}\n\t}\n\treturn\n}", "func (c *collector) Describe(ch chan<- *prometheus.Desc) {\n\tfor _, d := range descriptors {\n\t\tch <- d\n\t}\n}", "f...
[ "0.58088684", "0.5562258", "0.55334586", "0.55037814", "0.5347168", "0.53121257", "0.5310797", "0.5289114", "0.5254953", "0.52527744", "0.52251166", "0.52201605", "0.52137506", "0.52137166", "0.5206045", "0.52008325", "0.5198924", "0.5187874", "0.5168878", "0.516446", "0.5129...
0.48819733
68
This implements Stringer interface from package fmt.
func (p Person) String() string { return fmt.Sprintf("%v (%v years)", p.Name, p.Age) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *Name) String() string {\n\tif this.DoubleValue != nil {\n\t\treturn this.Before.String() + strconv.FormatFloat(this.GetDoubleValue(), 'f', -1, 64)\n\t}\n\tif this.IntValue != nil {\n\t\treturn this.Before.String() + strconv.FormatInt(this.GetIntValue(), 10)\n\t}\n\tif this.UintValue != nil {\n\t\tretur...
[ "0.6654755", "0.66311586", "0.65776306", "0.6569977", "0.65669614", "0.65365326", "0.6522435", "0.651368", "0.6511166", "0.64904517", "0.6490063", "0.64900064", "0.647282", "0.64517486", "0.64481103", "0.6431935", "0.643003", "0.64241385", "0.6418602", "0.6406918", "0.6406384...
0.0
-1
/ this is general function collection it's can use in every time you need get offset and limit for paging
func Calcpage(page int)(int,int){ page -= 1 limit := 10 offset := (page * limit) + 1 return offset,limit }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MGOStore) PaginateOffset(limit, offset int64) (int64, error) {\n\tq := m.collection.Find(m.filter)\n\n\trecordCount, _ := q.Count()\n\tc := int64(recordCount)\n\n\tq.Limit(int(limit))\n\tq.Skip(int(offset))\n\treturn c, q.All(m.items)\n}", "func (d *mongoDB) mongoPagination(pagination *crud.Pagination) ...
[ "0.62947685", "0.6278961", "0.6123229", "0.60996085", "0.60073113", "0.59673357", "0.5958331", "0.5937828", "0.5937828", "0.59175867", "0.5915382", "0.5893339", "0.58894", "0.58830416", "0.58767486", "0.5874895", "0.58610237", "0.5832857", "0.5831853", "0.5828642", "0.5751818...
0.6210712
2
String returns the string representation
func (s DescribeUserHierarchyStructureInput) String() string { return awsutil.Prettify(s) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s CreateAlgorithmOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s CreateAlgorithmOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s CreateCanaryOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s Library) String() string {\n\tres := make([]strin...
[ "0.7215058", "0.7215058", "0.72000957", "0.7199919", "0.7177383", "0.7166947", "0.7118059", "0.7087492", "0.70870787", "0.7079275", "0.70782894", "0.7067719", "0.7031721", "0.70269966", "0.7026298", "0.70251423", "0.7021565", "0.70164025", "0.701059", "0.7010184", "0.70022964...
0.0
-1
Validate inspects the fields of the type to determine if they are valid.
func (s *DescribeUserHierarchyStructureInput) Validate() error { invalidParams := aws.ErrInvalidParams{Context: "DescribeUserHierarchyStructureInput"} if s.InstanceId == nil { invalidParams.Add(aws.NewErrParamRequired("InstanceId")) } if s.InstanceId != nil && len(*s.InstanceId) < 1 { invalidParams.Add(aws.NewErrParamMinLen("InstanceId", 1)) } if invalidParams.Len() > 0 { return invalidParams } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *InfoField) Validate() error {\n\tif err := f.BWCls.Validate(); err != nil {\n\t\treturn err\n\t}\n\tif err := f.RLC.Validate(); err != nil {\n\t\treturn err\n\t}\n\tif err := f.Idx.Validate(); err != nil {\n\t\treturn err\n\t}\n\tif err := f.PathType.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\tretu...
[ "0.6366166", "0.6255708", "0.62440985", "0.6219268", "0.6205969", "0.6186602", "0.61787015", "0.6151207", "0.6135345", "0.6129121", "0.61265224", "0.61265224", "0.60985357", "0.60598147", "0.60547787", "0.60132855", "0.5993056", "0.5990731", "0.59752667", "0.59422064", "0.591...
0.0
-1
MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s DescribeUserHierarchyStructureInput) MarshalFields(e protocol.FieldEncoder) error { e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{}) if s.InstanceId != nil { v := *s.InstanceId metadata := protocol.Metadata{} e.SetValue(protocol.PathTarget, "InstanceId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s CreateApiOutput) MarshalFields(e protocol.FieldEncoder) error {\n\tif s.ApiEndpoint != nil {\n\t\tv := *s.ApiEndpoint\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"apiEndpoint\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.ApiId != n...
[ "0.6349841", "0.6247435", "0.6194363", "0.61811036", "0.6169666", "0.61222064", "0.6101693", "0.607118", "0.6064306", "0.60118675", "0.60097605", "0.59601545", "0.5952495", "0.5934505", "0.59278136", "0.59241146", "0.5908956", "0.59053487", "0.5899269", "0.5884041", "0.587740...
0.0
-1
String returns the string representation
func (s DescribeUserHierarchyStructureOutput) String() string { return awsutil.Prettify(s) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s CreateAlgorithmOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s CreateAlgorithmOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s Library) String() string {\n\tres := make([]string, 5)\n\tres[0] = \"ID: \" + reform.Inspect(s.ID, true)\n\tres[1] = \"UserID: \" + r...
[ "0.721496", "0.721496", "0.72003424", "0.72003067", "0.71778786", "0.71672124", "0.71179444", "0.7087169", "0.708676", "0.70792294", "0.7078306", "0.7067698", "0.7031764", "0.7027706", "0.7026941", "0.70254856", "0.7020726", "0.70168954", "0.7010962", "0.70102316", "0.7001954...
0.0
-1
MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s DescribeUserHierarchyStructureOutput) MarshalFields(e protocol.FieldEncoder) error { if s.HierarchyStructure != nil { v := s.HierarchyStructure metadata := protocol.Metadata{} e.SetFields(protocol.BodyTarget, "HierarchyStructure", v, metadata) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s CreateApiOutput) MarshalFields(e protocol.FieldEncoder) error {\n\tif s.ApiEndpoint != nil {\n\t\tv := *s.ApiEndpoint\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"apiEndpoint\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.ApiId != n...
[ "0.63462156", "0.6244603", "0.6192145", "0.6177832", "0.6165666", "0.61186266", "0.60982037", "0.60677594", "0.6061786", "0.60107094", "0.6006523", "0.5958391", "0.5950599", "0.59313834", "0.59261024", "0.5919634", "0.5908056", "0.5903742", "0.5897319", "0.5880696", "0.587484...
0.0
-1
Send marshals and sends the DescribeUserHierarchyStructure API request.
func (r DescribeUserHierarchyStructureRequest) Send(ctx context.Context) (*DescribeUserHierarchyStructureResponse, error) { r.Request.SetContext(ctx) err := r.Request.Send() if err != nil { return nil, err } resp := &DescribeUserHierarchyStructureResponse{ DescribeUserHierarchyStructureOutput: r.Request.Data.(*DescribeUserHierarchyStructureOutput), response: &aws.Response{Request: r.Request}, } return resp, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *DescribeUserHierarchyStructureOutput) SetHierarchyStructure(v *HierarchyStructure) *DescribeUserHierarchyStructureOutput {\n\ts.HierarchyStructure = v\n\treturn s\n}", "func (s *UpdateUserHierarchyStructureInput) SetHierarchyStructure(v *HierarchyStructureUpdate) *UpdateUserHierarchyStructureInput {\n\t...
[ "0.57184553", "0.5469647", "0.5156814", "0.49289703", "0.48873046", "0.48873046", "0.4772959", "0.4772959", "0.44967076", "0.4447158", "0.4413114", "0.44060668", "0.44043696", "0.44002792", "0.43401435", "0.4336481", "0.42501748", "0.42497203", "0.42474967", "0.42249528", "0....
0.7537883
0
SDKResponseMetdata returns the response metadata for the DescribeUserHierarchyStructure request.
func (r *DescribeUserHierarchyStructureResponse) SDKResponseMetdata() *aws.Response { return r.response }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *DescribeUserResponse) SDKResponseMetdata() *aws.Response {\n\treturn r.response\n}", "func (r *DescribeOrganizationConfigurationResponse) SDKResponseMetdata() *aws.Response {\n\treturn r.response\n}", "func (r *DescribeAccountAuditConfigurationResponse) SDKResponseMetdata() *aws.Response {\n\treturn r...
[ "0.62536407", "0.5904975", "0.5872406", "0.5871081", "0.5858043", "0.5845549", "0.5798019", "0.57850534", "0.574214", "0.57293725", "0.5725915", "0.57254905", "0.57240504", "0.5721584", "0.5710341", "0.570328", "0.5691056", "0.5691056", "0.5689465", "0.5678145", "0.56704104",...
0.7379813
0
Func to remove lines if contains keyword 'TODO'
func removeText(fileName string) { //Skip main.go file if fileName != "main.go" { //Read file bytes from filename param, a success call return err==null, not err==EOF input, err := ioutil.ReadFile(fileName) if err != nil { log.Fatalln(err) } //Convert content to string text := string(input) //Replace keyword 'TODO' by regex re := regexp.MustCompile(".*TODO.*\r?\n") lines := re.ReplaceAllString(text, "") //Write string into a file err = WriteToFile(fileName, lines) if err != nil { log.Fatal(err) } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (rign *CFGoReadIgnore) Clean() {\n}", "func (todo Todo) Remove() error {\n\treturn todo.updateInPlace(func(lineNumber int, line string) (string, bool) {\n\t\tif lineNumber == todo.Line {\n\t\t\treturn \"\", true\n\t\t}\n\n\t\treturn line, false\n\t})\n}", "func TestGoDocSkipLinesPass(t *testing.T) {\n\tac...
[ "0.54466265", "0.5368636", "0.5209538", "0.51757854", "0.51733", "0.510984", "0.5052854", "0.5028639", "0.501462", "0.49272683", "0.49216142", "0.48630762", "0.4812344", "0.4799068", "0.47983843", "0.4777912", "0.47583553", "0.4754255", "0.46990237", "0.4693532", "0.4676753",...
0.6194988
0
Func to write string into a file function, with filename param
func WriteToFile(filename string, data string) error { file, err := os.Create(filename) if err != nil { return err } defer file.Close() _, err = io.WriteString(file, data) if err != nil { return err } return file.Sync() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func FileWriteString(f *os.File, s string) (int, error)", "func _file_write(call otto.FunctionCall) otto.Value {\n\tfilepath, _ := call.Argument(0).ToString()\n\tdata, _ := call.Argument(1).ToString()\n\tif !fileExists(filepath) {\n\t\tos.Create(filepath)\n\t}\n\n\tfile, err := os.OpenFile(filepath, os.O_APPEND|...
[ "0.7139199", "0.6933927", "0.67930186", "0.67593706", "0.65849555", "0.654152", "0.6540923", "0.6525228", "0.64944446", "0.6472575", "0.645946", "0.6423754", "0.6371545", "0.6369693", "0.6349962", "0.633454", "0.63281596", "0.6317388", "0.62762797", "0.6273116", "0.62696135",...
0.5798089
49
NewWorkload constructs and returns a workload representation from an application reference.
func NewWorkload(cluster *kubernetes.Cluster, app models.AppRef) *Workload { return &Workload{cluster: cluster, app: app} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewWorkloadDefinition(ctx *pulumi.Context,\n\tname string, args *WorkloadDefinitionArgs, opts ...pulumi.ResourceOption) (*WorkloadDefinition, error) {\n\tif args == nil {\n\t\targs = &WorkloadDefinitionArgs{}\n\t}\n\targs.ApiVersion = pulumi.StringPtr(\"core.oam.dev/v1alpha2\")\n\targs.Kind = pulumi.StringPtr...
[ "0.6290281", "0.6186775", "0.59179425", "0.57543576", "0.5292014", "0.52139693", "0.52035826", "0.5164044", "0.51574534", "0.5087843", "0.5084347", "0.50763017", "0.49866802", "0.498484", "0.49624205", "0.4953039", "0.49443993", "0.49021307", "0.48930544", "0.47866622", "0.47...
0.78468955
0
BoundServicesChange imports the currently bound services into the deployment. It takes a ServiceList, not just names, as it has to create/retrieve the associated service binding secrets. It further takes a set of the old services. This enables incremental modification of the deployment (add, remove affected, instead of wholsesale replacement).
func (a *Workload) BoundServicesChange(ctx context.Context, userName string, oldServices NameSet, newServices interfaces.ServiceList) error { app, err := Get(ctx, a.cluster, a.app) if err != nil { // Should not happen. Application was validated to exist // already somewhere by callers. return err } owner := metav1.OwnerReference{ APIVersion: app.GetAPIVersion(), Kind: app.GetKind(), Name: app.GetName(), UID: app.GetUID(), } bindings, err := ToBinds(ctx, newServices, a.app.Name, owner, userName) if err != nil { return err } // Create name-keyed maps from old/new slices for quick lookup and decision. No linear searches. new := map[string]struct{}{} for _, s := range newServices { new[s.Name()] = struct{}{} } // Read, modify and write the deployment return retry.RetryOnConflict(retry.DefaultRetry, func() error { // Retrieve the latest version of Deployment before attempting update // RetryOnConflict uses exponential backoff to avoid exhausting the apiserver deployment, err := a.Deployment(ctx) if err != nil { return err } // The action is done in multiple iterations over the deployment's volumes and volumemounts. // The first iteration over each determines removed services (in old, not in new). The second // iteration, over the new services now, adds all which are not in old, i.e. actually new. newVolumes := []corev1.Volume{} newMounts := []corev1.VolumeMount{} for _, volume := range deployment.Spec.Template.Spec.Volumes { _, hasold := oldServices[volume.Name] _, hasnew := new[volume.Name] // Note that volumes which are not in old are passed and kept. These are the volumes // not related to services. if hasold && !hasnew { continue } newVolumes = append(newVolumes, volume) } // TODO: Iterate over containers and find the one matching the app name for _, mount := range deployment.Spec.Template.Spec.Containers[0].VolumeMounts { _, hasold := oldServices[mount.Name] _, hasnew := new[mount.Name] // Note that volumes which are in not in old are passed and kept. These are the volumes // not related to services. if hasold && !hasnew { continue } newMounts = append(newMounts, mount) } for _, binding := range bindings { // Skip services which already exist if _, hasold := oldServices[binding.service]; hasold { continue } newVolumes = append(newVolumes, corev1.Volume{ Name: binding.service, VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ SecretName: binding.resource, }, }, }) newMounts = append(newMounts, corev1.VolumeMount{ Name: binding.service, ReadOnly: true, MountPath: fmt.Sprintf("/services/%s", binding.service), }) } // Write the changed set of mounts and volumes back to the deployment ... deployment.Spec.Template.Spec.Volumes = newVolumes deployment.Spec.Template.Spec.Containers[0].VolumeMounts = newMounts // ... and then the cluster. _, err = a.cluster.Kubectl.AppsV1().Deployments(a.app.Org).Update( ctx, deployment, metav1.UpdateOptions{}) return err }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (service *Service) HandelBoundServices(d9SecurityGroupID, policyType string, boundService BoundServicesRequest) (*CloudSecurityGroupResponse, *http.Response, error) {\n\tv := new(CloudSecurityGroupResponse)\n\trelativeURL := fmt.Sprintf(\"%s/%s/%s/%s\", awsSgResourcePath, d9SecurityGroupID, awsSgResourceServi...
[ "0.56772745", "0.54476625", "0.5211605", "0.51789063", "0.51135707", "0.50000817", "0.4976379", "0.49644193", "0.49369168", "0.48852873", "0.48671865", "0.4861238", "0.48560068", "0.48487443", "0.482289", "0.48134246", "0.48115814", "0.47962728", "0.47867313", "0.47812405", "...
0.7591342
0
EnvironmentChange imports the current environment into the deployment. This requires only the names of the currently existing environment variables, not the values, as the import is internally done as pod env specifications using secret key references.
func (a *Workload) EnvironmentChange(ctx context.Context, varNames []string) error { return retry.RetryOnConflict(retry.DefaultRetry, func() error { // Retrieve the latest version of Deployment before attempting update // RetryOnConflict uses exponential backoff to avoid exhausting the apiserver deployment, err := a.Deployment(ctx) if err != nil { return err } evSecretName := a.app.MakeEnvSecretName() // 1. Remove all the old EVs referencing the app's EV secret. // 2. Add entries for the new set of EV's (S.a varNames). // 3. Replace container spec // // Note: While 1+2 could be optimized to only remove entries of // EVs not in varNames, and add only entries for varNames // not in Env, this is way more complex for what is likely // just 10 entries. I expect any gain in perf to be // negligible, and completely offset by the complexity of // understanding and maintaining it later. Full removal // and re-adding is much simpler to understand, and should // be fast enough. newEnvironment := []corev1.EnvVar{} for _, ev := range deployment.Spec.Template.Spec.Containers[0].Env { // Drop EV if pulled from EV secret of the app if ev.ValueFrom != nil && ev.ValueFrom.SecretKeyRef != nil && ev.ValueFrom.SecretKeyRef.Name == evSecretName { continue } // Keep everything else. newEnvironment = append(newEnvironment, ev) } for _, varName := range varNames { newEnvironment = append(newEnvironment, corev1.EnvVar{ Name: varName, ValueFrom: &corev1.EnvVarSource{ SecretKeyRef: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ Name: evSecretName, }, Key: varName, }, }, }) } deployment.Spec.Template.Spec.Containers[0].Env = newEnvironment _, err = a.cluster.Kubectl.AppsV1().Deployments(a.app.Org).Update( ctx, deployment, metav1.UpdateOptions{}) return err }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func env() error {\n\t// regexp for TF_VAR_ terraform vars\n\ttfVar := regexp.MustCompile(`^TF_VAR_.*$`)\n\n\t// match terraform vars in environment\n\tfor _, e := range os.Environ() {\n\t\t// split on value\n\t\tpair := strings.SplitN(e, \"=\", 2)\n\n\t\t// match on TF_VAR_*\n\t\tif tfVar.MatchString(pair[0]) {\n...
[ "0.5812909", "0.5790658", "0.576041", "0.5611268", "0.5522273", "0.5518604", "0.549987", "0.5493906", "0.54892653", "0.54662716", "0.54650384", "0.54612553", "0.5447039", "0.54098463", "0.5391029", "0.5381192", "0.53804636", "0.537156", "0.53701836", "0.5362287", "0.5356194",...
0.76379824
0
Scale changes the number of instances (replicas) for the application's Deployment.
func (a *Workload) Scale(ctx context.Context, instances int32) error { return retry.RetryOnConflict(retry.DefaultRetry, func() error { // Retrieve the latest version of Deployment before attempting update // RetryOnConflict uses exponential backoff to avoid exhausting the apiserver deployment, err := a.Deployment(ctx) if err != nil { return err } deployment.Spec.Replicas = &instances _, err = a.cluster.Kubectl.AppsV1().Deployments(a.app.Org).Update( ctx, deployment, metav1.UpdateOptions{}) return err }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Scale(namespace string, app string, n *int32) error {\n\tc, err := k8s.NewInClusterClient()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to get k8s client\")\n\t}\n\n\td, err := c.ExtensionsV1Beta1().GetDeployment(ctx, app, namespace)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed t...
[ "0.82982755", "0.73352265", "0.7108116", "0.70009696", "0.6907844", "0.6820197", "0.6735582", "0.67346925", "0.66280305", "0.64414525", "0.6375801", "0.6365863", "0.6314644", "0.62918156", "0.62655246", "0.6144791", "0.61160296", "0.60683995", "0.60674256", "0.5875461", "0.58...
0.8210777
1
deployment is a helper, it returns the kube deployment resource of the workload.
func (a *Workload) Deployment(ctx context.Context) (*appsv1.Deployment, error) { return a.cluster.Kubectl.AppsV1().Deployments(a.app.Org).Get( ctx, a.app.Name, metav1.GetOptions{}, ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func kubeconDeployment(image, tag string) (*apiv1b2.Deployment, error) {\n\tom := webappMeta(helloKubeconDeploymentName, \"api\")\n\tif tag == \"\" || image == \"\" {\n\t\treturn nil, fmt.Errorf(\"error: image and tag must be defined\")\n\t}\n\tpts := &v1.PodTemplateSpec{\n\t\tObjectMeta: om,\n\t\tSpec: v1.PodSpec...
[ "0.69726676", "0.6918134", "0.6861107", "0.6786004", "0.6662607", "0.6639795", "0.6584675", "0.6517535", "0.65127385", "0.64983946", "0.6455542", "0.64240986", "0.6340011", "0.6307846", "0.63056487", "0.6301531", "0.62912184", "0.6233751", "0.6231887", "0.62260896", "0.622602...
0.7065447
0
Get returns the state of the app deployment encoded in the workload.
func (a *Workload) Get(ctx context.Context, deployment *appsv1.Deployment) *models.AppDeployment { active := false route := "" stageID := "" status := "" username := "" // Query application deployment for stageID and status (ready vs desired replicas) deploymentSelector := fmt.Sprintf("app.kubernetes.io/part-of=%s,app.kubernetes.io/name=%s", a.app.Org, a.app.Name) deploymentListOptions := metav1.ListOptions{ LabelSelector: deploymentSelector, } deployments, err := a.cluster.Kubectl.AppsV1().Deployments(a.app.Org).List(ctx, deploymentListOptions) if err != nil { status = pkgerrors.Wrap(err, "failed to get Deployment status").Error() } else if len(deployments.Items) < 1 { status = "0/0" } else { status = fmt.Sprintf("%d/%d", deployments.Items[0].Status.ReadyReplicas, deployments.Items[0].Status.Replicas) stageID = deployments.Items[0]. Spec.Template.ObjectMeta.Labels["epinio.suse.org/stage-id"] username = deployments.Items[0].Spec.Template.ObjectMeta.Labels["app.kubernetes.io/created-by"] active = true } routes, err := a.cluster.ListIngressRoutes(ctx, a.app.Org, names.IngressName(a.app.Name)) if err != nil { route = err.Error() } else { route = routes[0] } return &models.AppDeployment{ Active: active, Username: username, StageID: stageID, Status: status, Route: route, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *Deployment) Get(namespace, name string) (*appsv1.Deployment, error) {\n\tdeploy, err := d.cs.AppsV1().Deployments(namespace).Get(context.Background(), name, metav1.GetOptions{})\n\tif err != nil {\n\t\tif k8serrors.IsNotFound(err) {\n\t\t\treturn nil, k8serror.ErrNotFound\n\t\t}\n\t\treturn nil, err\n\t}\...
[ "0.60578436", "0.5990617", "0.5870273", "0.5749326", "0.5747082", "0.5648761", "0.5562212", "0.5540046", "0.54830396", "0.5407057", "0.5313466", "0.5292182", "0.5255391", "0.52393395", "0.52236474", "0.5207524", "0.51852775", "0.5173332", "0.5171748", "0.51617277", "0.5147494...
0.7768766
0
Uses figlet to generate ascii art text
func Figlet(msg string) (string, error) { cmd := exec.Command(figletcmd, msg) b, err := cmd.Output() if err != nil { return msg, err } return string(b), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Figlet(msg string) (string, error) {\n\t// Figlet4go also support using figlet fonts (/usr/share/figlet/*.flf).\n\t// These also supports lowercase characters.\n\t// Look at slant.flf and big.flf, for instance.\n\t// TODO: Use big.flf, if available\n\tar := figlet4go.NewAsciiRender()\n\treturn ar.Render(msg)\...
[ "0.6409015", "0.63927233", "0.58695", "0.58139056", "0.5674917", "0.56051385", "0.5559758", "0.5534353", "0.5517358", "0.5478104", "0.5449108", "0.5446319", "0.53765625", "0.5314368", "0.5303025", "0.5302334", "0.52745944", "0.52546656", "0.5204993", "0.5194887", "0.5191028",...
0.55526286
7
NewRepository returns Repository with given middleware.Pool
func NewRepository(db middleware.Pool) *Repository { return &Repository{Database: db} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewRepository(pool *pgxpool.Pool) *Repository {\n\treturn &Repository{pool: pool}\n}", "func New(pool *pgxpool.Pool) (repository.Repository, error) {\n\tif pool == nil {\n\t\treturn nil, ErrMissingPool\n\t}\n\n\treturn postgresRepository{\n\t\tpool: pool,\n\t}, nil\n}", "func NewRepository(pool *pgxpool.P...
[ "0.7033007", "0.70324636", "0.68525314", "0.67147243", "0.65552145", "0.65296394", "0.6516489", "0.64633226", "0.6458645", "0.6428717", "0.6424986", "0.64021033", "0.6314789", "0.62775224", "0.6276378", "0.62416613", "0.6236914", "0.621444", "0.61860937", "0.6185766", "0.6185...
0.76721686
0
NewRepository returns Repository with global mysql pool
func NewRepositoryWithGlobal() *Repository { return NewRepository(global.DASMySQLPool) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewRepository(repo *Repository, db *sql.DB) (*Repository, error) {\n\tfmt.Println(\"START NewRepository\")\n\tdefer fmt.Println(\"END START NewRepository\")\n\n\trepo.db = db\n\n\terr := db.Ping()\n\tif err != nil {\n\t\tfmt.Println(\"db err: \", err)\n\t\treturn nil, err\n\t}\n\n\tdb.SetMaxIdleConns(500)\n\t...
[ "0.6742565", "0.66320115", "0.6582812", "0.65410703", "0.6381777", "0.6357211", "0.6310225", "0.6292557", "0.62729156", "0.62224114", "0.62185216", "0.6188371", "0.61257654", "0.6119679", "0.6106526", "0.609459", "0.60807514", "0.6075455", "0.6065493", "0.6063669", "0.6062696...
0.63773257
5
Execute executes given command and placeholders on the middleware
func (r *Repository) Execute(command string, args ...interface{}) (middleware.Result, error) { conn, err := r.Database.Get() if err != nil { return nil, err } defer func() { err = conn.Close() if err != nil { log.Errorf("alert DASRepo.Execute(): close database connection failed.\n%s", err.Error()) } }() return conn.Execute(command, args...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Command) Execute(user string, msg string, args []string) {\n}", "func (h *Handler) Execute(name string, args []string) {\n\tlog.Warn(\"generic doesn't support command execution\")\n}", "func (this Middleware) executeMiddlewareLocally(pair models.RequestResponsePair) (models.RequestResponsePair, error)...
[ "0.6153839", "0.60812134", "0.6061275", "0.57693285", "0.56747967", "0.5673223", "0.56219643", "0.562186", "0.5618159", "0.55443805", "0.55078334", "0.5487502", "0.54630804", "0.54364175", "0.5420066", "0.54042244", "0.5403575", "0.54031974", "0.5371576", "0.53653485", "0.536...
0.5757006
4
Transaction returns a middleware.Transaction that could execute multiple commands as a transaction
func (r *Repository) Transaction() (middleware.Transaction, error) { return r.Database.Transaction() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Transaction(next http.Handler) http.Handler {\n\tfn := func(w http.ResponseWriter, r *http.Request) {\n\t\tt, ctx := orm.NewTransaction(r.Context())\n\t\tdefer func() {\n\t\t\tif rec := recover(); rec != nil {\n\t\t\t\tt.Rollback()\n\t\t\t\t// Panic to let recoverer handle 500\n\t\t\t\tpanic(rec)\n\t\t\t} els...
[ "0.6934194", "0.68263537", "0.66666955", "0.65281916", "0.65220726", "0.6500732", "0.64666903", "0.6418999", "0.6384218", "0.63415635", "0.6333283", "0.63124186", "0.630846", "0.6259748", "0.62529105", "0.6215971", "0.62130564", "0.6209439", "0.6205622", "0.6169113", "0.61445...
0.7005496
0
Save saves sql tuning advice into the middleware
func (r *Repository) Save(url string, toAddr, ccAddr []string, content string, status int) error { return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (aps *ApiServer) setMiddleware() {\n\t/*\n\t\taps.Engine.Use(func(c *gin.Context) {\n\t\t\tstart := time.Now()\n\t\t\tc.Next()\n\t\t\tend := time.Now()\n\t\t\tlatency := end.Sub(start)\n\t\t\tpath := c.Request.URL.Path\n\t\t\tclientIP := c.ClientIP()\n\t\t\tmethod := c.Request.Method\n\t\t\tstatusCode := c.Wr...
[ "0.531296", "0.50333303", "0.4953532", "0.48831928", "0.48323447", "0.47431743", "0.46773672", "0.4666421", "0.46413967", "0.460012", "0.45993534", "0.45916364", "0.45906082", "0.45842862", "0.45842552", "0.45771828", "0.4524724", "0.45106146", "0.45050916", "0.45030513", "0....
0.0
-1
a,b integer values x 8/56 fixed point value
func incomplete(a, b, x int64) Fixed { // Iₓ(a,b) = (xᵃ*(1-x)ᵇ)/(a*B(a,b)) * (1/(1+(d₁/(1+(d₂/(1+...)))))) // (xᵃ*(1-x)ᵇ)/B(a,b) = exp(lgamma(a+b) - lgamma(a) - lgamma(b) + a*log(x) + b*log(1-x)) // d_{2m+1} = -(a+m)(a+b+m)x/((a+2m)(a+2m+1)) // d_{2m} = m(b-m)x/((a+2m-1)(a+2m)) if a > int64(1)<<30 || b > int64(1)<<30 { panic(ErrOverflow) } bt := fixed(0) if 0 < x && x < oneValue { bt = exp(addx(subx(lgamma(a+b), lgamma(a), lgamma(b)), alogx(x, a), alogx(oneValue-x, b))) } else if x < 0 || x > oneValue { panic(ErrOverflow) } bcfx := func() Fixed { if bt.iszero() { return bt } h := bcf(x, a, b) return div(mul(bt, h), fixed(a)) } if x > div(fixed(a+1), fixed(a+b+2)).fixed56() { // symmetry transform // 1 - bt/b*bcf(1-x,b,a) x, a, b = oneValue-x, b, a return sub(fixedOne, bcfx()) } return bcfx() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func HexAxpy(c, b []float64, s float64, ci, bi int)", "func PMINSBm128int8(X1 []int8, X2 []int8)", "func HexadecAxpy(c, b []float64, s float64, ci, bi int)", "func Changebytetoint(b []byte) (x int64) {\n\tfor i, val := range b {\n\t\tif i == 0 {\n\t\t\tx = x + int64(val)\n\t\t} else {\n\t\t\tx = x + int64(2<...
[ "0.5875011", "0.5786388", "0.56857926", "0.5649239", "0.55676305", "0.55642706", "0.5491502", "0.54723597", "0.5457835", "0.5405847", "0.53998804", "0.5364934", "0.53503346", "0.5335121", "0.53200454", "0.52959776", "0.5291742", "0.52640444", "0.5239919", "0.5216811", "0.5206...
0.55694884
4
Calculate returns the standard deviation of a base indicator
func (sdi StandardDeviationIndicator) Calculate(index int) big.Decimal { return VarianceIndicator{ Indicator: sdi.Indicator, }.Calculate(index).Sqrt() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (h *pingHistory) stdDev() float64 {\n\treturn math.Sqrt(h.variance())\n}", "func (e *exemplarSampler) standardDeviation() float64 {\n\tif e.count < 2 {\n\t\treturn 0\n\t}\n\treturn math.Sqrt(e.m2 / float64(e.count-1))\n}", "func TestGet_StandardDeviation(t *testing.T) {\n\tdata := []float64{1345, 1301, 13...
[ "0.63204044", "0.62387717", "0.62177527", "0.6179172", "0.60376096", "0.60309976", "0.59888536", "0.5988705", "0.5976886", "0.5951141", "0.59371185", "0.5927489", "0.59189886", "0.5914602", "0.5874174", "0.58649164", "0.5854873", "0.58130044", "0.57826555", "0.5778925", "0.57...
0.6419046
0
NewClient Creates a new client to communicate with the Sentry API.
func NewClient(api string, baseURI string, org string) *Client { if !strings.HasSuffix(baseURI, "/") { baseURI += "/" } return &Client{ client: &http.Client{}, sentryAPIKey: api, sentryURI: baseURI, sentryOrg: org, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewClient(clientID string) *Client {\n\treturn &Client{\n\t\tApi: &soundcloud.Api{\n\t\t\tClientId: clientID,\n\t\t},\n\t\tclientID: clientID,\n\t\thc: &http.Client{\n\t\t\tTimeout: 5 * time.Second,\n\t\t},\n\t}\n}", "func New(client *sajari.Client) *Client {\n\treturn &Client{\n\t\tc: client,\n\t}\n}", "...
[ "0.69753504", "0.6909176", "0.68756545", "0.6828231", "0.6781878", "0.6778484", "0.67573667", "0.6750796", "0.6738676", "0.67295736", "0.67211974", "0.6719252", "0.67097473", "0.67009145", "0.66968787", "0.6682295", "0.66727865", "0.6664944", "0.66583467", "0.6650193", "0.664...
0.72267675
0
Check that the constructor works.
func TestNewTransport(t *testing.T) { _, err := NewTransport(testURL, ips, nil, nil, nil) if err != nil { t.Fatal(err) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestConstructor(t *testing.T) {\n\tobject := Constructor()\n\tobjectType := reflect.TypeOf(object)\n\tminStackType := reflect.TypeOf(MinStack{})\n\tif objectType != minStackType {\n\t\tt.Errorf(\"Constructor Error | Expected %v, got %v\", minStackType, objectType)\n\t}\n}", "func TestConstructor(t *testing....
[ "0.6858513", "0.6666509", "0.6298899", "0.6049641", "0.59415185", "0.58098793", "0.58064705", "0.57521695", "0.5611217", "0.55934876", "0.5578441", "0.5485013", "0.54486066", "0.5383912", "0.53633654", "0.5355686", "0.5350019", "0.53485173", "0.53275627", "0.53227466", "0.530...
0.0
-1
Check that the constructor rejects unsupported URLs.
func TestBadUrl(t *testing.T) { _, err := NewTransport("ftp://www.example.com", nil, nil, nil, nil) if err == nil { t.Error("Expected error") } _, err = NewTransport("https://www.example", nil, nil, nil, nil) if err == nil { t.Error("Expected error") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func validURL(url string) bool {\n\treturn true\n}", "func URL(data ValidationData) error {\n\tv, err := helper.ToString(data.Value)\n\tif err != nil {\n\t\treturn ErrInvalid{\n\t\t\tValidationData: data,\n\t\t\tFailure: \"is not a string\",\n\t\t\tMessage: data.Message,\n\t\t}\n\t}\n\n\tparsed, er...
[ "0.61628383", "0.60171264", "0.5781071", "0.56981534", "0.566405", "0.56014615", "0.5594309", "0.557612", "0.5561288", "0.55422866", "0.5511598", "0.55095285", "0.5507065", "0.5505966", "0.54857326", "0.54577285", "0.54563826", "0.54048747", "0.5387832", "0.5376122", "0.53429...
0.65448236
0
Check for failure when the query is too short to be valid.
func TestShortQuery(t *testing.T) { var qerr *queryError doh, _ := NewTransport(testURL, ips, nil, nil, nil) _, err := doh.Query([]byte{}) if err == nil { t.Error("Empty query should fail") } else if !errors.As(err, &qerr) { t.Errorf("Wrong error type: %v", err) } else if qerr.status != BadQuery { t.Errorf("Wrong error status: %d", qerr.status) } _, err = doh.Query([]byte{1}) if err == nil { t.Error("One byte query should fail") } else if !errors.As(err, &qerr) { t.Errorf("Wrong error type: %v", err) } else if qerr.status != BadQuery { t.Errorf("Wrong error status: %d", qerr.status) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsOverQueryLimit(err error) bool {\n\tif e, ok := err.(*apiError); ok {\n\t\treturn e.Status == \"OVER_QUERY_LIMIT\"\n\t}\n\treturn false\n}", "func check_args(parsed_query []string, num_expected int) bool {\n\treturn (len(parsed_query) >= num_expected)\n}", "func (v *verifier) MinLength(length int) *veri...
[ "0.60837597", "0.58889705", "0.58200884", "0.58081704", "0.5772958", "0.5753801", "0.5691889", "0.5673438", "0.5651879", "0.5646494", "0.5557274", "0.55330944", "0.5494559", "0.5465842", "0.5409435", "0.5400918", "0.53961563", "0.5393424", "0.53896415", "0.5370335", "0.531648...
0.5915572
1
Send a DoH query to an actual DoH server
func TestQueryIntegration(t *testing.T) { queryData := []byte{ 111, 222, // [0-1] query ID 1, 0, // [2-3] flags, RD=1 0, 1, // [4-5] QDCOUNT (number of queries) = 1 0, 0, // [6-7] ANCOUNT (number of answers) = 0 0, 0, // [8-9] NSCOUNT (number of authoritative answers) = 0 0, 0, // [10-11] ARCOUNT (number of additional records) = 0 // Start of first query 7, 'y', 'o', 'u', 't', 'u', 'b', 'e', 3, 'c', 'o', 'm', 0, // null terminator of FQDN (DNS root) 0, 1, // QTYPE = A 0, 1, // QCLASS = IN (Internet) } testQuery := func(queryData []byte) { doh, err := NewTransport(testURL, ips, nil, nil, nil) if err != nil { t.Fatal(err) } resp, err2 := doh.Query(queryData) if err2 != nil { t.Fatal(err2) } if resp[0] != queryData[0] || resp[1] != queryData[1] { t.Error("Query ID mismatch") } if len(resp) <= len(queryData) { t.Error("Response is short") } } testQuery(queryData) paddedQueryBytes, err := AddEdnsPadding(simpleQueryBytes) if err != nil { t.Fatal(err) } testQuery(paddedQueryBytes) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Client) Do(query interface{}) (interface{}, error) {\n\n\t// TODO: make sure it's a real query message - the proto will allow responses as well, and we don't want that\n\n\tmsg, err := c.proto.WriteMessage(query)\n\tif err != nil {\n\t\treturn nil, errors.NewError(\"Could not send query: %s\", err)\n\t}\n...
[ "0.6129731", "0.60646135", "0.60184616", "0.6008058", "0.5970393", "0.5874811", "0.5786087", "0.5687894", "0.56664693", "0.5643446", "0.5627055", "0.5622696", "0.562168", "0.560722", "0.5519367", "0.5510898", "0.5503905", "0.5501435", "0.54969597", "0.54964566", "0.5490829", ...
0.0
-1
Check that a DNS query is converted correctly into an HTTP query.
func TestRequest(t *testing.T) { doh, _ := NewTransport(testURL, ips, nil, nil, nil) transport := doh.(*transport) rt := makeTestRoundTripper() transport.client.Transport = rt go doh.Query(simpleQueryBytes) req := <-rt.req if req.URL.String() != testURL { t.Errorf("URL mismatch: %s != %s", req.URL.String(), testURL) } reqBody, err := ioutil.ReadAll(req.Body) if err != nil { t.Error(err) } if len(reqBody)%PaddingBlockSize != 0 { t.Errorf("reqBody has unexpected length: %d", len(reqBody)) } // Parse reqBody into a Message. newQuery := mustUnpack(reqBody) // Ensure the converted request has an ID of zero. if newQuery.Header.ID != 0 { t.Errorf("Unexpected request header id: %v", newQuery.Header.ID) } // Check that all fields except for Header.ID and Additionals // are the same as the original. Additionals may differ if // padding was added. if !queriesMostlyEqual(simpleQuery, *newQuery) { t.Errorf("Unexpected query body:\n\t%v\nExpected:\n\t%v", newQuery, simpleQuery) } contentType := req.Header.Get("Content-Type") if contentType != "application/dns-message" { t.Errorf("Wrong content type: %s", contentType) } accept := req.Header.Get("Accept") if accept != "application/dns-message" { t.Errorf("Wrong Accept header: %s", accept) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestShortQuery(t *testing.T) {\n\tvar qerr *queryError\n\tdoh, _ := NewTransport(testURL, ips, nil, nil, nil)\n\t_, err := doh.Query([]byte{})\n\tif err == nil {\n\t\tt.Error(\"Empty query should fail\")\n\t} else if !errors.As(err, &qerr) {\n\t\tt.Errorf(\"Wrong error type: %v\", err)\n\t} else if qerr.statu...
[ "0.61967796", "0.59444106", "0.5883444", "0.58111125", "0.5794155", "0.56501865", "0.5649279", "0.5606844", "0.55810744", "0.557853", "0.55547315", "0.54801077", "0.5479285", "0.5403357", "0.5397834", "0.5353204", "0.5351625", "0.53264076", "0.530033", "0.52961653", "0.525122...
0.51648927
30
Check that all fields of m1 match those of m2, except for Header.ID and Additionals.
func queriesMostlyEqual(m1 dnsmessage.Message, m2 dnsmessage.Message) bool { // Make fields we don't care about match, so that equality check is easy. m1.Header.ID = m2.Header.ID m1.Additionals = m2.Additionals return reflect.DeepEqual(m1, m2) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Record) Eq(other *Record) bool {\n\n\t// We disregard leader in equality tests, since LineMARC doesn't have one,\n\t// and it will be generated by decoders and encoder.\n\t/*\n\t\t// Leader equal?\n\t\tif r.Leader != other.Leader {\n\t\t\treturn false\n\t\t}\n\t*/\n\n\t// Control Fields equal?\n\tif len(r...
[ "0.59522516", "0.54425323", "0.5349307", "0.53088397", "0.5259998", "0.5258071", "0.5201605", "0.519218", "0.51761544", "0.51652557", "0.50507516", "0.5047003", "0.50291055", "0.49821675", "0.49660936", "0.48716882", "0.48716882", "0.48586023", "0.48566115", "0.48440102", "0....
0.6223601
0
Check that a DOH response is returned correctly.
func TestResponse(t *testing.T) { doh, _ := NewTransport(testURL, ips, nil, nil, nil) transport := doh.(*transport) rt := makeTestRoundTripper() transport.client.Transport = rt // Fake server. go func() { <-rt.req r, w := io.Pipe() rt.resp <- &http.Response{ StatusCode: 200, Body: r, Request: &http.Request{URL: parsedURL}, } // The DOH response should have a zero query ID. var modifiedQuery dnsmessage.Message = simpleQuery modifiedQuery.Header.ID = 0 w.Write(mustPack(&modifiedQuery)) w.Close() }() resp, err := doh.Query(simpleQueryBytes) if err != nil { t.Error(err) } // Parse the response as a DNS message. respParsed := mustUnpack(resp) // Query() should reconstitute the query ID in the response. if respParsed.Header.ID != simpleQuery.Header.ID || !queriesMostlyEqual(*respParsed, simpleQuery) { t.Errorf("Unexpected response %v", resp) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CheckResponse(r *http.Response) error {\n\tif r.StatusCode == 200 {\n\t\treader := bufio.NewReader(r.Body)\n\t\tfirstByte, err := reader.ReadByte()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treader.UnreadByte()\n\n\t\tif string(firstByte) == \"-\" {\n\t\t\terrorString, _ := reader.ReadString('\\n')\...
[ "0.61948586", "0.60625297", "0.6035303", "0.5975617", "0.59202296", "0.5916416", "0.5899773", "0.5872947", "0.585373", "0.5781684", "0.576798", "0.5761874", "0.5718958", "0.5677509", "0.56607926", "0.5654915", "0.55763286", "0.5567104", "0.55537856", "0.55441964", "0.55430424...
0.62793565
0
Simulate an empty response. (This is not a compliant server behavior.)
func TestEmptyResponse(t *testing.T) { doh, _ := NewTransport(testURL, ips, nil, nil, nil) transport := doh.(*transport) rt := makeTestRoundTripper() transport.client.Transport = rt // Fake server. go func() { <-rt.req // Make an empty body. r, w := io.Pipe() w.Close() rt.resp <- &http.Response{ StatusCode: 200, Body: r, Request: &http.Request{URL: parsedURL}, } }() _, err := doh.Query(simpleQueryBytes) var qerr *queryError if err == nil { t.Error("Empty body should cause an error") } else if !errors.As(err, &qerr) { t.Errorf("Wrong error type: %v", err) } else if qerr.status != BadResponse { t.Errorf("Wrong error status: %d", qerr.status) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CreateEmptyResponse(w http.ResponseWriter) {\n\tw.WriteHeader(http.StatusNoContent)\n}", "func (r *Responder) NoContent() { r.write(http.StatusNoContent) }", "func RespondEmpty(w http.ResponseWriter, code int) {\n\tw.Header().Set(\"X-XSS-Protection\", \"1; mode=block\")\n\tw.Header().Set(\"X-Content-Type-...
[ "0.75151366", "0.7469854", "0.7159161", "0.7026811", "0.7014444", "0.69953966", "0.69483393", "0.6848218", "0.6798946", "0.6741318", "0.67343277", "0.67306024", "0.6727121", "0.6715123", "0.66678727", "0.6632295", "0.6557014", "0.6511988", "0.64460313", "0.6439891", "0.643529...
0.7485086
1
Simulate a non200 HTTP response code.
func TestHTTPError(t *testing.T) { doh, _ := NewTransport(testURL, ips, nil, nil, nil) transport := doh.(*transport) rt := makeTestRoundTripper() transport.client.Transport = rt go func() { <-rt.req r, w := io.Pipe() rt.resp <- &http.Response{ StatusCode: 500, Body: r, Request: &http.Request{URL: parsedURL}, } w.Write([]byte{0, 0, 8, 9, 10}) w.Close() }() _, err := doh.Query(simpleQueryBytes) var qerr *queryError if err == nil { t.Error("Empty body should cause an error") } else if !errors.As(err, &qerr) { t.Errorf("Wrong error type: %v", err) } else if qerr.status != HTTPError { t.Errorf("Wrong error status: %d", qerr.status) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func respondHTTPCodeOnly(w http.ResponseWriter, code int) {\n w.WriteHeader(code)\n}", "func customResponseCode(w http.ResponseWriter, r *http.Request){\n\tw.WriteHeader(501)\n\tfmt.Fprintln(w, \"You have reached an endpoint that does not exist\")\n\n}", "func failIfNotStatusCode(t *testing.T, resp *github.Re...
[ "0.7124401", "0.7087085", "0.65703964", "0.64711255", "0.6452569", "0.64233696", "0.641495", "0.6388999", "0.6352772", "0.63128644", "0.6304014", "0.62912434", "0.6290846", "0.62804615", "0.6208764", "0.62053645", "0.6187882", "0.6167296", "0.6165685", "0.6135368", "0.6127713...
0.0
-1
Simulate an HTTP query error.
func TestSendFailed(t *testing.T) { doh, _ := NewTransport(testURL, ips, nil, nil, nil) transport := doh.(*transport) rt := makeTestRoundTripper() transport.client.Transport = rt rt.err = errors.New("test") _, err := doh.Query(simpleQueryBytes) var qerr *queryError if err == nil { t.Error("Send failure should be reported") } else if !errors.As(err, &qerr) { t.Errorf("Wrong error type: %v", err) } else if qerr.status != SendFailed { t.Errorf("Wrong error status: %d", qerr.status) } else if !errors.Is(qerr, rt.err) { t.Errorf("Underlying error is not retained") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestHTTPError(t *testing.T) {\n\tdoh, _ := NewTransport(testURL, ips, nil, nil, nil)\n\ttransport := doh.(*transport)\n\trt := makeTestRoundTripper()\n\ttransport.client.Transport = rt\n\n\tgo func() {\n\t\t<-rt.req\n\t\tr, w := io.Pipe()\n\t\trt.resp <- &http.Response{\n\t\t\tStatusCode: 500,\n\t\t\tBody: ...
[ "0.71777856", "0.62353325", "0.6109641", "0.6030236", "0.59038633", "0.57996684", "0.5759412", "0.5752646", "0.57412255", "0.5717031", "0.56211805", "0.557163", "0.5566794", "0.55465424", "0.5541418", "0.5538802", "0.55216664", "0.55215216", "0.5515991", "0.5514905", "0.55133...
0.5748074
8
Test if DoH resolver IPs are confirmed and disconfirmed when queries suceeded and fail, respectively.
func TestDohIPConfirmDisconfirm(t *testing.T) { u, _ := url.Parse(testURL) doh, _ := NewTransport(testURL, ips, nil, nil, nil) transport := doh.(*transport) hostname := u.Hostname() ipmap := transport.ips.Get(hostname) // send a valid request to first have confirmed-ip set res, _ := doh.Query(simpleQueryBytes) mustUnpack(res) ip1 := ipmap.Confirmed() if ip1 == nil { t.Errorf("IP not confirmed despite valid query to %s", u) } // simulate http-fail with doh server-ip set to previously confirmed-ip rt := makeTestRoundTripper() transport.client.Transport = rt go func() { req := <-rt.req trace := httptrace.ContextClientTrace(req.Context()) trace.GotConn(httptrace.GotConnInfo{ Conn: &fakeConn{ remoteAddr: &net.TCPAddr{ IP: ip1, // confirmed-ip from before Port: 443, }}}) rt.resp <- &http.Response{ StatusCode: 509, // some non-2xx status Body: nil, Request: &http.Request{URL: u}, } }() doh.Query(simpleQueryBytes) ip2 := ipmap.Confirmed() if ip2 != nil { t.Errorf("IP confirmed (%s) despite err", ip2) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestFlaggingDecommissionedHosts(t *testing.T) {\n\tConvey(\"When flagging decommissioned hosts\", t, func() {\n\n\t\tConvey(\"only hosts in the database who are marked decommissioned\"+\n\t\t\t\" should be returned\", func() {\n\n\t\t\t// reset the db\n\t\t\trequire.NoError(t, db.ClearCollections(host.Collect...
[ "0.56950366", "0.5444178", "0.52720666", "0.52533114", "0.52149844", "0.520094", "0.51740646", "0.51245964", "0.5120735", "0.5113124", "0.5092491", "0.50820696", "0.50752467", "0.50582534", "0.5049603", "0.5046325", "0.50083274", "0.49557894", "0.49459672", "0.49330953", "0.4...
0.71566
0
Check that the DNSListener is called with a correct summary.
func TestListener(t *testing.T) { listener := &fakeListener{} doh, _ := NewTransport(testURL, ips, nil, nil, listener) transport := doh.(*transport) rt := makeTestRoundTripper() transport.client.Transport = rt go func() { req := <-rt.req trace := httptrace.ContextClientTrace(req.Context()) trace.GotConn(httptrace.GotConnInfo{ Conn: &fakeConn{ remoteAddr: &net.TCPAddr{ IP: net.ParseIP("192.0.2.2"), Port: 443, }}}) r, w := io.Pipe() rt.resp <- &http.Response{ StatusCode: 200, Body: r, Request: &http.Request{URL: parsedURL}, } w.Write([]byte{0, 0, 8, 9, 10}) w.Close() }() doh.Query(simpleQueryBytes) s := listener.summary if s.Latency < 0 { t.Errorf("Negative latency: %f", s.Latency) } if !bytes.Equal(s.Query, simpleQueryBytes) { t.Errorf("Wrong query: %v", s.Query) } if !bytes.Equal(s.Response, []byte{0xbe, 0xef, 8, 9, 10}) { t.Errorf("Wrong response: %v", s.Response) } if s.Server != "192.0.2.2" { t.Errorf("Wrong server IP string: %s", s.Server) } if s.Status != Complete { t.Errorf("Wrong status: %d", s.Status) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DNS) Check(ipaddr net.IP) error {\n\t// NOTE: We are ignoring error. It says: \"nodename nor servname\n\t// provided, or not known\" if there is no DNS name for the IP address.\n\tnames, _ := net.LookupAddr(ipaddr.String())\n\td.Names = names\n\treturn nil\n}", "func okHealthCheck(proxy *Proxy) error {\...
[ "0.56406116", "0.52390766", "0.5200705", "0.5123499", "0.49002868", "0.48812556", "0.48797923", "0.48549375", "0.47794652", "0.47729024", "0.47388643", "0.47244483", "0.4720166", "0.4683753", "0.46482006", "0.46386418", "0.4630596", "0.46139523", "0.45714936", "0.45633712", "...
0.5148379
3
Test a successful query over TCP
func TestAccept(t *testing.T) { doh := newFakeTransport() client, server := makePair() // Start the forwarder running. go Accept(doh, server) lbuf := make([]byte, 2) // Send Query queryData := simpleQueryBytes binary.BigEndian.PutUint16(lbuf, uint16(len(queryData))) n, err := client.Write(lbuf) if err != nil { t.Fatal(err) } if n != 2 { t.Error("Length write problem") } n, err = client.Write(queryData) if err != nil { t.Fatal(err) } if n != len(queryData) { t.Error("Query write problem") } // Read query queryRead := <-doh.query if !bytes.Equal(queryRead, queryData) { t.Error("Query mismatch") } // Send fake response responseData := []byte{1, 2, 8, 9, 10} doh.response <- responseData // Get Response n, err = client.Read(lbuf) if err != nil { t.Fatal(err) } if n != 2 { t.Error("Length read problem") } rlen := binary.BigEndian.Uint16(lbuf) resp := make([]byte, int(rlen)) n, err = client.Read(resp) if err != nil { t.Fatal(err) } if !bytes.Equal(responseData, resp) { t.Error("Response mismatch") } client.Close() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (my *MySQL) Ping() (err os.Error) {\n defer my.unlock()\n defer catchOsError(&err)\n my.lock()\n\n if my.conn == nil {\n return NOT_CONN_ERROR\n }\n if my.unreaded_rows {\n return UNREADED_ROWS_ERROR\n }\n\n // Send command\n my.sendCmd(_COM_PING)\n // Get server re...
[ "0.61619914", "0.61236", "0.6005466", "0.5846167", "0.58428293", "0.58305943", "0.57885176", "0.5739293", "0.56987995", "0.5646071", "0.5617517", "0.5611779", "0.56109595", "0.55873877", "0.55506074", "0.55271316", "0.5510483", "0.5507143", "0.5506634", "0.54904956", "0.54569...
0.5318429
33
Sends a TCP query that results in failure. When a query fails, Accept should close the TCP socket.
func TestAcceptFail(t *testing.T) { doh := newFakeTransport() client, server := makePair() // Start the forwarder running. go Accept(doh, server) lbuf := make([]byte, 2) // Send Query queryData := simpleQueryBytes binary.BigEndian.PutUint16(lbuf, uint16(len(queryData))) client.Write(lbuf) client.Write(queryData) // Indicate that the query failed doh.err = errors.New("fake error") // Read query queryRead := <-doh.query if !bytes.Equal(queryRead, queryData) { t.Error("Query mismatch") } // Accept should have closed the socket. n, _ := client.Read(lbuf) if n != 0 { t.Error("Expected to read 0 bytes") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func WaitForTCP(ctx context.Context, rAddr string) error {\n\tdialer := net.Dialer{}\n\tconn, err := dialer.DialContext(ctx, \"tcp\", rAddr)\n\t//For loop to get around OS Dial Timeout\n\tfor err != nil {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tdefault:\n\t\t}\n\t\tconn, err = dialer.Dia...
[ "0.5549525", "0.55408275", "0.53043896", "0.528792", "0.52191246", "0.5194476", "0.5182247", "0.517237", "0.50538695", "0.4971472", "0.49563774", "0.49338162", "0.49332836", "0.49071816", "0.4888864", "0.48753402", "0.486269", "0.4854261", "0.48495227", "0.48452085", "0.48272...
0.62287647
0
Sends a TCP query, and closes the socket before the response is sent. This tests for crashes when a response cannot be delivered.
func TestAcceptClose(t *testing.T) { doh := newFakeTransport() client, server := makePair() // Start the forwarder running. go Accept(doh, server) lbuf := make([]byte, 2) // Send Query queryData := simpleQueryBytes binary.BigEndian.PutUint16(lbuf, uint16(len(queryData))) client.Write(lbuf) client.Write(queryData) // Read query queryRead := <-doh.query if !bytes.Equal(queryRead, queryData) { t.Error("Query mismatch") } // Close the TCP connection client.Close() // Send fake response too late. responseData := []byte{1, 2, 8, 9, 10} doh.response <- responseData }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func echo(conn net.Conn){\n defer conn.Close()\n bData, _ := recvDataB(conn)\n sendDataB(conn, bData, OK_CODE)\n}", "func (c Client) SendQuery(message dns.Msg) (dns.Msg, error) {\n\t// Open a new QUIC stream\n\tlog.Debugln(\"opening new quic stream\")\n\tstream, err := c.Session.OpenStream()\n\tif err != nil ...
[ "0.58487767", "0.55408037", "0.54952556", "0.54832953", "0.54605734", "0.5419732", "0.5407065", "0.5375777", "0.53394234", "0.52898824", "0.5242137", "0.52413064", "0.52413064", "0.5237375", "0.5227795", "0.52071977", "0.51766586", "0.5172305", "0.5154059", "0.5132827", "0.51...
0.58927166
0
Test failure due to a response that is larger than the maximum message size for DNS over TCP (65535).
func TestAcceptOversize(t *testing.T) { doh := newFakeTransport() client, server := makePair() // Start the forwarder running. go Accept(doh, server) lbuf := make([]byte, 2) // Send Query queryData := simpleQueryBytes binary.BigEndian.PutUint16(lbuf, uint16(len(queryData))) client.Write(lbuf) client.Write(queryData) // Read query <-doh.query // Send oversize response doh.response <- make([]byte, 65536) // Accept should have closed the socket because the response // cannot be written. n, _ := client.Read(lbuf) if n != 0 { t.Error("Expected to read 0 bytes") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func isPacketTooBig(err error) bool {\n\treturn false\n}", "func TestMalformedPacket(t *testing.T) {\n\t// copied as bytes from Wireshark, then modified the RelayMessage option length\n\tbytes := []byte{\n\t\t0x0c, 0x00, 0x24, 0x01, 0xdb, 0x00, 0x30, 0x10, 0xb0, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t\t0x0...
[ "0.61080605", "0.57464087", "0.5693387", "0.5656182", "0.5621133", "0.5612451", "0.56082", "0.55885124", "0.5567672", "0.5557804", "0.5530482", "0.5529525", "0.54606605", "0.54481703", "0.54177463", "0.54153514", "0.540712", "0.539885", "0.5369703", "0.5310614", "0.5308976", ...
0.54559296
13
Check that packing |compressedQueryBytes| constructs the same query byteforbyte.
func TestDnsMessageCompressedQueryConfidenceCheck(t *testing.T) { m := mustUnpack(compressedQueryBytes) packedBytes := mustPack(m) if len(packedBytes) != len(compressedQueryBytes) { t.Errorf("Packed query has different size than original:\n %v\n %v", packedBytes, compressedQueryBytes) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestDnsMessageUncompressedQueryConfidenceCheck(t *testing.T) {\n\tm := mustUnpack(uncompressedQueryBytes)\n\tpackedBytes := mustPack(m)\n\tif len(packedBytes) >= len(uncompressedQueryBytes) {\n\t\tt.Errorf(\"Compressed query is not smaller than uncompressed query\")\n\t}\n}", "func (q *CompoundQuery) GetCom...
[ "0.68890274", "0.57353276", "0.5696035", "0.5437959", "0.54121333", "0.537639", "0.5337406", "0.5200456", "0.51706797", "0.5057195", "0.5042812", "0.49630687", "0.4941367", "0.49219006", "0.4919686", "0.49029464", "0.48985067", "0.4887714", "0.48703045", "0.4842406", "0.48307...
0.71391696
0
Check that packing |uncompressedQueryBytes| constructs a smaller query byteforbyte, since label compression is enabled by default.
func TestDnsMessageUncompressedQueryConfidenceCheck(t *testing.T) { m := mustUnpack(uncompressedQueryBytes) packedBytes := mustPack(m) if len(packedBytes) >= len(uncompressedQueryBytes) { t.Errorf("Compressed query is not smaller than uncompressed query") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestDnsMessageCompressedQueryConfidenceCheck(t *testing.T) {\n\tm := mustUnpack(compressedQueryBytes)\n\tpackedBytes := mustPack(m)\n\tif len(packedBytes) != len(compressedQueryBytes) {\n\t\tt.Errorf(\"Packed query has different size than original:\\n %v\\n %v\", packedBytes, compressedQueryBytes)\n\t}\n}",...
[ "0.6823946", "0.53564346", "0.51485986", "0.5139452", "0.50640583", "0.5022969", "0.49374676", "0.4916851", "0.48699605", "0.4850243", "0.48246896", "0.48079136", "0.4799034", "0.4767999", "0.47604385", "0.47575718", "0.4742403", "0.47369084", "0.47271678", "0.47015467", "0.4...
0.721547
0
Check that we correctly pad an uncompressed query to the nearest block.
func TestAddEdnsPaddingUncompressedQuery(t *testing.T) { if len(uncompressedQueryBytes)%PaddingBlockSize == 0 { t.Errorf("uncompressedQueryBytes does not require padding, so this test is invalid") } padded, err := AddEdnsPadding(uncompressedQueryBytes) if err != nil { panic(err) } if len(padded)%PaddingBlockSize != 0 { t.Errorf("AddEdnsPadding failed to correctly pad uncompressed query") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestDnsMessageUncompressedQueryConfidenceCheck(t *testing.T) {\n\tm := mustUnpack(uncompressedQueryBytes)\n\tpackedBytes := mustPack(m)\n\tif len(packedBytes) >= len(uncompressedQueryBytes) {\n\t\tt.Errorf(\"Compressed query is not smaller than uncompressed query\")\n\t}\n}", "func TestDnsMessageCompressedQ...
[ "0.625556", "0.5852425", "0.5724083", "0.5428828", "0.526153", "0.51679826", "0.51656187", "0.5112957", "0.505683", "0.48105946", "0.4784534", "0.4780916", "0.47005382", "0.46983063", "0.4685418", "0.466283", "0.46618646", "0.4618533", "0.45821616", "0.45800024", "0.45759624"...
0.60605675
1
Check that we correctly pad a compressed query to the nearest block.
func TestAddEdnsPaddingCompressedQuery(t *testing.T) { if len(compressedQueryBytes)%PaddingBlockSize == 0 { t.Errorf("compressedQueryBytes does not require padding, so this test is invalid") } padded, err := AddEdnsPadding(compressedQueryBytes) if err != nil { panic(err) } if len(padded)%PaddingBlockSize != 0 { t.Errorf("AddEdnsPadding failed to correctly pad compressed query") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestDnsMessageCompressedQueryConfidenceCheck(t *testing.T) {\n\tm := mustUnpack(compressedQueryBytes)\n\tpackedBytes := mustPack(m)\n\tif len(packedBytes) != len(compressedQueryBytes) {\n\t\tt.Errorf(\"Packed query has different size than original:\\n %v\\n %v\", packedBytes, compressedQueryBytes)\n\t}\n}",...
[ "0.6187572", "0.6138", "0.5824444", "0.5796465", "0.56046355", "0.5274121", "0.51186985", "0.5001094", "0.49921867", "0.49766874", "0.49304855", "0.49192142", "0.49119055", "0.4871706", "0.47838402", "0.47368175", "0.4720097", "0.47121912", "0.46999508", "0.46996126", "0.4683...
0.6087205
2
Try to pad a query that already contains an OPT record, but no padding option.
func TestAddEdnsPaddingCompressedOptQuery(t *testing.T) { optQuery := simpleQuery optQuery.Additionals = make([]dnsmessage.Resource, len(simpleQuery.Additionals)) copy(optQuery.Additionals, simpleQuery.Additionals) optQuery.Additionals = append(optQuery.Additionals, dnsmessage.Resource{ Header: dnsmessage.ResourceHeader{ Name: dnsmessage.MustNewName("."), Class: dnsmessage.ClassINET, TTL: 0, }, Body: &dnsmessage.OPTResource{ Options: []dnsmessage.Option{}, }, }, ) paddedOnWire, err := AddEdnsPadding(mustPack(&optQuery)) if err != nil { t.Errorf("Failed to pad query with OPT but no padding: %v", err) } if len(paddedOnWire)%PaddingBlockSize != 0 { t.Errorf("AddEdnsPadding failed to correctly pad query with OPT but no padding") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func pad(unpadded []byte, desiredLength int) []byte {\n\tif len(unpadded) == desiredLength {\n\t\treturn unpadded\n\t}\n\ttoAppend := desiredLength - len(unpadded)\n\treturn append(unpadded, bytes.Repeat([]byte{byte(0x00)}, toAppend)...)\n}", "func WithPaddingAllowed() ParserOption {\n\treturn func(p *Parser) {\...
[ "0.5929429", "0.56697994", "0.5376924", "0.5368815", "0.5289138", "0.523237", "0.5228269", "0.5175912", "0.5130749", "0.5128292", "0.51032317", "0.5100639", "0.5078234", "0.50763285", "0.5069053", "0.50648904", "0.5044292", "0.50086397", "0.49749118", "0.4940589", "0.48642007...
0.60436326
0
Try to pad a query that already contains an OPT record with padding. The query should be unmodified by AddEdnsPadding.
func TestAddEdnsPaddingCompressedPaddedQuery(t *testing.T) { paddedQuery := simpleQuery paddedQuery.Additionals = make([]dnsmessage.Resource, len(simpleQuery.Additionals)) copy(paddedQuery.Additionals, simpleQuery.Additionals) paddedQuery.Additionals = append(paddedQuery.Additionals, dnsmessage.Resource{ Header: dnsmessage.ResourceHeader{ Name: dnsmessage.MustNewName("."), Class: dnsmessage.ClassINET, TTL: 0, }, Body: &dnsmessage.OPTResource{ Options: []dnsmessage.Option{ { Code: OptResourcePaddingCode, Data: make([]byte, 5), }, }, }, }, ) originalOnWire := mustPack(&paddedQuery) paddedOnWire, err := AddEdnsPadding(mustPack(&paddedQuery)) if err != nil { t.Errorf("Failed to pad padded query: %v", err) } if !bytes.Equal(originalOnWire, paddedOnWire) { t.Errorf("AddEdnsPadding tampered with a query that was already padded") } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestAddEdnsPaddingCompressedOptQuery(t *testing.T) {\n\toptQuery := simpleQuery\n\toptQuery.Additionals = make([]dnsmessage.Resource, len(simpleQuery.Additionals))\n\tcopy(optQuery.Additionals, simpleQuery.Additionals)\n\n\toptQuery.Additionals = append(optQuery.Additionals,\n\t\tdnsmessage.Resource{\n\t\t\tH...
[ "0.65444535", "0.58884513", "0.5867946", "0.57902974", "0.5498424", "0.54974675", "0.54956174", "0.5449674", "0.54282355", "0.5364954", "0.5342457", "0.5313182", "0.52898765", "0.5234249", "0.52095866", "0.5208116", "0.5151577", "0.50245225", "0.49983007", "0.49957857", "0.49...
0.609781
1
ReadResponse reads a server response into the received o.
func (o *ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { switch response.Code() { case 200: result := NewProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetOK() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil case 422: result := NewProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity() if err := result.readResponse(response, consumer, o.formats); err != nil { return nil, err } return result, nil default: data, err := ioutil.ReadAll(response.Body()) if err != nil { return nil, err } return nil, fmt.Errorf("Requested GET /game-telemetry/v1/protected/steamIds/{steamId}/playtime returns an error %d: %s", response.Code(), string(data)) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *ResourceHandler) ReadResponse(dataOut unsafe.Pointer, bytesToRead int32, bytesRead *int32, callback *Callback) int32 {\n\treturn lookupResourceHandlerProxy(d.Base()).ReadResponse(d, dataOut, bytesToRead, bytesRead, callback)\n}", "func (o *GetServerReader) ReadResponse(response runtime.ClientResponse, c...
[ "0.7641552", "0.760927", "0.7521922", "0.750983", "0.74814624", "0.74742043", "0.74354094", "0.74259144", "0.73762655", "0.73685175", "0.7360411", "0.73561996", "0.73510104", "0.73482704", "0.734754", "0.73415536", "0.73377526", "0.7324228", "0.73168004", "0.7316417", "0.7311...
0.0
-1
NewProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetOK creates a ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetOK with default headers values
func NewProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetOK() *ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetOK { return &ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetOK{} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity() *ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity {\n\treturn &ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity{}\n}", "func (o *Pr...
[ "0.52899104", "0.447495", "0.4440635", "0.44148892", "0.4270405", "0.42306632", "0.42255187", "0.42208046", "0.41822582", "0.41728333", "0.41548944", "0.4154055", "0.4148511", "0.41375974", "0.41100857", "0.41024846", "0.40931123", "0.4068021", "0.40467957", "0.4037121", "0.4...
0.7406249
0
NewProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity creates a ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity with default headers values
func NewProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity() *ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity { return &ProtectedGetPlaytimeGameTelemetryV1ProtectedSteamIdsSteamIDPlaytimeGetUnprocessableEntity{} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewGetTaskDetailsUnprocessableEntity() *GetTaskDetailsUnprocessableEntity {\n\n\treturn &GetTaskDetailsUnprocessableEntity{}\n}", "func NewGetAPIPublicV1TeamUnprocessableEntity() *GetAPIPublicV1TeamUnprocessableEntity {\n\treturn &GetAPIPublicV1TeamUnprocessableEntity{}\n}", "func NewWeaviateKeyCreateUnpr...
[ "0.5650617", "0.5636281", "0.54643387", "0.5256545", "0.5237649", "0.5215986", "0.5137212", "0.5104093", "0.5101223", "0.4990614", "0.49280345", "0.48145685", "0.48031926", "0.47842333", "0.47759265", "0.4742333", "0.4735349", "0.46556872", "0.46432883", "0.46251956", "0.4601...
0.7384049
0
NewPaddingTLV creates a new padding TLV
func NewPaddingTLV(length uint8) *PaddingTLV { return &PaddingTLV{ TLVType: PaddingType, TLVLength: length, PaddingData: make([]byte, length), } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *PaddingTLV) Length() uint8 {\n\treturn p.TLVLength\n}", "func pad(unpadded []byte, desiredLength int) []byte {\n\tif len(unpadded) == desiredLength {\n\t\treturn unpadded\n\t}\n\ttoAppend := desiredLength - len(unpadded)\n\treturn append(unpadded, bytes.Repeat([]byte{byte(0x00)}, toAppend)...)\n}", "f...
[ "0.5740221", "0.56109005", "0.5459555", "0.5429105", "0.5415254", "0.526596", "0.52202696", "0.5168666", "0.50730824", "0.49269283", "0.49154794", "0.49023673", "0.48499796", "0.48332152", "0.48277208", "0.48276848", "0.47980988", "0.47889626", "0.4785528", "0.47746792", "0.4...
0.7591314
0
Type gets the type of the TLV
func (p *PaddingTLV) Type() uint8 { return p.TLVType }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t TLVHead) Type() TLVType {\n\treturn t.TLVType\n}", "func (b *Block) Type() uint32 {\n\treturn b.tlvType\n}", "func (bs endecBytes) Type() byte {\n\treturn bs[0] >> 4\n}", "func (b *Block) Type() string {\n\ttypeNameObj := b.typeName.content.(*identifier)\n\treturn string(typeNameObj.token.Bytes)\n}",...
[ "0.7792124", "0.7596322", "0.67068475", "0.66240877", "0.65851456", "0.65079874", "0.6467992", "0.6432543", "0.6431359", "0.6421504", "0.6419574", "0.6413628", "0.64031136", "0.6390112", "0.6384129", "0.636459", "0.6359154", "0.635645", "0.6353648", "0.634136", "0.6336353", ...
0.6860522
2
Length gets the length of the TLV
func (p *PaddingTLV) Length() uint8 { return p.TLVLength }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (a *AdditionalGUTI) GetLen() (len uint16) {}", "func (h *ExtendedHeader) GetLength(_ protocol.VersionNumber) protocol.ByteCount {\n\tlength := 1 /* type byte */ + 4 /* version */ + 1 /* dest conn ID len */ + protocol.ByteCount(h.DestConnectionID.Len()) + 1 /* src conn ID len */ + protocol.ByteCount(h.SrcCon...
[ "0.7318795", "0.7001363", "0.6942401", "0.6891273", "0.6878425", "0.68543977", "0.6744803", "0.6739835", "0.6715174", "0.67149013", "0.6713755", "0.66523576", "0.66506857", "0.66475517", "0.6636951", "0.6624504", "0.65799433", "0.6557597", "0.65531355", "0.65423506", "0.65261...
0.7524238
0
Value gets the TLV itself
func (p *PaddingTLV) Value() interface{} { return p }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *SmppTlv) GetValue() string {\n\tif o == nil || o.Value == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Value\n}", "func (o ThingTypeTagOutput) Value() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ThingTypeTag) string { return v.Value }).(pulumi.StringOutput)\n}", "func (b *baseSemant...
[ "0.71718717", "0.6518982", "0.6511803", "0.63563395", "0.6336774", "0.63253427", "0.62726206", "0.62723505", "0.6252216", "0.62233454", "0.6198178", "0.61777335", "0.6150266", "0.6144369", "0.61414146", "0.6107172", "0.6098916", "0.6090685", "0.6087054", "0.6082909", "0.60711...
0.69627863
1
Serialize serializes a padding TLV
func (p *PaddingTLV) Serialize(buf *bytes.Buffer) { buf.WriteByte(p.TLVType) buf.WriteByte(p.TLVLength) buf.Write(p.PaddingData) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *PaddingTLV) Length() uint8 {\n\treturn p.TLVLength\n}", "func NewPaddingTLV(length uint8) *PaddingTLV {\n\treturn &PaddingTLV{\n\t\tTLVType: PaddingType,\n\t\tTLVLength: length,\n\t\tPaddingData: make([]byte, length),\n\t}\n}", "func (g *GroupedAVP) Padding() int {\n\treturn 0\n}", "func getPa...
[ "0.5785339", "0.5553274", "0.5451155", "0.5364017", "0.5321094", "0.52745724", "0.5261391", "0.52536887", "0.5251995", "0.52181494", "0.5216098", "0.5210108", "0.520552", "0.5186594", "0.5163753", "0.50572926", "0.50076044", "0.49867326", "0.4979345", "0.49656087", "0.4959786...
0.76584166
0
Injectors from injector.go: Build
func Build() (*chi.Mux, func(), error) { logrusLogger, cleanup, err := logger.Provider() if err != nil { return nil, nil, err } opentracingTracer, cleanup2, err := tracer.Provider(logrusLogger) if err != nil { cleanup() return nil, nil, err } serverHandler, cleanup3, err := handlers.Provider(logrusLogger) if err != nil { cleanup2() cleanup() return nil, nil, err } mux, cleanup4, err := Provider(logrusLogger, opentracingTracer, serverHandler) if err != nil { cleanup3() cleanup2() cleanup() return nil, nil, err } return mux, func() { cleanup4() cleanup3() cleanup2() cleanup() }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Inject(builder ConfigBuilder) {\n\n\t//load the env into the object\n\tbuilder.SetEnvConfigs()\n\n\t//setup dynamo library\n\tdynamoClient := builder.SetDynamoDBConfigsAndBuild()\n\t//connect to the instance\n\tlog.Println(\"Connecting to dynamo client\")\n\tdynamoClient.DefaultConnect()\n\n\t//dependency inj...
[ "0.6409702", "0.62989783", "0.6237891", "0.6081254", "0.5925314", "0.5865492", "0.5862993", "0.5773957", "0.57736605", "0.56715137", "0.5591116", "0.5471734", "0.54399365", "0.5416204", "0.53920984", "0.5386215", "0.537239", "0.5371537", "0.536091", "0.5348586", "0.5323686", ...
0.5705451
9
AFunc1In calls the stored function 'a_bit_of_everything.a_func_1_in(number) number' on db.
func AFunc1In(ctx context.Context, db DB, aParam int64) (int64, error) { // call a_bit_of_everything.a_func_1_in const sqlstr = `SELECT a_bit_of_everything.a_func_1_in(:1) FROM dual` // run var r0 int64 logf(sqlstr, aParam) if err := db.QueryRowContext(ctx, sqlstr, aParam).Scan(&r0); err != nil { return 0, logerror(err) } return r0, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func A1In1Out(ctx context.Context, db DB, aParam int) (int, error) {\n\t// At the moment, the Go MySQL driver does not support stored procedures\n\t// with out parameters\n\treturn 0, fmt.Errorf(\"unsupported\")\n}", "func FuncIn() {\n\tsimlog.FuncIn()\n}", "func (l *logger) FuncIn() {\n\tif !l.isDebug {\n\t\t...
[ "0.59811527", "0.5737294", "0.5608908", "0.542825", "0.52071387", "0.50139046", "0.5005405", "0.49846172", "0.49317142", "0.49308378", "0.48855373", "0.48657376", "0.4847981", "0.48454347", "0.48078746", "0.48072076", "0.47299212", "0.47262934", "0.47253907", "0.47093183", "0...
0.86705595
0
XXH64 returns new hash.Hash64
func XXH64(seed uint64) hash.Hash64 { d := &digest64{seed: seed, buf: new(bytes.Buffer)} d.Reset() return d }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *XXHash64) Hash(data []byte) uint64 {\n\tend := len(data)\n\tvar h64 uint64\n\tn := 0\n\n\tif end >= 32 {\n\t\tend32 := end - 32\n\t\tv1 := this.seed + _XXHASH_PRIME64_1 + _XXHASH_PRIME64_2\n\t\tv2 := this.seed + _XXHASH_PRIME64_2\n\t\tv3 := this.seed\n\t\tv4 := this.seed - _XXHASH_PRIME64_1\n\n\t\tfor ...
[ "0.708379", "0.6949178", "0.6914841", "0.6849021", "0.6677332", "0.66591746", "0.664148", "0.65541524", "0.6538839", "0.64558864", "0.64174473", "0.6362205", "0.6334637", "0.6288086", "0.6278777", "0.62381715", "0.6187761", "0.6118733", "0.6098435", "0.6039612", "0.603536", ...
0.7710503
0
Attack implements the brokenrsa method against ciphertext in multiple keys.
func Attack(ks []*keys.RSA, ch chan error) { k := ks[0] if k.CipherText == nil { ch <- fmt.Errorf("invalid arguments for attack %s: this attack requires the ciphertext", name) return } d, u, _ := ln.XGCD(k.Key.PublicKey.E, k.Key.N) if !d.Equals(ln.BigOne) { ch <- fmt.Errorf("n and e were not coprime so %s attack will not work: GCE(e,n) == %v", name, d) return } ct := ln.BytesToNumber(k.CipherText) pt := new(fmp.Fmpz).Mul(ct, u) k.PlainText = ln.NumberToBytes(pt.Mod(pt, k.Key.N)) ch <- nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestChallenge12(test *testing.T) {\n\t// Feed identical bytes of your-string to the function 1 at a time --- start with 1 byte (\"A\"),\n\t// then \"AA\", then \"AAA\" and so on. Discover the block size of the cipher. You know it, but do this step anyway.\n\toracle := challenge12Oracle{key(16)}\n\tblockSize, ...
[ "0.53970337", "0.5308709", "0.52447593", "0.5208022", "0.5136759", "0.5136451", "0.5077559", "0.5055551", "0.50317246", "0.49933606", "0.4976835", "0.49750414", "0.49339533", "0.4925139", "0.49096018", "0.48946983", "0.48878032", "0.4884183", "0.48840725", "0.4876813", "0.486...
0.67120165
0
NewConfig returns an empty ServerConfigBuilder.
func NewConfig() ServerConfigBuilder { return &serverConfig{} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func newConfigServer() *ConfigServer {\n\treturn &ConfigServer{}\n}", "func newConfig() *Config {\n\treturn &Config{\n\t\tgeneral{\n\t\t\tVerbose: false,\n\t\t},\n\t\tserver{\n\t\t\tType: \"http\",\n\t\t\tHost: \"0.0.0.0\",\n\t\t},\n\t\tmongo{\n\t\t\tHost: \"0.0.0.0:27017\",\n\t\t\tDatabase: \"etlog\",\n...
[ "0.714636", "0.6788078", "0.672954", "0.671221", "0.64953154", "0.6477215", "0.63846946", "0.6384149", "0.6354265", "0.6305003", "0.6282221", "0.6247137", "0.6234308", "0.622695", "0.61695105", "0.61501217", "0.61187845", "0.6103186", "0.60942477", "0.60919195", "0.60896236",...
0.7364699
0
SetHost accepts a string in the form of and sets this as URL in serverConfig.
func (co *serverConfig) SetURL(URL string) ServerConfigBuilder { co.URL = URL return co }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (_this *URL) SetHost(value string) {\n\tinput := value\n\t_this.Value_JS.Set(\"host\", input)\n}", "func SetHost(v string) {\n\traw.Host = v\n}", "func (b *Binary) SetHost(host string) {\n\tif host == \"\" {\n\t\treturn\n\t}\n\tu, err := url.Parse(host)\n\tif err != nil {\n\t\treturn\n\t}\n\tu.Path = b.ur...
[ "0.77516806", "0.7434453", "0.7432567", "0.7276324", "0.71877426", "0.6935025", "0.68915313", "0.6835565", "0.67834437", "0.6763738", "0.6760979", "0.67476106", "0.67438185", "0.6711807", "0.66517454", "0.66216093", "0.6601068", "0.6472164", "0.64509356", "0.64432657", "0.643...
0.0
-1
SetHost accepts an int and sets the retry count.
func (co *serverConfig) SetRetry(r int) ServerConfigBuilder { co.Retry = r return co }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *BaseClient) SetRetry(value int) {\n\tclient.retry = value\n}", "func (m *DeviceHealthAttestationState) SetRestartCount(value *int64)() {\n err := m.GetBackingStore().Set(\"restartCount\", value)\n if err != nil {\n panic(err)\n }\n}", "func (wp *WorkerPool[T]) SetNumShards(numShar...
[ "0.56200206", "0.55528766", "0.5400684", "0.517109", "0.5157865", "0.51496375", "0.5104901", "0.5081008", "0.50627774", "0.5058947", "0.50475997", "0.5022949", "0.49496228", "0.49336797", "0.4874195", "0.48509568", "0.4837097", "0.4823085", "0.48207945", "0.48175836", "0.4788...
0.52591467
3
SetRetryWaitTime accepts an int and sets retry wait time in seconds.
func (co *serverConfig) SetRetryWaitTime(t int) ServerConfigBuilder { co.RetryWaitTime = time.Duration(t) * time.Second return co }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Client) SetMaxRetryWait(retryWait time.Duration) {\n\tc.modifyLock.RLock()\n\tdefer c.modifyLock.RUnlock()\n\tc.config.modifyLock.Lock()\n\tdefer c.config.modifyLock.Unlock()\n\n\tc.config.MaxRetryWait = retryWait\n}", "func SetRetrySeconds(retrySeconds int8) Option {\n\treturn func(s *Scraper) Option {...
[ "0.6929946", "0.67542446", "0.6693405", "0.6526574", "0.6397074", "0.63898647", "0.6365026", "0.6311", "0.6271505", "0.6238838", "0.6207614", "0.61254764", "0.60295117", "0.6028012", "0.6021742", "0.5974879", "0.5930354", "0.59214675", "0.5837585", "0.5833836", "0.57983696", ...
0.83682585
0
Build method returns a serverConfig struct.
func (co *serverConfig) Build() serverConfig { return serverConfig{ URL: co.URL, Retry: co.Retry, RetryWaitTime: co.RetryWaitTime, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *TLSConfig) BuildServerConfig(host string) *tls.Config {\n\tif c == nil {\n\t\t// use default TLS settings, if config is empty.\n\t\treturn &tls.Config{\n\t\t\tServerName: host,\n\t\t\tInsecureSkipVerify: true,\n\t\t\tVerifyConnection: makeVerifyServerConnection(&TLSConfig{\n\t\t\t\tVerification: V...
[ "0.66880894", "0.6239105", "0.61657727", "0.6142114", "0.60939157", "0.6093432", "0.5998546", "0.59107727", "0.5907868", "0.5894315", "0.5862838", "0.5836971", "0.582672", "0.57969505", "0.57863814", "0.5756004", "0.5753981", "0.5732995", "0.57201874", "0.56668013", "0.565264...
0.7297781
0
NewClient returns Singularity HTTP endpoint.
func NewClient(c serverConfig) *Client { r := resty.New(). SetRESTMode(). SetRetryCount(c.Retry). SetRetryWaitTime(c.RetryWaitTime). SetHostURL(c.URL). AddRetryCondition( // Condition function will be provided with *resty.Response as a // parameter. It is expected to return (bool, error) pair. Resty will retry // in case condition returns true or non nil error. func(r *resty.Response) (bool, error) { return r.StatusCode() == http.StatusNotFound, nil }, ) return &Client{ Rest: r, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func New(httpClient *http.Client, config Config) (*Client, error) {\n\tc := NewClient(httpClient)\n\tc.Config = config\n\n\tbaseURL, err := url.Parse(\"https://\" + config.Host)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.BaseURL = baseURL\n\treturn c, nil\n}", "func New(endpoint string) *Client {\n\tr...
[ "0.7146831", "0.7028338", "0.701566", "0.69679964", "0.69676816", "0.6900288", "0.6884137", "0.68382514", "0.68368256", "0.68338436", "0.6792138", "0.6765314", "0.6765314", "0.67554337", "0.67366046", "0.67330617", "0.66954935", "0.6687802", "0.66775715", "0.66609675", "0.665...
0.0
-1
/ Get ProtectedEntity for Persistent Volume referenced by this PVC ProtectedEntity. Candidates are, IVD ProtectedEntity(nonGuestCluster) and ParaVirt ProtectedEntity(GuestCluster).
func (this PVCProtectedEntity) getProtectedEntityForPV(ctx context.Context, pv *core_v1.PersistentVolume) (astrolabe.ProtectedEntity, error) { if pv.Spec.CSI != nil { if pv.Spec.CSI.Driver == VSphereCSIProvisioner { if pv.Spec.AccessModes[0] == core_v1.ReadWriteOnce { var pvIDstr string if this.ppetm.isGuest { pvIDstr = pv.Name // use pv name rather than pv volume handle as the ID of paravirt PE, since it is easier to retrieve pv volume handle from pv name } else { pvIDstr = pv.Spec.CSI.VolumeHandle } pvPEType := this.getComponentPEType() pvPEID := astrolabe.NewProtectedEntityIDWithSnapshotID(pvPEType, pvIDstr, this.id.GetSnapshotID()) pvPE, err := this.ppetm.pem.GetProtectedEntity(ctx, pvPEID) if err != nil { return nil, errors.Wrapf(err, "Could not get Protected Entity for PV %s", pvPEID.String()) } return pvPE, nil } else { return nil, errors.Errorf("Unexpected access mode, %v, for Persistent Volume %s", pv.Spec.AccessModes[0], pv.Name) } } } return nil, errors.Errorf("Could not find PE for Persistent Volume %s", pv.Name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *StackEbrc) GetVolume(ref string) (*abstract.Volume, fail.Error) {\n\tlogrus.Debug(\"ebrc.Client.GetVolume() called\")\n\tdefer logrus.Debug(\"ebrc.Client.GetVolume() done\")\n\n\tvar volume abstract.Volume\n\n\t_, vdc, err := s.getOrgVdc()\n\tif err != nil {\n\t\treturn nil, fail.Wrap(err, fmt.Sprintf(\"E...
[ "0.5145643", "0.49404353", "0.48711714", "0.47512802", "0.47413394", "0.47331426", "0.47056416", "0.46269906", "0.4609255", "0.46007136", "0.45736876", "0.45705947", "0.45601365", "0.45379475", "0.45265597", "0.4504617", "0.44908112", "0.44778052", "0.4476148", "0.44699076", ...
0.6989835
0
RunTests executes the scorecard tests as configured
func (o Scorecard) RunTests(ctx context.Context) (testOutput v1alpha3.Test, err error) { err = o.TestRunner.Initialize(ctx) if err != nil { return testOutput, err } tests := o.selectTests() if len(tests) == 0 { return testOutput, nil } for _, test := range tests { result, err := o.TestRunner.RunTest(ctx, test) if err != nil { result = convertErrorToStatus(test.Name, err) } testOutput.Status.Results = append(testOutput.Status.Results, result.Results...) } if !o.SkipCleanup { err = o.TestRunner.Cleanup(ctx) if err != nil { return testOutput, err } } return testOutput, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o Scorecard) RunTests() (testOutput v1alpha2.ScorecardOutput, err error) {\n\ttests := selectTests(o.Selector, o.Config.Tests)\n\tif len(tests) == 0 {\n\t\tfmt.Println(\"no tests selected\")\n\t\treturn testOutput, err\n\t}\n\n\tbundleData, err := getBundleData(o.BundlePath)\n\tif err != nil {\n\t\treturn te...
[ "0.7847949", "0.7178379", "0.66959757", "0.6382603", "0.63654983", "0.63125676", "0.62624186", "0.6155679", "0.6062077", "0.6012515", "0.59727854", "0.59608316", "0.59560037", "0.594106", "0.59397423", "0.5924008", "0.59166163", "0.5908898", "0.5906732", "0.5884082", "0.58350...
0.79646385
0
selectTests applies an optionally passed selector expression against the configured set of tests, returning the selected tests
func (o Scorecard) selectTests() []Test { selected := make([]Test, 0) for _, test := range o.Config.Tests { if o.Selector.String() == "" || o.Selector.Matches(labels.Set(test.Labels)) { // TODO olm manifests check selected = append(selected, test) } } return selected }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func selectTests(selector labels.Selector, tests []Test) []Test {\n\n\tselected := make([]Test, 0)\n\n\tfor _, test := range tests {\n\t\tif selector.String() == \"\" || selector.Matches(labels.Set(test.Labels)) {\n\t\t\t// TODO olm manifests check\n\t\t\tselected = append(selected, test)\n\t\t}\n\t}\n\treturn sel...
[ "0.74813306", "0.7090248", "0.5607932", "0.5303558", "0.5094614", "0.5069643", "0.5042959", "0.50331104", "0.49627775", "0.49533433", "0.49461237", "0.48975343", "0.47849888", "0.4777621", "0.47751915", "0.47463155", "0.47339553", "0.46907428", "0.46764013", "0.46577954", "0....
0.7408755
1
Initialize sets up the bundle configmap for tests
func (r *PodTestRunner) Initialize(ctx context.Context) error { bundleData, err := r.getBundleData() if err != nil { return fmt.Errorf("error getting bundle data %w", err) } r.configMapName, err = r.CreateConfigMap(ctx, bundleData) if err != nil { return fmt.Errorf("error creating ConfigMap %w", err) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *PodTestRunner) Initialize(ctx context.Context) error {\n\tbundleData, err := r.getBundleData()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting bundle data %w\", err)\n\t}\n\n\tr.configMapName, err = r.CreateConfigMap(ctx, bundleData)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating Con...
[ "0.7311859", "0.6341264", "0.63236684", "0.6308758", "0.6293854", "0.6219397", "0.61819357", "0.6114997", "0.6113638", "0.61045194", "0.610196", "0.6097097", "0.60905164", "0.6058089", "0.6026225", "0.60097724", "0.60009825", "0.5987813", "0.59876114", "0.5987233", "0.5917201...
0.7322952
0
Cleanup deletes pods and configmap resources from this test run
func (r PodTestRunner) Cleanup(ctx context.Context) (err error) { err = r.deletePods(ctx, r.configMapName) if err != nil { return err } err = r.deleteConfigMap(ctx, r.configMapName) if err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r PodTestRunner) Cleanup(ctx context.Context) (err error) {\n\n\terr = r.deletePods(ctx, r.configMapName)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = r.deleteConfigMap(ctx, r.configMapName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (p *PodmanTestIntegration) Cleanup() {\n\tp.S...
[ "0.82490194", "0.7183337", "0.6963463", "0.6941537", "0.6897071", "0.6610021", "0.6599832", "0.6594847", "0.6564672", "0.6459518", "0.64580095", "0.6447388", "0.6432132", "0.6390202", "0.6367826", "0.636664", "0.63490593", "0.6323104", "0.62937874", "0.6286403", "0.62849927",...
0.8216792
1
RunTest executes a single test
func (r PodTestRunner) RunTest(ctx context.Context, test Test) (result *v1alpha3.TestStatus, err error) { // Create a Pod to run the test podDef := getPodDefinition(r.configMapName, test, r) pod, err := r.Client.CoreV1().Pods(r.Namespace).Create(ctx, podDef, metav1.CreateOptions{}) if err != nil { return result, err } err = r.waitForTestToComplete(ctx, pod) if err != nil { return result, err } result = r.getTestStatus(ctx, pod, test) return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestRun(t *testing.T) {\n\tRun()\n}", "func (m *Main) RunTest(name, command string, run func(t *Test) error) error {\n\tt := m.NewTest(name, command, run)\n\treturn t.Run()\n}", "func TestRunMain(t *testing.T) {\n\tmain()\n}", "func (envManager *TestEnvManager) RunTest(m runnable) (ret int) {\n\tdefer e...
[ "0.78072757", "0.74127185", "0.733165", "0.72698194", "0.72393966", "0.7207766", "0.70724136", "0.70590204", "0.69538665", "0.68821836", "0.68679804", "0.6842752", "0.6730383", "0.67301863", "0.6718925", "0.6653832", "0.66490334", "0.6636336", "0.662904", "0.6625863", "0.6613...
0.0
-1
RunTest executes a single test
func (r FakeTestRunner) RunTest(ctx context.Context, test Test) (result *v1alpha3.TestStatus, err error) { return r.TestStatus, r.Error }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestRun(t *testing.T) {\n\tRun()\n}", "func (m *Main) RunTest(name, command string, run func(t *Test) error) error {\n\tt := m.NewTest(name, command, run)\n\treturn t.Run()\n}", "func TestRunMain(t *testing.T) {\n\tmain()\n}", "func (envManager *TestEnvManager) RunTest(m runnable) (ret int) {\n\tdefer e...
[ "0.78072983", "0.7412214", "0.73320264", "0.72707105", "0.72383493", "0.7207434", "0.7073435", "0.7059288", "0.6953264", "0.68833536", "0.6867685", "0.6841037", "0.6731276", "0.67177874", "0.66537756", "0.664927", "0.6636479", "0.6629489", "0.6625154", "0.6613278", "0.6574058...
0.6729761
13
waitForTestToComplete waits for a fixed amount of time while checking for a test pod to complete
func (r PodTestRunner) waitForTestToComplete(ctx context.Context, p *v1.Pod) (err error) { podCheck := wait.ConditionFunc(func() (done bool, err error) { var tmp *v1.Pod tmp, err = r.Client.CoreV1().Pods(p.Namespace).Get(ctx, p.Name, metav1.GetOptions{}) if err != nil { return true, fmt.Errorf("error getting pod %s %w", p.Name, err) } if tmp.Status.Phase == v1.PodSucceeded || tmp.Status.Phase == v1.PodFailed { return true, nil } return false, nil }) err = wait.PollImmediateUntil(time.Duration(1*time.Second), podCheck, ctx.Done()) return err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r PodTestRunner) waitForTestToComplete(ctx context.Context, p *v1.Pod) (err error) {\n\n\tpodCheck := wait.ConditionFunc(func() (done bool, err error) {\n\t\tvar tmp *v1.Pod\n\t\ttmp, err = r.Client.CoreV1().Pods(p.Namespace).Get(ctx, p.Name, metav1.GetOptions{})\n\t\tif err != nil {\n\t\t\treturn true, fmt....
[ "0.7927179", "0.72653604", "0.6584559", "0.60880834", "0.6087988", "0.6062425", "0.5917469", "0.59123796", "0.59050435", "0.59032446", "0.58534753", "0.5846773", "0.5770013", "0.57408786", "0.57073563", "0.56853384", "0.56759846", "0.5669011", "0.56403846", "0.56218016", "0.5...
0.76772004
1
DelayDuration returns delay duration in a form of time.Duration.
func (o *Options) DelayDuration() time.Duration { return time.Second * time.Duration(o.Delay) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v RxDelay) Duration() time.Duration {\n\tswitch v {\n\tcase RX_DELAY_0, RX_DELAY_1:\n\t\treturn time.Second\n\tdefault:\n\t\treturn time.Duration(v) * time.Second\n\t}\n}", "func (d *Delay) TimeDuration() time.Duration {\n\treturn time.Duration(d.Duration*1000) * time.Millisecond\n}", "func (b *Backoff) ...
[ "0.79466355", "0.7600061", "0.6968741", "0.68646014", "0.68198526", "0.6818932", "0.6725045", "0.66359437", "0.66057986", "0.6569005", "0.6561068", "0.6546487", "0.6497679", "0.64850616", "0.6454614", "0.64448506", "0.64159924", "0.6401013", "0.6279634", "0.6225847", "0.61952...
0.78912795
1
Body packs job payload into binary payload.
func (i *Item) Body() []byte { return utils.AsBytes(i.Payload) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (enc *Enqueuer) BodyBytes() ([]byte, error) {\n\tvar body = map[string]string{\n\t\t\"account\": enc.account,\n\t\t\"repo\": enc.repo,\n\t\t\"ref\": enc.ref,\n\t\t\"bobfile\": enc.bobfile,\n\t}\n\tbodyBytes, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bodyBytes, nil...
[ "0.61125934", "0.6009258", "0.56471306", "0.55544174", "0.54946643", "0.54576397", "0.5440506", "0.5395753", "0.53928536", "0.5352864", "0.5337374", "0.5183572", "0.51288664", "0.51206577", "0.5100693", "0.5085167", "0.50795686", "0.50787616", "0.50787616", "0.5071958", "0.50...
0.50859964
15
Context packs job context (job, id) into binary payload. Not used in the sqs, MessageAttributes used instead
func (i *Item) Context() ([]byte, error) { ctx, err := json.Marshal( struct { ID string `json:"id"` Job string `json:"job"` Headers map[string][]string `json:"headers"` Pipeline string `json:"pipeline"` }{ID: i.Ident, Job: i.Job, Headers: i.Headers, Pipeline: i.Options.Pipeline}, ) if err != nil { return nil, err } return ctx, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func serialiseContextRaw(ctx context.Context) ([]byte, error) {\n\tif ctx == nil {\n\t\treturn nil, fmt.Errorf(\"Cannot serialise 'nil' context\")\n\t}\n\tmd := tryGetMetadata(ctx)\n\n\tif md == nil {\n\t\treturn nil, fmt.Errorf(\"No metadata in callstate\")\n\t}\n\tdata, err := proto.Marshal(md)\n\tif err != nil ...
[ "0.5882201", "0.5235766", "0.52184343", "0.5215826", "0.50911605", "0.5015357", "0.5003859", "0.4904247", "0.48560473", "0.4854567", "0.48491663", "0.48325953", "0.48104867", "0.48014134", "0.47813973", "0.4768167", "0.47045356", "0.46879327", "0.46729985", "0.46666056", "0.4...
0.63743937
0
Convert is file convert command
func Convert(c *cli.Context) { var wg sync.WaitGroup for _, path := range c.Args() { wg.Add(1) go func(p string) { defer wg.Done() writeFile(p) }(path) } wg.Wait() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func convertFile(path string, convBootstrap convArray, convAddresses convAddrs) error {\n\tin, err := os.Open(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Create a temp file to write the output to on success\n\tout, err := atomicfile.New(path, 0600)\n\tif err != nil {\n\t\tin.Close()\n\t\treturn err\n\t}\...
[ "0.67846465", "0.6675129", "0.63838804", "0.63182414", "0.62801427", "0.62730193", "0.61669016", "0.6140353", "0.6136235", "0.60967994", "0.6027835", "0.5972999", "0.5927276", "0.5762783", "0.565666", "0.56553465", "0.5606723", "0.5505648", "0.5443074", "0.54286844", "0.53785...
0.6845794
0
PopCount returns the population count (number of set bits) of x.
func Test17(x uint64) int { return int(pc[byte(x>>(0*8))] + pc[byte(x>>(1*8))] + pc[byte(x>>(2*8))] + pc[byte(x>>(3*8))] + pc[byte(x>>(4*8))] + pc[byte(x>>(5*8))] + pc[byte(x>>(6*8))] + pc[byte(x>>(7*8))]) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func PopCount(x uint64) int {\n\tvar c uint64\n\tfor i := 0; i < 64; i++ {\n\t\tc += (x >> i) & 1\n\t}\n\treturn int(c)\n}", "func popcnt(x uint64) int {\n\t// Code adapted from https://chessprogramming.wikispaces.com/Population+Count.\n\tx = x - ((x >> 1) & k1)\n\tx = (x & k2) + ((x >> 2) & k2)\n\tx = (x + (x >...
[ "0.85887784", "0.8507372", "0.84685475", "0.8449659", "0.843988", "0.843988", "0.8418389", "0.83115256", "0.8252126", "0.8202739", "0.81959707", "0.80563897", "0.80499727", "0.7954959", "0.7939985", "0.7730451", "0.77174306", "0.76712596", "0.7617381", "0.7527805", "0.7507031...
0.0
-1
check the first parameter, true if it wants only a Context check if the handler needs a Context , has the first parameter as type of Context it's usefuly in NewRoute inside route.go
func hasContextParam(handlerType reflect.Type) bool { //if the handler doesn't take arguments, false if handlerType.NumIn() == 0 { return false } //if the first argument is not a pointer, false p1 := handlerType.In(0) if p1.Kind() != reflect.Ptr { return false } //but if the first argument is a context, true if p1.Elem() == contextType { return true } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func hasContextAndRenderer(handlerType reflect.Type) bool {\n\n\t//first check if we have pass 2 arguments\n\tif handlerType.NumIn() < 2 {\n\t\treturn false\n\t}\n\n\tfirstParamIsContext := hasContextParam(handlerType)\n\n\t//the first argument/parameter is always context if exists otherwise it's only Renderer or ...
[ "0.7213183", "0.5509956", "0.5483808", "0.5468682", "0.5381114", "0.53599775", "0.53556824", "0.5326522", "0.5323669", "0.53084695", "0.5305011", "0.5259829", "0.52473307", "0.52404714", "0.52363706", "0.52258265", "0.5179706", "0.51651525", "0.5151531", "0.5140357", "0.50984...
0.76307327
0
check the first parameter, true if it wants only a Renderer
func hasRendererParam(handlerType reflect.Type) bool { //if the handler doesn't take arguments, false if handlerType.NumIn() == 0 { return false } //if the first argument is not a pointer, false p1 := handlerType.In(0) if p1.Kind() != reflect.Ptr { return false } //but if the first argument is a renderer, true if p1.Elem() == rendererType { return true } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func hasContextAndRenderer(handlerType reflect.Type) bool {\n\n\t//first check if we have pass 2 arguments\n\tif handlerType.NumIn() < 2 {\n\t\treturn false\n\t}\n\n\tfirstParamIsContext := hasContextParam(handlerType)\n\n\t//the first argument/parameter is always context if exists otherwise it's only Renderer or ...
[ "0.64195585", "0.6211272", "0.5952793", "0.5785611", "0.57511944", "0.5662539", "0.56310743", "0.56270677", "0.5563061", "0.5553207", "0.55048263", "0.55048263", "0.55043006", "0.5455274", "0.5440663", "0.54219353", "0.5395095", "0.5364567", "0.5228344", "0.52223676", "0.5192...
0.72854406
0
check if two parameters, true if it wants Context following by a Renderer
func hasContextAndRenderer(handlerType reflect.Type) bool { //first check if we have pass 2 arguments if handlerType.NumIn() < 2 { return false } firstParamIsContext := hasContextParam(handlerType) //the first argument/parameter is always context if exists otherwise it's only Renderer or ResponseWriter,Request. if firstParamIsContext == false { return false } p2 := handlerType.In(1) if p2.Kind() != reflect.Ptr { return false } //but if the first argument is a context, true if p2.Elem() == rendererType { return true } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func hasRendererParam(handlerType reflect.Type) bool {\n\t//if the handler doesn't take arguments, false\n\tif handlerType.NumIn() == 0 {\n\t\treturn false\n\t}\n\n\t//if the first argument is not a pointer, false\n\tp1 := handlerType.In(0)\n\tif p1.Kind() != reflect.Ptr {\n\t\treturn false\n\t}\n\t//but if the fi...
[ "0.5999429", "0.5965332", "0.57624316", "0.54819465", "0.53604686", "0.5321732", "0.52336234", "0.51454157", "0.50726795", "0.5054565", "0.50247794", "0.4973077", "0.49111223", "0.4891894", "0.48881614", "0.4885618", "0.48833802", "0.48631704", "0.48545897", "0.48403186", "0....
0.7145373
0
GetNerCustomizedSeaEcom invokes the alinlp.GetNerCustomizedSeaEcom API synchronously
func (client *Client) GetNerCustomizedSeaEcom(request *GetNerCustomizedSeaEcomRequest) (response *GetNerCustomizedSeaEcomResponse, err error) { response = CreateGetNerCustomizedSeaEcomResponse() err = client.DoAction(request, response) return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *Client) GetNerCustomizedSeaEcomWithCallback(request *GetNerCustomizedSeaEcomRequest, callback func(response *GetNerCustomizedSeaEcomResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *GetNerCustomizedSeaEcomResponse\n\t\tvar err ...
[ "0.7576879", "0.69949114", "0.6187827", "0.6112665", "0.50135446", "0.4806385", "0.46168134", "0.45960653", "0.45363542", "0.45080954", "0.44634172", "0.43717235", "0.43654612", "0.43571216", "0.43244952", "0.42791805", "0.42694405", "0.42490053", "0.42486668", "0.42294818", ...
0.7616816
0
GetNerCustomizedSeaEcomWithChan invokes the alinlp.GetNerCustomizedSeaEcom API asynchronously
func (client *Client) GetNerCustomizedSeaEcomWithChan(request *GetNerCustomizedSeaEcomRequest) (<-chan *GetNerCustomizedSeaEcomResponse, <-chan error) { responseChan := make(chan *GetNerCustomizedSeaEcomResponse, 1) errChan := make(chan error, 1) err := client.AddAsyncTask(func() { defer close(responseChan) defer close(errChan) response, err := client.GetNerCustomizedSeaEcom(request) if err != nil { errChan <- err } else { responseChan <- response } }) if err != nil { errChan <- err close(responseChan) close(errChan) } return responseChan, errChan }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *Client) GetNerCustomizedSeaEcomWithCallback(request *GetNerCustomizedSeaEcomRequest, callback func(response *GetNerCustomizedSeaEcomResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *GetNerCustomizedSeaEcomResponse\n\t\tvar err ...
[ "0.7701703", "0.64137083", "0.58868027", "0.55262583", "0.5286783", "0.52103513", "0.5023557", "0.501735", "0.4995522", "0.4890827", "0.48545292", "0.4846518", "0.48191816", "0.4794705", "0.47043338", "0.4639148", "0.46159783", "0.46019688", "0.45946375", "0.45439455", "0.451...
0.8141107
0
GetNerCustomizedSeaEcomWithCallback invokes the alinlp.GetNerCustomizedSeaEcom API asynchronously
func (client *Client) GetNerCustomizedSeaEcomWithCallback(request *GetNerCustomizedSeaEcomRequest, callback func(response *GetNerCustomizedSeaEcomResponse, err error)) <-chan int { result := make(chan int, 1) err := client.AddAsyncTask(func() { var response *GetNerCustomizedSeaEcomResponse var err error defer close(result) response, err = client.GetNerCustomizedSeaEcom(request) callback(response, err) result <- 1 }) if err != nil { defer close(result) callback(nil, err) result <- 0 } return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *Client) GetNerCustomizedSeaEcomWithChan(request *GetNerCustomizedSeaEcomRequest) (<-chan *GetNerCustomizedSeaEcomResponse, <-chan error) {\n\tresponseChan := make(chan *GetNerCustomizedSeaEcomResponse, 1)\n\terrChan := make(chan error, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tdefer close(respon...
[ "0.66507435", "0.6284932", "0.5937611", "0.547515", "0.5420296", "0.52048594", "0.51196504", "0.49444628", "0.49300382", "0.4908999", "0.48851317", "0.48516223", "0.4745386", "0.47324798", "0.4731915", "0.4646688", "0.46445283", "0.46423602", "0.45770156", "0.45028207", "0.45...
0.8188641
0
CreateGetNerCustomizedSeaEcomRequest creates a request to invoke GetNerCustomizedSeaEcom API
func CreateGetNerCustomizedSeaEcomRequest() (request *GetNerCustomizedSeaEcomRequest) { request = &GetNerCustomizedSeaEcomRequest{ RpcRequest: &requests.RpcRequest{}, } request.InitWithApiInfo("alinlp", "2020-06-29", "GetNerCustomizedSeaEcom", "alinlp", "openAPI") request.Method = requests.POST return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *Client) GetNerCustomizedSeaEcom(request *GetNerCustomizedSeaEcomRequest) (response *GetNerCustomizedSeaEcomResponse, err error) {\n\tresponse = CreateGetNerCustomizedSeaEcomResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func CreateGetNerCustomizedSeaEcomResponse() (response ...
[ "0.7064167", "0.68019885", "0.67888623", "0.6246826", "0.619077", "0.6190453", "0.5972899", "0.58737063", "0.5718027", "0.5634352", "0.5581408", "0.55074394", "0.54870504", "0.54577786", "0.5399441", "0.5375696", "0.53739506", "0.533545", "0.5314561", "0.5306372", "0.5286929"...
0.89601254
0
CreateGetNerCustomizedSeaEcomResponse creates a response to parse from GetNerCustomizedSeaEcom response
func CreateGetNerCustomizedSeaEcomResponse() (response *GetNerCustomizedSeaEcomResponse) { response = &GetNerCustomizedSeaEcomResponse{ BaseResponse: &responses.BaseResponse{}, } return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CreateGetNerCustomizedSeaEcomRequest() (request *GetNerCustomizedSeaEcomRequest) {\n\trequest = &GetNerCustomizedSeaEcomRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"alinlp\", \"2020-06-29\", \"GetNerCustomizedSeaEcom\", \"alinlp\", \"openAPI\")\n\trequest.Method = reques...
[ "0.75959283", "0.70300895", "0.661331", "0.6274801", "0.61348885", "0.6081415", "0.60363543", "0.5802763", "0.57948554", "0.56905454", "0.5679204", "0.5625127", "0.5603903", "0.5568985", "0.55646026", "0.5562964", "0.55232185", "0.5499022", "0.54989606", "0.5492508", "0.54896...
0.896394
0
WithBaseURL sets the baseURL
func WithBaseURL(url string) Option { return func(s *Storage) { s.baseURL = url } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Client) SetBaseURL(bu string) {\n\tu, err := url.Parse(bu)\n\tif err != nil {\n\t\t// return err\n\t\tlog.Fatalf(\"error parsing base url %v\", err)\n\t}\n\n\tc.BaseURL = u\n}", "func (c *Client) SetBaseURL(base string) error {\n\tu, err := url.ParseRequestURI(base)\n\tif err != nil {\n\t\treturn err\n\...
[ "0.7003866", "0.699843", "0.6800046", "0.67183524", "0.6677771", "0.6500183", "0.6447244", "0.64459676", "0.6425619", "0.62872773", "0.6284496", "0.62346447", "0.6181099", "0.60991687", "0.60940456", "0.609286", "0.60837984", "0.6007285", "0.5934689", "0.5925488", "0.5879423"...
0.6301283
9
WithHeimdallClient sets the client
func WithHeimdallClient(client heimdall.Client) Option { return func(s *Storage) { s.client = client } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cl *Client) setClient() {\n\tcl.client = &http.Client{\n\t\tTransport: &ochttp.Transport{\n\t\t\tBase: &http.Transport{\n\t\t\t\tProxy: http.ProxyFromEnvironment,\n\t\t\t\tDial: (&net.Dialer{\n\t\t\t\t\tKeepAlive: cl.keepAlive,\n\t\t\t\t}).Dial,\n\t\t\t\tTLSHandshakeTimeout: cl.handshakeTimeout,\n\t\t\t\tMax...
[ "0.66653216", "0.656386", "0.6513115", "0.63362336", "0.6135869", "0.6078363", "0.6058374", "0.6022997", "0.58994734", "0.5800192", "0.57922196", "0.5785561", "0.5777135", "0.57480276", "0.5738935", "0.5699551", "0.5697977", "0.56765866", "0.56661636", "0.5657892", "0.5656079...
0.71384174
0
CreateAuthMiddleware creates the middleware for authtication
func CreateAuthMiddleware() (*jwt.Middleware, error) { err := variables.LoadTokenKeys() if err != nil { return nil, err } authMiddleware := &jwt.Middleware{ Realm: "numapp", SigningAlgorithm: variables.SigningAlgorithm, Key: variables.TokenSignKey, VerifyKey: &variables.TokenSignKey.PublicKey, Timeout: time.Hour, MaxRefresh: time.Hour * 24, Authenticator: func(username string, password string) error { // Log the user in err := login.Login(username, password) if err != nil { return err } return nil }, } return authMiddleware, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewAuthMiddleware(svc interfaces.Service, r interfaces.Repository) interfaces.Service {\n\treturn &authMiddleware{\n\t\tnext: svc,\n\t\trepository: r,\n\t}\n}", "func NewAuthMiddleware(l lib.LogI, ctx *lib.Context) *AuthMiddleware {\n\treturn &AuthMiddleware{\n\t\tLog: l,\n\t\tContext: ctx,\n\t}\n...
[ "0.749641", "0.71149826", "0.7067203", "0.6840958", "0.684059", "0.6691852", "0.66247874", "0.6615308", "0.6607044", "0.6568086", "0.65581614", "0.65564984", "0.65474516", "0.65150654", "0.65064883", "0.6489449", "0.6460329", "0.6460041", "0.6445028", "0.64227384", "0.6399165...
0.76894057
0
MakeHandler creates the api request handler
func MakeHandler() *http.Handler { api := rest.NewApi() authMiddleware, err := CreateAuthMiddleware() if err != nil { panic(err) } api.Use(&rest.IfMiddleware{ // Only authenticate non login or register requests Condition: func(request *rest.Request) bool { return (request.URL.Path != variables.APIPathLoginUserServer) && (request.URL.Path != variables.APIPathRegisterUserServer) }, IfTrue: authMiddleware, }) api.Use(rest.DefaultProdStack...) router, err := rest.MakeRouter( rest.Post(variables.APIPathLoginUserServer, authMiddleware.LoginHandler), rest.Get(variables.APIPathRefreshUserServer, authMiddleware.RefreshHandler), rest.Post(variables.APIPathRegisterUserServer, PostRegister), rest.Get(variables.APIPathUserServer, GetUser), rest.Post(variables.APIPathUserServer, PostUser), ) if err != nil { log.Fatal(err) } api.SetApp(router) handler := api.MakeHandler() return &handler }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func MakeHandler(svc manager.Service) http.Handler {\n\topts := []kithttp.ServerOption{\n\t\tkithttp.ServerErrorEncoder(encodeError),\n\t}\n\n\tregistration := kithttp.NewServer(\n\t\tregistrationEndpoint(svc),\n\t\tdecodeCredentials,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tlogin := kithttp.NewServer(\n\t\tlo...
[ "0.7168402", "0.710997", "0.7024364", "0.6932593", "0.69240314", "0.68977165", "0.6896971", "0.6886619", "0.6849388", "0.6845259", "0.68446195", "0.68355274", "0.68299645", "0.68141025", "0.67243904", "0.66944796", "0.6646774", "0.66209537", "0.6620859", "0.65832055", "0.6569...
0.7418875
0
Creates a case in the AWS Support Center. This operation is similar to how you create a case in the AWS Support Center Create Case ( page. The AWS Support API doesn't support requesting service limit increases. You can submit a service limit increase in the following ways: Submit a request from the AWS Support Center Create Case ( page. Use the Service Quotas RequestServiceQuotaIncrease ( operation. A successful CreateCase request returns an AWS Support case number. You can use the DescribeCases operation and specify the case number to get existing AWS Support cases. After you create a case, use the AddCommunicationToCase operation to add additional communication or attachments to an existing case. The caseId is separate from the displayId that appears in the AWS Support Center ( Use the DescribeCases operation to get the displayId. You must have a Business or Enterprise support plan to use the AWS Support API. If you call the AWS Support API from an account that does not have a Business or Enterprise support plan, the SubscriptionRequiredException error message appears. For information about changing your support plan, see AWS Support (
func (c *Client) CreateCase(ctx context.Context, params *CreateCaseInput, optFns ...func(*Options)) (*CreateCaseOutput, error) { if params == nil { params = &CreateCaseInput{} } result, metadata, err := c.invokeOperation(ctx, "CreateCase", params, optFns, addOperationCreateCaseMiddlewares) if err != nil { return nil, err } out := result.(*CreateCaseOutput) out.ResultMetadata = metadata return out, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Client) AddCommunicationToCase(ctx context.Context, params *AddCommunicationToCaseInput, optFns ...func(*Options)) (*AddCommunicationToCaseOutput, error) {\n\tif params == nil {\n\t\tparams = &AddCommunicationToCaseInput{}\n\t}\n\n\tresult, metadata, err := c.invokeOperation(ctx, \"AddCommunicationToCase\...
[ "0.6415229", "0.5866429", "0.5843353", "0.57201755", "0.57147646", "0.5541539", "0.52763075", "0.52597666", "0.5138041", "0.5122116", "0.50251997", "0.49641767", "0.48984498", "0.48797622", "0.48758298", "0.4828721", "0.48263887", "0.48155132", "0.4813809", "0.4793567", "0.47...
0.78295654
0