id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
3,300 | beefsack/go-rate | rate.go | New | func New(limit int, interval time.Duration) *RateLimiter {
lim := &RateLimiter{
limit: limit,
interval: interval,
}
lim.times.Init()
return lim
} | go | func New(limit int, interval time.Duration) *RateLimiter {
lim := &RateLimiter{
limit: limit,
interval: interval,
}
lim.times.Init()
return lim
} | [
"func",
"New",
"(",
"limit",
"int",
",",
"interval",
"time",
".",
"Duration",
")",
"*",
"RateLimiter",
"{",
"lim",
":=",
"&",
"RateLimiter",
"{",
"limit",
":",
"limit",
",",
"interval",
":",
"interval",
",",
"}",
"\n",
"lim",
".",
"times",
".",
"Init",
"(",
")",
"\n",
"return",
"lim",
"\n",
"}"
] | // New creates a new rate limiter for the limit and interval. | [
"New",
"creates",
"a",
"new",
"rate",
"limiter",
"for",
"the",
"limit",
"and",
"interval",
"."
] | efa7637bb9b6433f47eb73dde68902abda87f352 | https://github.com/beefsack/go-rate/blob/efa7637bb9b6433f47eb73dde68902abda87f352/rate.go#L22-L29 |
3,301 | beefsack/go-rate | rate.go | Wait | func (r *RateLimiter) Wait() {
for {
ok, remaining := r.Try()
if ok {
break
}
time.Sleep(remaining)
}
} | go | func (r *RateLimiter) Wait() {
for {
ok, remaining := r.Try()
if ok {
break
}
time.Sleep(remaining)
}
} | [
"func",
"(",
"r",
"*",
"RateLimiter",
")",
"Wait",
"(",
")",
"{",
"for",
"{",
"ok",
",",
"remaining",
":=",
"r",
".",
"Try",
"(",
")",
"\n",
"if",
"ok",
"{",
"break",
"\n",
"}",
"\n",
"time",
".",
"Sleep",
"(",
"remaining",
")",
"\n",
"}",
"\n",
"}"
] | // Wait blocks if the rate limit has been reached. Wait offers no guarantees
// of fairness for multiple actors if the allowed rate has been temporarily
// exhausted. | [
"Wait",
"blocks",
"if",
"the",
"rate",
"limit",
"has",
"been",
"reached",
".",
"Wait",
"offers",
"no",
"guarantees",
"of",
"fairness",
"for",
"multiple",
"actors",
"if",
"the",
"allowed",
"rate",
"has",
"been",
"temporarily",
"exhausted",
"."
] | efa7637bb9b6433f47eb73dde68902abda87f352 | https://github.com/beefsack/go-rate/blob/efa7637bb9b6433f47eb73dde68902abda87f352/rate.go#L34-L42 |
3,302 | beefsack/go-rate | rate.go | Try | func (r *RateLimiter) Try() (ok bool, remaining time.Duration) {
r.mtx.Lock()
defer r.mtx.Unlock()
now := time.Now()
if l := r.times.Len(); l < r.limit {
r.times.PushBack(now)
return true, 0
}
frnt := r.times.Front()
if diff := now.Sub(frnt.Value.(time.Time)); diff < r.interval {
return false, r.interval - diff
}
frnt.Value = now
r.times.MoveToBack(frnt)
return true, 0
} | go | func (r *RateLimiter) Try() (ok bool, remaining time.Duration) {
r.mtx.Lock()
defer r.mtx.Unlock()
now := time.Now()
if l := r.times.Len(); l < r.limit {
r.times.PushBack(now)
return true, 0
}
frnt := r.times.Front()
if diff := now.Sub(frnt.Value.(time.Time)); diff < r.interval {
return false, r.interval - diff
}
frnt.Value = now
r.times.MoveToBack(frnt)
return true, 0
} | [
"func",
"(",
"r",
"*",
"RateLimiter",
")",
"Try",
"(",
")",
"(",
"ok",
"bool",
",",
"remaining",
"time",
".",
"Duration",
")",
"{",
"r",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"if",
"l",
":=",
"r",
".",
"times",
".",
"Len",
"(",
")",
";",
"l",
"<",
"r",
".",
"limit",
"{",
"r",
".",
"times",
".",
"PushBack",
"(",
"now",
")",
"\n",
"return",
"true",
",",
"0",
"\n",
"}",
"\n",
"frnt",
":=",
"r",
".",
"times",
".",
"Front",
"(",
")",
"\n",
"if",
"diff",
":=",
"now",
".",
"Sub",
"(",
"frnt",
".",
"Value",
".",
"(",
"time",
".",
"Time",
")",
")",
";",
"diff",
"<",
"r",
".",
"interval",
"{",
"return",
"false",
",",
"r",
".",
"interval",
"-",
"diff",
"\n",
"}",
"\n",
"frnt",
".",
"Value",
"=",
"now",
"\n",
"r",
".",
"times",
".",
"MoveToBack",
"(",
"frnt",
")",
"\n",
"return",
"true",
",",
"0",
"\n",
"}"
] | // Try returns true if under the rate limit, or false if over and the
// remaining time before the rate limit expires. | [
"Try",
"returns",
"true",
"if",
"under",
"the",
"rate",
"limit",
"or",
"false",
"if",
"over",
"and",
"the",
"remaining",
"time",
"before",
"the",
"rate",
"limit",
"expires",
"."
] | efa7637bb9b6433f47eb73dde68902abda87f352 | https://github.com/beefsack/go-rate/blob/efa7637bb9b6433f47eb73dde68902abda87f352/rate.go#L46-L61 |
3,303 | bgentry/que-go | que.go | Done | func (j *Job) Done() {
j.mu.Lock()
defer j.mu.Unlock()
if j.conn == nil || j.pool == nil {
// already marked as done
return
}
var ok bool
// Swallow this error because we don't want an unlock failure to cause work to
// stop.
_ = j.conn.QueryRow("que_unlock_job", j.ID).Scan(&ok)
j.pool.Release(j.conn)
j.pool = nil
j.conn = nil
} | go | func (j *Job) Done() {
j.mu.Lock()
defer j.mu.Unlock()
if j.conn == nil || j.pool == nil {
// already marked as done
return
}
var ok bool
// Swallow this error because we don't want an unlock failure to cause work to
// stop.
_ = j.conn.QueryRow("que_unlock_job", j.ID).Scan(&ok)
j.pool.Release(j.conn)
j.pool = nil
j.conn = nil
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Done",
"(",
")",
"{",
"j",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"j",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"j",
".",
"conn",
"==",
"nil",
"||",
"j",
".",
"pool",
"==",
"nil",
"{",
"// already marked as done",
"return",
"\n",
"}",
"\n\n",
"var",
"ok",
"bool",
"\n",
"// Swallow this error because we don't want an unlock failure to cause work to",
"// stop.",
"_",
"=",
"j",
".",
"conn",
".",
"QueryRow",
"(",
"\"",
"\"",
",",
"j",
".",
"ID",
")",
".",
"Scan",
"(",
"&",
"ok",
")",
"\n\n",
"j",
".",
"pool",
".",
"Release",
"(",
"j",
".",
"conn",
")",
"\n",
"j",
".",
"pool",
"=",
"nil",
"\n",
"j",
".",
"conn",
"=",
"nil",
"\n",
"}"
] | // Done releases the Postgres advisory lock on the job and returns the database
// connection to the pool. | [
"Done",
"releases",
"the",
"Postgres",
"advisory",
"lock",
"on",
"the",
"job",
"and",
"returns",
"the",
"database",
"connection",
"to",
"the",
"pool",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/que.go#L86-L103 |
3,304 | bgentry/que-go | que.go | Enqueue | func (c *Client) Enqueue(j *Job) error {
return execEnqueue(j, c.pool)
} | go | func (c *Client) Enqueue(j *Job) error {
return execEnqueue(j, c.pool)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Enqueue",
"(",
"j",
"*",
"Job",
")",
"error",
"{",
"return",
"execEnqueue",
"(",
"j",
",",
"c",
".",
"pool",
")",
"\n",
"}"
] | // Enqueue adds a job to the queue. | [
"Enqueue",
"adds",
"a",
"job",
"to",
"the",
"queue",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/que.go#L140-L142 |
3,305 | bgentry/que-go | que.go | EnqueueInTx | func (c *Client) EnqueueInTx(j *Job, tx *pgx.Tx) error {
return execEnqueue(j, tx)
} | go | func (c *Client) EnqueueInTx(j *Job, tx *pgx.Tx) error {
return execEnqueue(j, tx)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"EnqueueInTx",
"(",
"j",
"*",
"Job",
",",
"tx",
"*",
"pgx",
".",
"Tx",
")",
"error",
"{",
"return",
"execEnqueue",
"(",
"j",
",",
"tx",
")",
"\n",
"}"
] | // EnqueueInTx adds a job to the queue within the scope of the transaction tx.
// This allows you to guarantee that an enqueued job will either be committed or
// rolled back atomically with other changes in the course of this transaction.
//
// It is the caller's responsibility to Commit or Rollback the transaction after
// this function is called. | [
"EnqueueInTx",
"adds",
"a",
"job",
"to",
"the",
"queue",
"within",
"the",
"scope",
"of",
"the",
"transaction",
"tx",
".",
"This",
"allows",
"you",
"to",
"guarantee",
"that",
"an",
"enqueued",
"job",
"will",
"either",
"be",
"committed",
"or",
"rolled",
"back",
"atomically",
"with",
"other",
"changes",
"in",
"the",
"course",
"of",
"this",
"transaction",
".",
"It",
"is",
"the",
"caller",
"s",
"responsibility",
"to",
"Commit",
"or",
"Rollback",
"the",
"transaction",
"after",
"this",
"function",
"is",
"called",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/que.go#L150-L152 |
3,306 | bgentry/que-go | worker.go | Shutdown | func (w *Worker) Shutdown() {
w.mu.Lock()
defer w.mu.Unlock()
if w.done {
return
}
log.Println("worker shutting down gracefully...")
w.ch <- struct{}{}
w.done = true
close(w.ch)
} | go | func (w *Worker) Shutdown() {
w.mu.Lock()
defer w.mu.Unlock()
if w.done {
return
}
log.Println("worker shutting down gracefully...")
w.ch <- struct{}{}
w.done = true
close(w.ch)
} | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Shutdown",
"(",
")",
"{",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"w",
".",
"done",
"{",
"return",
"\n",
"}",
"\n\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"w",
".",
"ch",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"w",
".",
"done",
"=",
"true",
"\n",
"close",
"(",
"w",
".",
"ch",
")",
"\n",
"}"
] | // Shutdown tells the worker to finish processing its current job and then stop.
// There is currently no timeout for in-progress jobs. This function blocks
// until the Worker has stopped working. It should only be called on an active
// Worker. | [
"Shutdown",
"tells",
"the",
"worker",
"to",
"finish",
"processing",
"its",
"current",
"job",
"and",
"then",
"stop",
".",
"There",
"is",
"currently",
"no",
"timeout",
"for",
"in",
"-",
"progress",
"jobs",
".",
"This",
"function",
"blocks",
"until",
"the",
"Worker",
"has",
"stopped",
"working",
".",
"It",
"should",
"only",
"be",
"called",
"on",
"an",
"active",
"Worker",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/worker.go#L128-L140 |
3,307 | bgentry/que-go | worker.go | recoverPanic | func recoverPanic(j *Job) {
if r := recover(); r != nil {
// record an error on the job with panic message and stacktrace
stackBuf := make([]byte, 1024)
n := runtime.Stack(stackBuf, false)
buf := &bytes.Buffer{}
fmt.Fprintf(buf, "%v\n", r)
fmt.Fprintln(buf, string(stackBuf[:n]))
fmt.Fprintln(buf, "[...]")
stacktrace := buf.String()
log.Printf("event=panic job_id=%d job_type=%s\n%s", j.ID, j.Type, stacktrace)
if err := j.Error(stacktrace); err != nil {
log.Printf("attempting to save error on job %d: %v", j.ID, err)
}
}
} | go | func recoverPanic(j *Job) {
if r := recover(); r != nil {
// record an error on the job with panic message and stacktrace
stackBuf := make([]byte, 1024)
n := runtime.Stack(stackBuf, false)
buf := &bytes.Buffer{}
fmt.Fprintf(buf, "%v\n", r)
fmt.Fprintln(buf, string(stackBuf[:n]))
fmt.Fprintln(buf, "[...]")
stacktrace := buf.String()
log.Printf("event=panic job_id=%d job_type=%s\n%s", j.ID, j.Type, stacktrace)
if err := j.Error(stacktrace); err != nil {
log.Printf("attempting to save error on job %d: %v", j.ID, err)
}
}
} | [
"func",
"recoverPanic",
"(",
"j",
"*",
"Job",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"{",
"// record an error on the job with panic message and stacktrace",
"stackBuf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1024",
")",
"\n",
"n",
":=",
"runtime",
".",
"Stack",
"(",
"stackBuf",
",",
"false",
")",
"\n\n",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"buf",
",",
"\"",
"\\n",
"\"",
",",
"r",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"buf",
",",
"string",
"(",
"stackBuf",
"[",
":",
"n",
"]",
")",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"buf",
",",
"\"",
"\"",
")",
"\n",
"stacktrace",
":=",
"buf",
".",
"String",
"(",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"j",
".",
"ID",
",",
"j",
".",
"Type",
",",
"stacktrace",
")",
"\n",
"if",
"err",
":=",
"j",
".",
"Error",
"(",
"stacktrace",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"j",
".",
"ID",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // recoverPanic tries to handle panics in job execution.
// A stacktrace is stored into Job last_error. | [
"recoverPanic",
"tries",
"to",
"handle",
"panics",
"in",
"job",
"execution",
".",
"A",
"stacktrace",
"is",
"stored",
"into",
"Job",
"last_error",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/worker.go#L144-L160 |
3,308 | bgentry/que-go | worker.go | NewWorkerPool | func NewWorkerPool(c *Client, wm WorkMap, count int) *WorkerPool {
return &WorkerPool{
c: c,
WorkMap: wm,
Interval: defaultWakeInterval,
workers: make([]*Worker, count),
}
} | go | func NewWorkerPool(c *Client, wm WorkMap, count int) *WorkerPool {
return &WorkerPool{
c: c,
WorkMap: wm,
Interval: defaultWakeInterval,
workers: make([]*Worker, count),
}
} | [
"func",
"NewWorkerPool",
"(",
"c",
"*",
"Client",
",",
"wm",
"WorkMap",
",",
"count",
"int",
")",
"*",
"WorkerPool",
"{",
"return",
"&",
"WorkerPool",
"{",
"c",
":",
"c",
",",
"WorkMap",
":",
"wm",
",",
"Interval",
":",
"defaultWakeInterval",
",",
"workers",
":",
"make",
"(",
"[",
"]",
"*",
"Worker",
",",
"count",
")",
",",
"}",
"\n",
"}"
] | // NewWorkerPool creates a new WorkerPool with count workers using the Client c. | [
"NewWorkerPool",
"creates",
"a",
"new",
"WorkerPool",
"with",
"count",
"workers",
"using",
"the",
"Client",
"c",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/worker.go#L176-L183 |
3,309 | bgentry/que-go | worker.go | Start | func (w *WorkerPool) Start() {
w.mu.Lock()
defer w.mu.Unlock()
for i := range w.workers {
w.workers[i] = NewWorker(w.c, w.WorkMap)
w.workers[i].Interval = w.Interval
w.workers[i].Queue = w.Queue
go w.workers[i].Work()
}
} | go | func (w *WorkerPool) Start() {
w.mu.Lock()
defer w.mu.Unlock()
for i := range w.workers {
w.workers[i] = NewWorker(w.c, w.WorkMap)
w.workers[i].Interval = w.Interval
w.workers[i].Queue = w.Queue
go w.workers[i].Work()
}
} | [
"func",
"(",
"w",
"*",
"WorkerPool",
")",
"Start",
"(",
")",
"{",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"i",
":=",
"range",
"w",
".",
"workers",
"{",
"w",
".",
"workers",
"[",
"i",
"]",
"=",
"NewWorker",
"(",
"w",
".",
"c",
",",
"w",
".",
"WorkMap",
")",
"\n",
"w",
".",
"workers",
"[",
"i",
"]",
".",
"Interval",
"=",
"w",
".",
"Interval",
"\n",
"w",
".",
"workers",
"[",
"i",
"]",
".",
"Queue",
"=",
"w",
".",
"Queue",
"\n",
"go",
"w",
".",
"workers",
"[",
"i",
"]",
".",
"Work",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Start starts all of the Workers in the WorkerPool. | [
"Start",
"starts",
"all",
"of",
"the",
"Workers",
"in",
"the",
"WorkerPool",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/worker.go#L186-L196 |
3,310 | bgentry/que-go | worker.go | Shutdown | func (w *WorkerPool) Shutdown() {
w.mu.Lock()
defer w.mu.Unlock()
if w.done {
return
}
var wg sync.WaitGroup
wg.Add(len(w.workers))
for _, worker := range w.workers {
go func(worker *Worker) {
worker.Shutdown()
wg.Done()
}(worker)
}
wg.Wait()
w.done = true
} | go | func (w *WorkerPool) Shutdown() {
w.mu.Lock()
defer w.mu.Unlock()
if w.done {
return
}
var wg sync.WaitGroup
wg.Add(len(w.workers))
for _, worker := range w.workers {
go func(worker *Worker) {
worker.Shutdown()
wg.Done()
}(worker)
}
wg.Wait()
w.done = true
} | [
"func",
"(",
"w",
"*",
"WorkerPool",
")",
"Shutdown",
"(",
")",
"{",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"w",
".",
"done",
"{",
"return",
"\n",
"}",
"\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"wg",
".",
"Add",
"(",
"len",
"(",
"w",
".",
"workers",
")",
")",
"\n\n",
"for",
"_",
",",
"worker",
":=",
"range",
"w",
".",
"workers",
"{",
"go",
"func",
"(",
"worker",
"*",
"Worker",
")",
"{",
"worker",
".",
"Shutdown",
"(",
")",
"\n",
"wg",
".",
"Done",
"(",
")",
"\n",
"}",
"(",
"worker",
")",
"\n",
"}",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"w",
".",
"done",
"=",
"true",
"\n",
"}"
] | // Shutdown sends a Shutdown signal to each of the Workers in the WorkerPool and
// waits for them all to finish shutting down. | [
"Shutdown",
"sends",
"a",
"Shutdown",
"signal",
"to",
"each",
"of",
"the",
"Workers",
"in",
"the",
"WorkerPool",
"and",
"waits",
"for",
"them",
"all",
"to",
"finish",
"shutting",
"down",
"."
] | b198c7caf054cfc10e9da6b34f33364d80464425 | https://github.com/bgentry/que-go/blob/b198c7caf054cfc10e9da6b34f33364d80464425/worker.go#L200-L218 |
3,311 | plimble/ace | context.go | HTML | func (c *C) HTML(name string, data interface{}) {
c.render.Render(c.Writer, name, data)
} | go | func (c *C) HTML(name string, data interface{}) {
c.render.Render(c.Writer, name, data)
} | [
"func",
"(",
"c",
"*",
"C",
")",
"HTML",
"(",
"name",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"render",
".",
"Render",
"(",
"c",
".",
"Writer",
",",
"name",
",",
"data",
")",
"\n",
"}"
] | //HTML render template engine | [
"HTML",
"render",
"template",
"engine"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/context.go#L88-L90 |
3,312 | plimble/ace | context.go | Param | func (c *C) Param(name string) string {
return c.params.ByName(name)
} | go | func (c *C) Param(name string) string {
return c.params.ByName(name)
} | [
"func",
"(",
"c",
"*",
"C",
")",
"Param",
"(",
"name",
"string",
")",
"string",
"{",
"return",
"c",
".",
"params",
".",
"ByName",
"(",
"name",
")",
"\n",
"}"
] | //Param get param from route | [
"Param",
"get",
"param",
"from",
"route"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/context.go#L93-L95 |
3,313 | plimble/ace | context.go | HTTPLang | func (c *C) HTTPLang() string {
langStr := c.Request.Header.Get(acceptLanguage)
return strings.Split(langStr, ",")[0]
} | go | func (c *C) HTTPLang() string {
langStr := c.Request.Header.Get(acceptLanguage)
return strings.Split(langStr, ",")[0]
} | [
"func",
"(",
"c",
"*",
"C",
")",
"HTTPLang",
"(",
")",
"string",
"{",
"langStr",
":=",
"c",
".",
"Request",
".",
"Header",
".",
"Get",
"(",
"acceptLanguage",
")",
"\n",
"return",
"strings",
".",
"Split",
"(",
"langStr",
",",
"\"",
"\"",
")",
"[",
"0",
"]",
"\n",
"}"
] | //HTTPLang get first language from HTTP Header | [
"HTTPLang",
"get",
"first",
"language",
"from",
"HTTP",
"Header"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/context.go#L104-L107 |
3,314 | plimble/ace | context.go | Redirect | func (c *C) Redirect(url string) {
http.Redirect(c.Writer, c.Request, url, 302)
} | go | func (c *C) Redirect(url string) {
http.Redirect(c.Writer, c.Request, url, 302)
} | [
"func",
"(",
"c",
"*",
"C",
")",
"Redirect",
"(",
"url",
"string",
")",
"{",
"http",
".",
"Redirect",
"(",
"c",
".",
"Writer",
",",
"c",
".",
"Request",
",",
"url",
",",
"302",
")",
"\n",
"}"
] | //Redirect 302 response | [
"Redirect",
"302",
"response"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/context.go#L110-L112 |
3,315 | plimble/ace | context.go | AbortWithStatus | func (c *C) AbortWithStatus(status int) {
c.Writer.WriteHeader(status)
c.Abort()
} | go | func (c *C) AbortWithStatus(status int) {
c.Writer.WriteHeader(status)
c.Abort()
} | [
"func",
"(",
"c",
"*",
"C",
")",
"AbortWithStatus",
"(",
"status",
"int",
")",
"{",
"c",
".",
"Writer",
".",
"WriteHeader",
"(",
"status",
")",
"\n",
"c",
".",
"Abort",
"(",
")",
"\n",
"}"
] | //AbortWithStatus stop maddileware and return http status code | [
"AbortWithStatus",
"stop",
"maddileware",
"and",
"return",
"http",
"status",
"code"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/context.go#L120-L123 |
3,316 | plimble/ace | context.go | Next | func (c *C) Next() {
c.index++
s := int8(len(c.handlers))
if c.index < s {
c.handlers[c.index](c)
}
} | go | func (c *C) Next() {
c.index++
s := int8(len(c.handlers))
if c.index < s {
c.handlers[c.index](c)
}
} | [
"func",
"(",
"c",
"*",
"C",
")",
"Next",
"(",
")",
"{",
"c",
".",
"index",
"++",
"\n",
"s",
":=",
"int8",
"(",
"len",
"(",
"c",
".",
"handlers",
")",
")",
"\n",
"if",
"c",
".",
"index",
"<",
"s",
"{",
"c",
".",
"handlers",
"[",
"c",
".",
"index",
"]",
"(",
"c",
")",
"\n",
"}",
"\n",
"}"
] | //Next next middleware | [
"Next",
"next",
"middleware"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/context.go#L126-L132 |
3,317 | plimble/ace | ace.go | Run | func (a *Ace) Run(addr string) {
if err := http.ListenAndServe(addr, a); err != nil {
panic(err)
}
} | go | func (a *Ace) Run(addr string) {
if err := http.ListenAndServe(addr, a); err != nil {
panic(err)
}
} | [
"func",
"(",
"a",
"*",
"Ace",
")",
"Run",
"(",
"addr",
"string",
")",
"{",
"if",
"err",
":=",
"http",
".",
"ListenAndServe",
"(",
"addr",
",",
"a",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}"
] | //Run server with specific address and port | [
"Run",
"server",
"with",
"specific",
"address",
"and",
"port"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/ace.go#L74-L78 |
3,318 | plimble/ace | ace.go | RunTLS | func (a *Ace) RunTLS(addr string, cert string, key string) {
if err := http.ListenAndServeTLS(addr, cert, key, a); err != nil {
panic(err)
}
} | go | func (a *Ace) RunTLS(addr string, cert string, key string) {
if err := http.ListenAndServeTLS(addr, cert, key, a); err != nil {
panic(err)
}
} | [
"func",
"(",
"a",
"*",
"Ace",
")",
"RunTLS",
"(",
"addr",
"string",
",",
"cert",
"string",
",",
"key",
"string",
")",
"{",
"if",
"err",
":=",
"http",
".",
"ListenAndServeTLS",
"(",
"addr",
",",
"cert",
",",
"key",
",",
"a",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}"
] | //RunTLS server with specific address and port | [
"RunTLS",
"server",
"with",
"specific",
"address",
"and",
"port"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/ace.go#L81-L85 |
3,319 | plimble/ace | ace.go | ServeHTTP | func (a *Ace) ServeHTTP(w http.ResponseWriter, req *http.Request) {
a.httprouter.ServeHTTP(w, req)
} | go | func (a *Ace) ServeHTTP(w http.ResponseWriter, req *http.Request) {
a.httprouter.ServeHTTP(w, req)
} | [
"func",
"(",
"a",
"*",
"Ace",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"a",
".",
"httprouter",
".",
"ServeHTTP",
"(",
"w",
",",
"req",
")",
"\n",
"}"
] | //ServeHTTP implement http.Handler | [
"ServeHTTP",
"implement",
"http",
".",
"Handler"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/ace.go#L88-L90 |
3,320 | plimble/ace | session.go | Session | func Session(store sessions.Store, options *SessionOptions) HandlerFunc {
var sessionOptions *sessions.Options
if options != nil {
sessionOptions = &sessions.Options{
Path: options.Path,
Domain: options.Domain,
MaxAge: options.MaxAge,
Secure: options.Secure,
HttpOnly: options.HTTPOnly,
}
}
manager := sessions.New(512, store, sessionOptions)
return func(c *C) {
c.sessions = manager.GetSessions(c.Request)
defer manager.Close(c.sessions)
c.Writer.Before(func(ResponseWriter) {
c.sessions.Save(c.Writer)
})
c.Next()
}
} | go | func Session(store sessions.Store, options *SessionOptions) HandlerFunc {
var sessionOptions *sessions.Options
if options != nil {
sessionOptions = &sessions.Options{
Path: options.Path,
Domain: options.Domain,
MaxAge: options.MaxAge,
Secure: options.Secure,
HttpOnly: options.HTTPOnly,
}
}
manager := sessions.New(512, store, sessionOptions)
return func(c *C) {
c.sessions = manager.GetSessions(c.Request)
defer manager.Close(c.sessions)
c.Writer.Before(func(ResponseWriter) {
c.sessions.Save(c.Writer)
})
c.Next()
}
} | [
"func",
"Session",
"(",
"store",
"sessions",
".",
"Store",
",",
"options",
"*",
"SessionOptions",
")",
"HandlerFunc",
"{",
"var",
"sessionOptions",
"*",
"sessions",
".",
"Options",
"\n\n",
"if",
"options",
"!=",
"nil",
"{",
"sessionOptions",
"=",
"&",
"sessions",
".",
"Options",
"{",
"Path",
":",
"options",
".",
"Path",
",",
"Domain",
":",
"options",
".",
"Domain",
",",
"MaxAge",
":",
"options",
".",
"MaxAge",
",",
"Secure",
":",
"options",
".",
"Secure",
",",
"HttpOnly",
":",
"options",
".",
"HTTPOnly",
",",
"}",
"\n",
"}",
"\n\n",
"manager",
":=",
"sessions",
".",
"New",
"(",
"512",
",",
"store",
",",
"sessionOptions",
")",
"\n\n",
"return",
"func",
"(",
"c",
"*",
"C",
")",
"{",
"c",
".",
"sessions",
"=",
"manager",
".",
"GetSessions",
"(",
"c",
".",
"Request",
")",
"\n",
"defer",
"manager",
".",
"Close",
"(",
"c",
".",
"sessions",
")",
"\n\n",
"c",
".",
"Writer",
".",
"Before",
"(",
"func",
"(",
"ResponseWriter",
")",
"{",
"c",
".",
"sessions",
".",
"Save",
"(",
"c",
".",
"Writer",
")",
"\n",
"}",
")",
"\n\n",
"c",
".",
"Next",
"(",
")",
"\n",
"}",
"\n",
"}"
] | //Session use session middleware | [
"Session",
"use",
"session",
"middleware"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/session.go#L20-L45 |
3,321 | plimble/ace | router.go | Use | func (r *Router) Use(middlewares ...HandlerFunc) {
for _, handler := range middlewares {
r.handlers = append(r.handlers, handler)
}
} | go | func (r *Router) Use(middlewares ...HandlerFunc) {
for _, handler := range middlewares {
r.handlers = append(r.handlers, handler)
}
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Use",
"(",
"middlewares",
"...",
"HandlerFunc",
")",
"{",
"for",
"_",
",",
"handler",
":=",
"range",
"middlewares",
"{",
"r",
".",
"handlers",
"=",
"append",
"(",
"r",
".",
"handlers",
",",
"handler",
")",
"\n",
"}",
"\n",
"}"
] | //Use register middleware | [
"Use",
"register",
"middleware"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L27-L31 |
3,322 | plimble/ace | router.go | GET | func (r *Router) GET(path string, handlers ...HandlerFunc) {
r.Handle("GET", path, handlers)
} | go | func (r *Router) GET(path string, handlers ...HandlerFunc) {
r.Handle("GET", path, handlers)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"GET",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"path",
",",
"handlers",
")",
"\n",
"}"
] | //GET handle GET method | [
"GET",
"handle",
"GET",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L34-L36 |
3,323 | plimble/ace | router.go | POST | func (r *Router) POST(path string, handlers ...HandlerFunc) {
r.Handle("POST", path, handlers)
} | go | func (r *Router) POST(path string, handlers ...HandlerFunc) {
r.Handle("POST", path, handlers)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"POST",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"path",
",",
"handlers",
")",
"\n",
"}"
] | //POST handle POST method | [
"POST",
"handle",
"POST",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L39-L41 |
3,324 | plimble/ace | router.go | PATCH | func (r *Router) PATCH(path string, handlers ...HandlerFunc) {
r.Handle("PATCH", path, handlers)
} | go | func (r *Router) PATCH(path string, handlers ...HandlerFunc) {
r.Handle("PATCH", path, handlers)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"PATCH",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"path",
",",
"handlers",
")",
"\n",
"}"
] | //PATCH handle PATCH method | [
"PATCH",
"handle",
"PATCH",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L44-L46 |
3,325 | plimble/ace | router.go | PUT | func (r *Router) PUT(path string, handlers ...HandlerFunc) {
r.Handle("PUT", path, handlers)
} | go | func (r *Router) PUT(path string, handlers ...HandlerFunc) {
r.Handle("PUT", path, handlers)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"PUT",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"path",
",",
"handlers",
")",
"\n",
"}"
] | //PUT handle PUT method | [
"PUT",
"handle",
"PUT",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L49-L51 |
3,326 | plimble/ace | router.go | DELETE | func (r *Router) DELETE(path string, handlers ...HandlerFunc) {
r.Handle("DELETE", path, handlers)
} | go | func (r *Router) DELETE(path string, handlers ...HandlerFunc) {
r.Handle("DELETE", path, handlers)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"DELETE",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"path",
",",
"handlers",
")",
"\n",
"}"
] | //DELETE handle DELETE method | [
"DELETE",
"handle",
"DELETE",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L54-L56 |
3,327 | plimble/ace | router.go | HEAD | func (r *Router) HEAD(path string, handlers ...HandlerFunc) {
r.Handle("HEAD", path, handlers)
} | go | func (r *Router) HEAD(path string, handlers ...HandlerFunc) {
r.Handle("HEAD", path, handlers)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"HEAD",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"path",
",",
"handlers",
")",
"\n",
"}"
] | //HEAD handle HEAD method | [
"HEAD",
"handle",
"HEAD",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L59-L61 |
3,328 | plimble/ace | router.go | OPTIONS | func (r *Router) OPTIONS(path string, handlers ...HandlerFunc) {
r.Handle("OPTIONS", path, handlers)
} | go | func (r *Router) OPTIONS(path string, handlers ...HandlerFunc) {
r.Handle("OPTIONS", path, handlers)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"OPTIONS",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"Handle",
"(",
"\"",
"\"",
",",
"path",
",",
"handlers",
")",
"\n",
"}"
] | //OPTIONS handle OPTIONS method | [
"OPTIONS",
"handle",
"OPTIONS",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L64-L66 |
3,329 | plimble/ace | router.go | Group | func (r *Router) Group(path string, handlers ...HandlerFunc) *Router {
handlers = r.combineHandlers(handlers)
return &Router{
handlers: handlers,
prefix: r.path(path),
ace: r.ace,
}
} | go | func (r *Router) Group(path string, handlers ...HandlerFunc) *Router {
handlers = r.combineHandlers(handlers)
return &Router{
handlers: handlers,
prefix: r.path(path),
ace: r.ace,
}
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Group",
"(",
"path",
"string",
",",
"handlers",
"...",
"HandlerFunc",
")",
"*",
"Router",
"{",
"handlers",
"=",
"r",
".",
"combineHandlers",
"(",
"handlers",
")",
"\n",
"return",
"&",
"Router",
"{",
"handlers",
":",
"handlers",
",",
"prefix",
":",
"r",
".",
"path",
"(",
"path",
")",
",",
"ace",
":",
"r",
".",
"ace",
",",
"}",
"\n",
"}"
] | //Group group route | [
"Group",
"group",
"route"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L69-L76 |
3,330 | plimble/ace | router.go | Static | func (r *Router) Static(path string, root http.Dir, handlers ...HandlerFunc) {
path = r.path(path)
fileServer := http.StripPrefix(path, http.FileServer(root))
handlers = append(handlers, func(c *C) {
fileServer.ServeHTTP(c.Writer, c.Request)
})
r.ace.httprouter.Handle("GET", r.staticPath(path), func(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
c := r.ace.createContext(w, req)
c.handlers = handlers
c.Next()
r.ace.pool.Put(c)
})
} | go | func (r *Router) Static(path string, root http.Dir, handlers ...HandlerFunc) {
path = r.path(path)
fileServer := http.StripPrefix(path, http.FileServer(root))
handlers = append(handlers, func(c *C) {
fileServer.ServeHTTP(c.Writer, c.Request)
})
r.ace.httprouter.Handle("GET", r.staticPath(path), func(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
c := r.ace.createContext(w, req)
c.handlers = handlers
c.Next()
r.ace.pool.Put(c)
})
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Static",
"(",
"path",
"string",
",",
"root",
"http",
".",
"Dir",
",",
"handlers",
"...",
"HandlerFunc",
")",
"{",
"path",
"=",
"r",
".",
"path",
"(",
"path",
")",
"\n",
"fileServer",
":=",
"http",
".",
"StripPrefix",
"(",
"path",
",",
"http",
".",
"FileServer",
"(",
"root",
")",
")",
"\n\n",
"handlers",
"=",
"append",
"(",
"handlers",
",",
"func",
"(",
"c",
"*",
"C",
")",
"{",
"fileServer",
".",
"ServeHTTP",
"(",
"c",
".",
"Writer",
",",
"c",
".",
"Request",
")",
"\n",
"}",
")",
"\n\n",
"r",
".",
"ace",
".",
"httprouter",
".",
"Handle",
"(",
"\"",
"\"",
",",
"r",
".",
"staticPath",
"(",
"path",
")",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"_",
"httprouter",
".",
"Params",
")",
"{",
"c",
":=",
"r",
".",
"ace",
".",
"createContext",
"(",
"w",
",",
"req",
")",
"\n",
"c",
".",
"handlers",
"=",
"handlers",
"\n",
"c",
".",
"Next",
"(",
")",
"\n",
"r",
".",
"ace",
".",
"pool",
".",
"Put",
"(",
"c",
")",
"\n",
"}",
")",
"\n",
"}"
] | //Static server static file
//path is url path
//root is root directory | [
"Static",
"server",
"static",
"file",
"path",
"is",
"url",
"path",
"root",
"is",
"root",
"directory"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L109-L123 |
3,331 | plimble/ace | router.go | Handle | func (r *Router) Handle(method, path string, handlers []HandlerFunc) {
handlers = r.combineHandlers(handlers)
r.ace.httprouter.Handle(method, r.path(path), func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
c := r.ace.createContext(w, req)
c.params = params
c.handlers = handlers
c.Next()
r.ace.pool.Put(c)
})
} | go | func (r *Router) Handle(method, path string, handlers []HandlerFunc) {
handlers = r.combineHandlers(handlers)
r.ace.httprouter.Handle(method, r.path(path), func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
c := r.ace.createContext(w, req)
c.params = params
c.handlers = handlers
c.Next()
r.ace.pool.Put(c)
})
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Handle",
"(",
"method",
",",
"path",
"string",
",",
"handlers",
"[",
"]",
"HandlerFunc",
")",
"{",
"handlers",
"=",
"r",
".",
"combineHandlers",
"(",
"handlers",
")",
"\n",
"r",
".",
"ace",
".",
"httprouter",
".",
"Handle",
"(",
"method",
",",
"r",
".",
"path",
"(",
"path",
")",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"params",
"httprouter",
".",
"Params",
")",
"{",
"c",
":=",
"r",
".",
"ace",
".",
"createContext",
"(",
"w",
",",
"req",
")",
"\n",
"c",
".",
"params",
"=",
"params",
"\n",
"c",
".",
"handlers",
"=",
"handlers",
"\n",
"c",
".",
"Next",
"(",
")",
"\n",
"r",
".",
"ace",
".",
"pool",
".",
"Put",
"(",
"c",
")",
"\n",
"}",
")",
"\n",
"}"
] | //Handle handle with specific method | [
"Handle",
"handle",
"with",
"specific",
"method"
] | ba79f505f4167588c521eae1f7691fdf360a574a | https://github.com/plimble/ace/blob/ba79f505f4167588c521eae1f7691fdf360a574a/router.go#L126-L135 |
3,332 | rafaeljesus/rabbus | rabbus.go | New | func New(dsn string, options ...Option) (*Rabbus, error) {
r := &Rabbus{
emit: make(chan Message),
emitErr: make(chan error),
emitOk: make(chan struct{}),
reconn: make(chan struct{}),
exDeclared: make(map[string]struct{}),
}
for _, o := range options {
if err := o(r); err != nil {
return nil, err
}
}
if r.Amqp == nil {
amqpWrapper, err := amqpWrap.New(dsn, r.config.isExchangePassive)
if err != nil {
return nil, err
}
r.Amqp = amqpWrapper
}
if err := r.WithQos(
r.config.qos.prefetchCount,
r.config.qos.prefetchSize,
r.config.qos.global,
); err != nil {
return nil, err
}
r.config.dsn = dsn
r.breaker = gobreaker.NewCircuitBreaker(newBreakerSettings(r.config))
return r, nil
} | go | func New(dsn string, options ...Option) (*Rabbus, error) {
r := &Rabbus{
emit: make(chan Message),
emitErr: make(chan error),
emitOk: make(chan struct{}),
reconn: make(chan struct{}),
exDeclared: make(map[string]struct{}),
}
for _, o := range options {
if err := o(r); err != nil {
return nil, err
}
}
if r.Amqp == nil {
amqpWrapper, err := amqpWrap.New(dsn, r.config.isExchangePassive)
if err != nil {
return nil, err
}
r.Amqp = amqpWrapper
}
if err := r.WithQos(
r.config.qos.prefetchCount,
r.config.qos.prefetchSize,
r.config.qos.global,
); err != nil {
return nil, err
}
r.config.dsn = dsn
r.breaker = gobreaker.NewCircuitBreaker(newBreakerSettings(r.config))
return r, nil
} | [
"func",
"New",
"(",
"dsn",
"string",
",",
"options",
"...",
"Option",
")",
"(",
"*",
"Rabbus",
",",
"error",
")",
"{",
"r",
":=",
"&",
"Rabbus",
"{",
"emit",
":",
"make",
"(",
"chan",
"Message",
")",
",",
"emitErr",
":",
"make",
"(",
"chan",
"error",
")",
",",
"emitOk",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"reconn",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"exDeclared",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
",",
"}",
"\n\n",
"for",
"_",
",",
"o",
":=",
"range",
"options",
"{",
"if",
"err",
":=",
"o",
"(",
"r",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"r",
".",
"Amqp",
"==",
"nil",
"{",
"amqpWrapper",
",",
"err",
":=",
"amqpWrap",
".",
"New",
"(",
"dsn",
",",
"r",
".",
"config",
".",
"isExchangePassive",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"r",
".",
"Amqp",
"=",
"amqpWrapper",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"r",
".",
"WithQos",
"(",
"r",
".",
"config",
".",
"qos",
".",
"prefetchCount",
",",
"r",
".",
"config",
".",
"qos",
".",
"prefetchSize",
",",
"r",
".",
"config",
".",
"qos",
".",
"global",
",",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"r",
".",
"config",
".",
"dsn",
"=",
"dsn",
"\n",
"r",
".",
"breaker",
"=",
"gobreaker",
".",
"NewCircuitBreaker",
"(",
"newBreakerSettings",
"(",
"r",
".",
"config",
")",
")",
"\n\n",
"return",
"r",
",",
"nil",
"\n",
"}"
] | // New returns a new Rabbus configured with the
// variables from the config parameter, or returning an non-nil err
// if an error occurred while creating connection and channel. | [
"New",
"returns",
"a",
"new",
"Rabbus",
"configured",
"with",
"the",
"variables",
"from",
"the",
"config",
"parameter",
"or",
"returning",
"an",
"non",
"-",
"nil",
"err",
"if",
"an",
"error",
"occurred",
"while",
"creating",
"connection",
"and",
"channel",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L166-L201 |
3,333 | rafaeljesus/rabbus | rabbus.go | Run | func (r *Rabbus) Run(ctx context.Context) error {
notifyClose := r.NotifyClose(make(chan *amqp.Error))
for {
select {
case m, ok := <-r.emit:
if !ok {
return errors.New("unexpected close of emit channel")
}
r.produce(m)
case err := <-notifyClose:
if err == nil {
// "… on a graceful close, no error will be sent."
return nil
}
r.handleAmqpClose(err)
// We have reconnected, so we need a new NotifyClose again.
notifyClose = r.NotifyClose(make(chan *amqp.Error))
case <-ctx.Done():
return ctx.Err()
}
}
} | go | func (r *Rabbus) Run(ctx context.Context) error {
notifyClose := r.NotifyClose(make(chan *amqp.Error))
for {
select {
case m, ok := <-r.emit:
if !ok {
return errors.New("unexpected close of emit channel")
}
r.produce(m)
case err := <-notifyClose:
if err == nil {
// "… on a graceful close, no error will be sent."
return nil
}
r.handleAmqpClose(err)
// We have reconnected, so we need a new NotifyClose again.
notifyClose = r.NotifyClose(make(chan *amqp.Error))
case <-ctx.Done():
return ctx.Err()
}
}
} | [
"func",
"(",
"r",
"*",
"Rabbus",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"notifyClose",
":=",
"r",
".",
"NotifyClose",
"(",
"make",
"(",
"chan",
"*",
"amqp",
".",
"Error",
")",
")",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"m",
",",
"ok",
":=",
"<-",
"r",
".",
"emit",
":",
"if",
"!",
"ok",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"r",
".",
"produce",
"(",
"m",
")",
"\n\n",
"case",
"err",
":=",
"<-",
"notifyClose",
":",
"if",
"err",
"==",
"nil",
"{",
"// \"… on a graceful close, no error will be sent.\"",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
".",
"handleAmqpClose",
"(",
"err",
")",
"\n\n",
"// We have reconnected, so we need a new NotifyClose again.",
"notifyClose",
"=",
"r",
".",
"NotifyClose",
"(",
"make",
"(",
"chan",
"*",
"amqp",
".",
"Error",
")",
")",
"\n\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // Run starts rabbus channels for emitting and listening for amqp connection close
// returns ctx error in case of any. | [
"Run",
"starts",
"rabbus",
"channels",
"for",
"emitting",
"and",
"listening",
"for",
"amqp",
"connection",
"close",
"returns",
"ctx",
"error",
"in",
"case",
"of",
"any",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L205-L232 |
3,334 | rafaeljesus/rabbus | rabbus.go | Listen | func (r *Rabbus) Listen(c ListenConfig) (chan ConsumerMessage, error) {
if err := c.validate(); err != nil {
return nil, err
}
msgs, err := r.CreateConsumer(c.Exchange, c.Key, c.Kind, c.Queue, r.config.durable)
if err != nil {
return nil, err
}
r.mu.Lock()
r.conDeclared++ // increase the declared consumers counter
r.exDeclared[c.Exchange] = struct{}{}
r.mu.Unlock()
messages := make(chan ConsumerMessage, 256)
go r.wrapMessage(c, msgs, messages)
go r.listenReconn(c, messages)
return messages, nil
} | go | func (r *Rabbus) Listen(c ListenConfig) (chan ConsumerMessage, error) {
if err := c.validate(); err != nil {
return nil, err
}
msgs, err := r.CreateConsumer(c.Exchange, c.Key, c.Kind, c.Queue, r.config.durable)
if err != nil {
return nil, err
}
r.mu.Lock()
r.conDeclared++ // increase the declared consumers counter
r.exDeclared[c.Exchange] = struct{}{}
r.mu.Unlock()
messages := make(chan ConsumerMessage, 256)
go r.wrapMessage(c, msgs, messages)
go r.listenReconn(c, messages)
return messages, nil
} | [
"func",
"(",
"r",
"*",
"Rabbus",
")",
"Listen",
"(",
"c",
"ListenConfig",
")",
"(",
"chan",
"ConsumerMessage",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"msgs",
",",
"err",
":=",
"r",
".",
"CreateConsumer",
"(",
"c",
".",
"Exchange",
",",
"c",
".",
"Key",
",",
"c",
".",
"Kind",
",",
"c",
".",
"Queue",
",",
"r",
".",
"config",
".",
"durable",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"r",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"conDeclared",
"++",
"// increase the declared consumers counter",
"\n",
"r",
".",
"exDeclared",
"[",
"c",
".",
"Exchange",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"r",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"messages",
":=",
"make",
"(",
"chan",
"ConsumerMessage",
",",
"256",
")",
"\n",
"go",
"r",
".",
"wrapMessage",
"(",
"c",
",",
"msgs",
",",
"messages",
")",
"\n",
"go",
"r",
".",
"listenReconn",
"(",
"c",
",",
"messages",
")",
"\n\n",
"return",
"messages",
",",
"nil",
"\n",
"}"
] | // Listen to a message from RabbitMQ, returns
// an error if exchange, queue name and function handler not passed or if an error occurred while creating
// amqp consumer. | [
"Listen",
"to",
"a",
"message",
"from",
"RabbitMQ",
"returns",
"an",
"error",
"if",
"exchange",
"queue",
"name",
"and",
"function",
"handler",
"not",
"passed",
"or",
"if",
"an",
"error",
"occurred",
"while",
"creating",
"amqp",
"consumer",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L246-L266 |
3,335 | rafaeljesus/rabbus | rabbus.go | Close | func (r *Rabbus) Close() error {
err := r.Amqp.Close()
close(r.emit)
close(r.emitOk)
close(r.emitErr)
close(r.reconn)
return err
} | go | func (r *Rabbus) Close() error {
err := r.Amqp.Close()
close(r.emit)
close(r.emitOk)
close(r.emitErr)
close(r.reconn)
return err
} | [
"func",
"(",
"r",
"*",
"Rabbus",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"r",
".",
"Amqp",
".",
"Close",
"(",
")",
"\n",
"close",
"(",
"r",
".",
"emit",
")",
"\n",
"close",
"(",
"r",
".",
"emitOk",
")",
"\n",
"close",
"(",
"r",
".",
"emitErr",
")",
"\n",
"close",
"(",
"r",
".",
"reconn",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close channels and attempt to close channel and connection. | [
"Close",
"channels",
"and",
"attempt",
"to",
"close",
"channel",
"and",
"connection",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L269-L276 |
3,336 | rafaeljesus/rabbus | rabbus.go | Durable | func Durable(durable bool) Option {
return func(r *Rabbus) error {
r.config.durable = durable
return nil
}
} | go | func Durable(durable bool) Option {
return func(r *Rabbus) error {
r.config.durable = durable
return nil
}
} | [
"func",
"Durable",
"(",
"durable",
"bool",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"durable",
"=",
"durable",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Durable indicates of the queue will survive broker restarts. Default to true. | [
"Durable",
"indicates",
"of",
"the",
"queue",
"will",
"survive",
"broker",
"restarts",
".",
"Default",
"to",
"true",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L321-L326 |
3,337 | rafaeljesus/rabbus | rabbus.go | PassiveExchange | func PassiveExchange(isExchangePassive bool) Option {
return func(r *Rabbus) error {
r.config.isExchangePassive = isExchangePassive
return nil
}
} | go | func PassiveExchange(isExchangePassive bool) Option {
return func(r *Rabbus) error {
r.config.isExchangePassive = isExchangePassive
return nil
}
} | [
"func",
"PassiveExchange",
"(",
"isExchangePassive",
"bool",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"isExchangePassive",
"=",
"isExchangePassive",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // PassiveExchange forces passive connection with all exchanges using
// amqp's ExchangeDeclarePassive instead the default ExchangeDeclare | [
"PassiveExchange",
"forces",
"passive",
"connection",
"with",
"all",
"exchanges",
"using",
"amqp",
"s",
"ExchangeDeclarePassive",
"instead",
"the",
"default",
"ExchangeDeclare"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L330-L335 |
3,338 | rafaeljesus/rabbus | rabbus.go | PrefetchCount | func PrefetchCount(count int) Option {
return func(r *Rabbus) error {
r.config.qos.prefetchCount = count
return nil
}
} | go | func PrefetchCount(count int) Option {
return func(r *Rabbus) error {
r.config.qos.prefetchCount = count
return nil
}
} | [
"func",
"PrefetchCount",
"(",
"count",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"qos",
".",
"prefetchCount",
"=",
"count",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // PrefetchCount limit the number of unacknowledged messages. | [
"PrefetchCount",
"limit",
"the",
"number",
"of",
"unacknowledged",
"messages",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L338-L343 |
3,339 | rafaeljesus/rabbus | rabbus.go | PrefetchSize | func PrefetchSize(size int) Option {
return func(r *Rabbus) error {
r.config.qos.prefetchSize = size
return nil
}
} | go | func PrefetchSize(size int) Option {
return func(r *Rabbus) error {
r.config.qos.prefetchSize = size
return nil
}
} | [
"func",
"PrefetchSize",
"(",
"size",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"qos",
".",
"prefetchSize",
"=",
"size",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // PrefetchSize when greater than zero, the server will try to keep at least
// that many bytes of deliveries flushed to the network before receiving
// acknowledgments from the consumers. | [
"PrefetchSize",
"when",
"greater",
"than",
"zero",
"the",
"server",
"will",
"try",
"to",
"keep",
"at",
"least",
"that",
"many",
"bytes",
"of",
"deliveries",
"flushed",
"to",
"the",
"network",
"before",
"receiving",
"acknowledgments",
"from",
"the",
"consumers",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L348-L353 |
3,340 | rafaeljesus/rabbus | rabbus.go | QosGlobal | func QosGlobal(global bool) Option {
return func(r *Rabbus) error {
r.config.qos.global = global
return nil
}
} | go | func QosGlobal(global bool) Option {
return func(r *Rabbus) error {
r.config.qos.global = global
return nil
}
} | [
"func",
"QosGlobal",
"(",
"global",
"bool",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"qos",
".",
"global",
"=",
"global",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // QosGlobal when global is true, these Qos settings apply to all existing and future
// consumers on all channels on the same connection. When false, the Channel.Qos
// settings will apply to all existing and future consumers on this channel.
// RabbitMQ does not implement the global flag. | [
"QosGlobal",
"when",
"global",
"is",
"true",
"these",
"Qos",
"settings",
"apply",
"to",
"all",
"existing",
"and",
"future",
"consumers",
"on",
"all",
"channels",
"on",
"the",
"same",
"connection",
".",
"When",
"false",
"the",
"Channel",
".",
"Qos",
"settings",
"will",
"apply",
"to",
"all",
"existing",
"and",
"future",
"consumers",
"on",
"this",
"channel",
".",
"RabbitMQ",
"does",
"not",
"implement",
"the",
"global",
"flag",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L359-L364 |
3,341 | rafaeljesus/rabbus | rabbus.go | Attempts | func Attempts(attempts int) Option {
return func(r *Rabbus) error {
r.config.retryCfg.attempts = attempts
return nil
}
} | go | func Attempts(attempts int) Option {
return func(r *Rabbus) error {
r.config.retryCfg.attempts = attempts
return nil
}
} | [
"func",
"Attempts",
"(",
"attempts",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"retryCfg",
".",
"attempts",
"=",
"attempts",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Attempts is the max number of retries on broker outages. | [
"Attempts",
"is",
"the",
"max",
"number",
"of",
"retries",
"on",
"broker",
"outages",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L367-L372 |
3,342 | rafaeljesus/rabbus | rabbus.go | Sleep | func Sleep(sleep time.Duration) Option {
return func(r *Rabbus) error {
if sleep == 0 {
r.config.retryCfg.reconnectSleep = time.Second * 10
}
r.config.retryCfg.sleep = sleep
return nil
}
} | go | func Sleep(sleep time.Duration) Option {
return func(r *Rabbus) error {
if sleep == 0 {
r.config.retryCfg.reconnectSleep = time.Second * 10
}
r.config.retryCfg.sleep = sleep
return nil
}
} | [
"func",
"Sleep",
"(",
"sleep",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"if",
"sleep",
"==",
"0",
"{",
"r",
".",
"config",
".",
"retryCfg",
".",
"reconnectSleep",
"=",
"time",
".",
"Second",
"*",
"10",
"\n",
"}",
"\n",
"r",
".",
"config",
".",
"retryCfg",
".",
"sleep",
"=",
"sleep",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Sleep is the sleep time of the retry mechanism. | [
"Sleep",
"is",
"the",
"sleep",
"time",
"of",
"the",
"retry",
"mechanism",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L375-L383 |
3,343 | rafaeljesus/rabbus | rabbus.go | BreakerInterval | func BreakerInterval(interval time.Duration) Option {
return func(r *Rabbus) error {
r.config.breaker.interval = interval
return nil
}
} | go | func BreakerInterval(interval time.Duration) Option {
return func(r *Rabbus) error {
r.config.breaker.interval = interval
return nil
}
} | [
"func",
"BreakerInterval",
"(",
"interval",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"breaker",
".",
"interval",
"=",
"interval",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // BreakerInterval is the cyclic period of the closed state for CircuitBreaker to clear the internal counts,
// If Interval is 0, CircuitBreaker doesn't clear the internal counts during the closed state. | [
"BreakerInterval",
"is",
"the",
"cyclic",
"period",
"of",
"the",
"closed",
"state",
"for",
"CircuitBreaker",
"to",
"clear",
"the",
"internal",
"counts",
"If",
"Interval",
"is",
"0",
"CircuitBreaker",
"doesn",
"t",
"clear",
"the",
"internal",
"counts",
"during",
"the",
"closed",
"state",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L387-L392 |
3,344 | rafaeljesus/rabbus | rabbus.go | BreakerTimeout | func BreakerTimeout(timeout time.Duration) Option {
return func(r *Rabbus) error {
r.config.breaker.timeout = timeout
return nil
}
} | go | func BreakerTimeout(timeout time.Duration) Option {
return func(r *Rabbus) error {
r.config.breaker.timeout = timeout
return nil
}
} | [
"func",
"BreakerTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"breaker",
".",
"timeout",
"=",
"timeout",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // BreakerTimeout is the period of the open state, after which the state of CircuitBreaker becomes half-open.
// If Timeout is 0, the timeout value of CircuitBreaker is set to 60 seconds. | [
"BreakerTimeout",
"is",
"the",
"period",
"of",
"the",
"open",
"state",
"after",
"which",
"the",
"state",
"of",
"CircuitBreaker",
"becomes",
"half",
"-",
"open",
".",
"If",
"Timeout",
"is",
"0",
"the",
"timeout",
"value",
"of",
"CircuitBreaker",
"is",
"set",
"to",
"60",
"seconds",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L396-L401 |
3,345 | rafaeljesus/rabbus | rabbus.go | Threshold | func Threshold(threshold uint32) Option {
return func(r *Rabbus) error {
if threshold == 0 {
threshold = 5
}
r.config.breaker.threshold = threshold
return nil
}
} | go | func Threshold(threshold uint32) Option {
return func(r *Rabbus) error {
if threshold == 0 {
threshold = 5
}
r.config.breaker.threshold = threshold
return nil
}
} | [
"func",
"Threshold",
"(",
"threshold",
"uint32",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"if",
"threshold",
"==",
"0",
"{",
"threshold",
"=",
"5",
"\n",
"}",
"\n",
"r",
".",
"config",
".",
"breaker",
".",
"threshold",
"=",
"threshold",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // Threshold when a threshold of failures has been reached, future calls to the broker will not run.
// During this state, the circuit breaker will periodically allow the calls to run and, if it is successful,
// will start running the function again. Default value is 5. | [
"Threshold",
"when",
"a",
"threshold",
"of",
"failures",
"has",
"been",
"reached",
"future",
"calls",
"to",
"the",
"broker",
"will",
"not",
"run",
".",
"During",
"this",
"state",
"the",
"circuit",
"breaker",
"will",
"periodically",
"allow",
"the",
"calls",
"to",
"run",
"and",
"if",
"it",
"is",
"successful",
"will",
"start",
"running",
"the",
"function",
"again",
".",
"Default",
"value",
"is",
"5",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L406-L414 |
3,346 | rafaeljesus/rabbus | rabbus.go | OnStateChange | func OnStateChange(fn OnStateChangeFunc) Option {
return func(r *Rabbus) error {
r.config.breaker.onStateChange = fn
return nil
}
} | go | func OnStateChange(fn OnStateChangeFunc) Option {
return func(r *Rabbus) error {
r.config.breaker.onStateChange = fn
return nil
}
} | [
"func",
"OnStateChange",
"(",
"fn",
"OnStateChangeFunc",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"r",
".",
"config",
".",
"breaker",
".",
"onStateChange",
"=",
"fn",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // OnStateChange is called whenever the state of CircuitBreaker changes. | [
"OnStateChange",
"is",
"called",
"whenever",
"the",
"state",
"of",
"CircuitBreaker",
"changes",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L417-L422 |
3,347 | rafaeljesus/rabbus | rabbus.go | AmqpProvider | func AmqpProvider(provider Amqp) Option {
return func(r *Rabbus) error {
if provider != nil {
r.Amqp = provider
return nil
}
return errors.New("unexpected amqp provider")
}
} | go | func AmqpProvider(provider Amqp) Option {
return func(r *Rabbus) error {
if provider != nil {
r.Amqp = provider
return nil
}
return errors.New("unexpected amqp provider")
}
} | [
"func",
"AmqpProvider",
"(",
"provider",
"Amqp",
")",
"Option",
"{",
"return",
"func",
"(",
"r",
"*",
"Rabbus",
")",
"error",
"{",
"if",
"provider",
"!=",
"nil",
"{",
"r",
".",
"Amqp",
"=",
"provider",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // AmqpProvider expose a interface for interacting with amqp broker | [
"AmqpProvider",
"expose",
"a",
"interface",
"for",
"interacting",
"with",
"amqp",
"broker"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/rabbus.go#L425-L433 |
3,348 | rafaeljesus/rabbus | consumer_message.go | Ack | func (cm ConsumerMessage) Ack(multiple bool) error {
return cm.delivery.Ack(multiple)
} | go | func (cm ConsumerMessage) Ack(multiple bool) error {
return cm.delivery.Ack(multiple)
} | [
"func",
"(",
"cm",
"ConsumerMessage",
")",
"Ack",
"(",
"multiple",
"bool",
")",
"error",
"{",
"return",
"cm",
".",
"delivery",
".",
"Ack",
"(",
"multiple",
")",
"\n",
"}"
] | // Ack delegates an acknowledgement through the Acknowledger interface that the client or server has finished work on a delivery.
// All deliveries in AMQP must be acknowledged. If you called Channel.Consume with autoAck true then the server will be automatically ack each message and this method should not be called. Otherwise, you must call Delivery.Ack after you have successfully processed this delivery.
// When multiple is true, this delivery and all prior unacknowledged deliveries on the same channel will be acknowledged. This is useful for batch processing of deliveries.
// An error will indicate that the acknowledge could not be delivered to the channel it was sent from.
// Either Delivery.Ack, Delivery.Reject or Delivery.Nack must be called for every delivery that is not automatically acknowledged. | [
"Ack",
"delegates",
"an",
"acknowledgement",
"through",
"the",
"Acknowledger",
"interface",
"that",
"the",
"client",
"or",
"server",
"has",
"finished",
"work",
"on",
"a",
"delivery",
".",
"All",
"deliveries",
"in",
"AMQP",
"must",
"be",
"acknowledged",
".",
"If",
"you",
"called",
"Channel",
".",
"Consume",
"with",
"autoAck",
"true",
"then",
"the",
"server",
"will",
"be",
"automatically",
"ack",
"each",
"message",
"and",
"this",
"method",
"should",
"not",
"be",
"called",
".",
"Otherwise",
"you",
"must",
"call",
"Delivery",
".",
"Ack",
"after",
"you",
"have",
"successfully",
"processed",
"this",
"delivery",
".",
"When",
"multiple",
"is",
"true",
"this",
"delivery",
"and",
"all",
"prior",
"unacknowledged",
"deliveries",
"on",
"the",
"same",
"channel",
"will",
"be",
"acknowledged",
".",
"This",
"is",
"useful",
"for",
"batch",
"processing",
"of",
"deliveries",
".",
"An",
"error",
"will",
"indicate",
"that",
"the",
"acknowledge",
"could",
"not",
"be",
"delivered",
"to",
"the",
"channel",
"it",
"was",
"sent",
"from",
".",
"Either",
"Delivery",
".",
"Ack",
"Delivery",
".",
"Reject",
"or",
"Delivery",
".",
"Nack",
"must",
"be",
"called",
"for",
"every",
"delivery",
"that",
"is",
"not",
"automatically",
"acknowledged",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/consumer_message.go#L75-L77 |
3,349 | rafaeljesus/rabbus | consumer_message.go | Reject | func (cm ConsumerMessage) Reject(requeue bool) error {
return cm.delivery.Reject(requeue)
} | go | func (cm ConsumerMessage) Reject(requeue bool) error {
return cm.delivery.Reject(requeue)
} | [
"func",
"(",
"cm",
"ConsumerMessage",
")",
"Reject",
"(",
"requeue",
"bool",
")",
"error",
"{",
"return",
"cm",
".",
"delivery",
".",
"Reject",
"(",
"requeue",
")",
"\n",
"}"
] | // Reject delegates a negatively acknowledgement through the Acknowledger interface.
// When requeue is true, queue this message to be delivered to a consumer on a different channel. When requeue is false or the server is unable to queue this message, it will be dropped.
// If you are batch processing deliveries, and your server supports it, prefer Delivery.Nack.
// Either Delivery.Ack, Delivery.Reject or Delivery.Nack must be called for every delivery that is not automatically acknowledged. | [
"Reject",
"delegates",
"a",
"negatively",
"acknowledgement",
"through",
"the",
"Acknowledger",
"interface",
".",
"When",
"requeue",
"is",
"true",
"queue",
"this",
"message",
"to",
"be",
"delivered",
"to",
"a",
"consumer",
"on",
"a",
"different",
"channel",
".",
"When",
"requeue",
"is",
"false",
"or",
"the",
"server",
"is",
"unable",
"to",
"queue",
"this",
"message",
"it",
"will",
"be",
"dropped",
".",
"If",
"you",
"are",
"batch",
"processing",
"deliveries",
"and",
"your",
"server",
"supports",
"it",
"prefer",
"Delivery",
".",
"Nack",
".",
"Either",
"Delivery",
".",
"Ack",
"Delivery",
".",
"Reject",
"or",
"Delivery",
".",
"Nack",
"must",
"be",
"called",
"for",
"every",
"delivery",
"that",
"is",
"not",
"automatically",
"acknowledged",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/consumer_message.go#L92-L94 |
3,350 | rafaeljesus/rabbus | internal/amqp/amqp.go | New | func New(dsn string, pex bool) (*Amqp, error) {
conn, ch, err := createConnAndChan(dsn)
if err != nil {
return nil, err
}
return &Amqp{
conn: conn,
ch: ch,
passiveExchange: pex,
}, nil
} | go | func New(dsn string, pex bool) (*Amqp, error) {
conn, ch, err := createConnAndChan(dsn)
if err != nil {
return nil, err
}
return &Amqp{
conn: conn,
ch: ch,
passiveExchange: pex,
}, nil
} | [
"func",
"New",
"(",
"dsn",
"string",
",",
"pex",
"bool",
")",
"(",
"*",
"Amqp",
",",
"error",
")",
"{",
"conn",
",",
"ch",
",",
"err",
":=",
"createConnAndChan",
"(",
"dsn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"Amqp",
"{",
"conn",
":",
"conn",
",",
"ch",
":",
"ch",
",",
"passiveExchange",
":",
"pex",
",",
"}",
",",
"nil",
"\n",
"}"
] | // New returns a new Amqp configured, or returning an non-nil err
// if an error occurred while creating connection or channel. | [
"New",
"returns",
"a",
"new",
"Amqp",
"configured",
"or",
"returning",
"an",
"non",
"-",
"nil",
"err",
"if",
"an",
"error",
"occurred",
"while",
"creating",
"connection",
"or",
"channel",
"."
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/internal/amqp/amqp.go#L16-L27 |
3,351 | rafaeljesus/rabbus | internal/amqp/amqp.go | Publish | func (ai *Amqp) Publish(exchange, key string, opts amqp.Publishing) error {
return ai.ch.Publish(exchange, key, false, false, opts)
} | go | func (ai *Amqp) Publish(exchange, key string, opts amqp.Publishing) error {
return ai.ch.Publish(exchange, key, false, false, opts)
} | [
"func",
"(",
"ai",
"*",
"Amqp",
")",
"Publish",
"(",
"exchange",
",",
"key",
"string",
",",
"opts",
"amqp",
".",
"Publishing",
")",
"error",
"{",
"return",
"ai",
".",
"ch",
".",
"Publish",
"(",
"exchange",
",",
"key",
",",
"false",
",",
"false",
",",
"opts",
")",
"\n",
"}"
] | // Publish wraps amqp.Publish method | [
"Publish",
"wraps",
"amqp",
".",
"Publish",
"method"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/internal/amqp/amqp.go#L30-L32 |
3,352 | rafaeljesus/rabbus | internal/amqp/amqp.go | CreateConsumer | func (ai *Amqp) CreateConsumer(exchange, key, kind, queue string, durable bool) (<-chan amqp.Delivery, error) {
if err := ai.WithExchange(exchange, kind, durable); err != nil {
return nil, err
}
q, err := ai.ch.QueueDeclare(queue, durable, false, false, false, nil)
if err != nil {
return nil, err
}
if err := ai.ch.QueueBind(q.Name, key, exchange, false, nil); err != nil {
return nil, err
}
return ai.ch.Consume(q.Name, "", false, false, false, false, nil)
} | go | func (ai *Amqp) CreateConsumer(exchange, key, kind, queue string, durable bool) (<-chan amqp.Delivery, error) {
if err := ai.WithExchange(exchange, kind, durable); err != nil {
return nil, err
}
q, err := ai.ch.QueueDeclare(queue, durable, false, false, false, nil)
if err != nil {
return nil, err
}
if err := ai.ch.QueueBind(q.Name, key, exchange, false, nil); err != nil {
return nil, err
}
return ai.ch.Consume(q.Name, "", false, false, false, false, nil)
} | [
"func",
"(",
"ai",
"*",
"Amqp",
")",
"CreateConsumer",
"(",
"exchange",
",",
"key",
",",
"kind",
",",
"queue",
"string",
",",
"durable",
"bool",
")",
"(",
"<-",
"chan",
"amqp",
".",
"Delivery",
",",
"error",
")",
"{",
"if",
"err",
":=",
"ai",
".",
"WithExchange",
"(",
"exchange",
",",
"kind",
",",
"durable",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"q",
",",
"err",
":=",
"ai",
".",
"ch",
".",
"QueueDeclare",
"(",
"queue",
",",
"durable",
",",
"false",
",",
"false",
",",
"false",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"ai",
".",
"ch",
".",
"QueueBind",
"(",
"q",
".",
"Name",
",",
"key",
",",
"exchange",
",",
"false",
",",
"nil",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"ai",
".",
"ch",
".",
"Consume",
"(",
"q",
".",
"Name",
",",
"\"",
"\"",
",",
"false",
",",
"false",
",",
"false",
",",
"false",
",",
"nil",
")",
"\n",
"}"
] | // CreateConsumer creates a amqp consumer | [
"CreateConsumer",
"creates",
"a",
"amqp",
"consumer"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/internal/amqp/amqp.go#L35-L50 |
3,353 | rafaeljesus/rabbus | internal/amqp/amqp.go | WithExchange | func (ai *Amqp) WithExchange(exchange, kind string, durable bool) error {
if ai.passiveExchange {
return ai.ch.ExchangeDeclarePassive(exchange, kind, durable, false, false, false, nil)
}
return ai.ch.ExchangeDeclare(exchange, kind, durable, false, false, false, nil)
} | go | func (ai *Amqp) WithExchange(exchange, kind string, durable bool) error {
if ai.passiveExchange {
return ai.ch.ExchangeDeclarePassive(exchange, kind, durable, false, false, false, nil)
}
return ai.ch.ExchangeDeclare(exchange, kind, durable, false, false, false, nil)
} | [
"func",
"(",
"ai",
"*",
"Amqp",
")",
"WithExchange",
"(",
"exchange",
",",
"kind",
"string",
",",
"durable",
"bool",
")",
"error",
"{",
"if",
"ai",
".",
"passiveExchange",
"{",
"return",
"ai",
".",
"ch",
".",
"ExchangeDeclarePassive",
"(",
"exchange",
",",
"kind",
",",
"durable",
",",
"false",
",",
"false",
",",
"false",
",",
"nil",
")",
"\n",
"}",
"\n\n",
"return",
"ai",
".",
"ch",
".",
"ExchangeDeclare",
"(",
"exchange",
",",
"kind",
",",
"durable",
",",
"false",
",",
"false",
",",
"false",
",",
"nil",
")",
"\n",
"}"
] | // WithExchange creates a amqp exchange | [
"WithExchange",
"creates",
"a",
"amqp",
"exchange"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/internal/amqp/amqp.go#L53-L59 |
3,354 | rafaeljesus/rabbus | internal/amqp/amqp.go | WithQos | func (ai *Amqp) WithQos(count, size int, global bool) error {
return ai.ch.Qos(count, size, global)
} | go | func (ai *Amqp) WithQos(count, size int, global bool) error {
return ai.ch.Qos(count, size, global)
} | [
"func",
"(",
"ai",
"*",
"Amqp",
")",
"WithQos",
"(",
"count",
",",
"size",
"int",
",",
"global",
"bool",
")",
"error",
"{",
"return",
"ai",
".",
"ch",
".",
"Qos",
"(",
"count",
",",
"size",
",",
"global",
")",
"\n",
"}"
] | // WithQos wrapper over amqp.Qos method | [
"WithQos",
"wrapper",
"over",
"amqp",
".",
"Qos",
"method"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/internal/amqp/amqp.go#L62-L64 |
3,355 | rafaeljesus/rabbus | internal/amqp/amqp.go | NotifyClose | func (ai *Amqp) NotifyClose(c chan *amqp.Error) chan *amqp.Error {
return ai.conn.NotifyClose(c)
} | go | func (ai *Amqp) NotifyClose(c chan *amqp.Error) chan *amqp.Error {
return ai.conn.NotifyClose(c)
} | [
"func",
"(",
"ai",
"*",
"Amqp",
")",
"NotifyClose",
"(",
"c",
"chan",
"*",
"amqp",
".",
"Error",
")",
"chan",
"*",
"amqp",
".",
"Error",
"{",
"return",
"ai",
".",
"conn",
".",
"NotifyClose",
"(",
"c",
")",
"\n",
"}"
] | // NotifyClose wrapper over notifyClose method | [
"NotifyClose",
"wrapper",
"over",
"notifyClose",
"method"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/internal/amqp/amqp.go#L67-L69 |
3,356 | rafaeljesus/rabbus | internal/amqp/amqp.go | Close | func (ai *Amqp) Close() error {
if err := ai.ch.Close(); err != nil {
return err
}
if ai.conn != nil {
return ai.conn.Close()
}
return nil
} | go | func (ai *Amqp) Close() error {
if err := ai.ch.Close(); err != nil {
return err
}
if ai.conn != nil {
return ai.conn.Close()
}
return nil
} | [
"func",
"(",
"ai",
"*",
"Amqp",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"ai",
".",
"ch",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"ai",
".",
"conn",
"!=",
"nil",
"{",
"return",
"ai",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Close closes the running amqp connection and channel | [
"Close",
"closes",
"the",
"running",
"amqp",
"connection",
"and",
"channel"
] | 086d921c442ae5210224920df8517fb862ef56d4 | https://github.com/rafaeljesus/rabbus/blob/086d921c442ae5210224920df8517fb862ef56d4/internal/amqp/amqp.go#L72-L82 |
3,357 | a8m/djson | interface.go | Type | func Type(v interface{}) ValueType {
t := Unknown
switch v.(type) {
case nil:
t = Null
case bool:
t = Bool
case string:
t = String
case float64:
t = Number
case []interface{}:
t = Array
case map[string]interface{}:
t = Object
}
return t
} | go | func Type(v interface{}) ValueType {
t := Unknown
switch v.(type) {
case nil:
t = Null
case bool:
t = Bool
case string:
t = String
case float64:
t = Number
case []interface{}:
t = Array
case map[string]interface{}:
t = Object
}
return t
} | [
"func",
"Type",
"(",
"v",
"interface",
"{",
"}",
")",
"ValueType",
"{",
"t",
":=",
"Unknown",
"\n",
"switch",
"v",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",
"t",
"=",
"Null",
"\n",
"case",
"bool",
":",
"t",
"=",
"Bool",
"\n",
"case",
"string",
":",
"t",
"=",
"String",
"\n",
"case",
"float64",
":",
"t",
"=",
"Number",
"\n",
"case",
"[",
"]",
"interface",
"{",
"}",
":",
"t",
"=",
"Array",
"\n",
"case",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
":",
"t",
"=",
"Object",
"\n",
"}",
"\n",
"return",
"t",
"\n",
"}"
] | // Type returns the JSON-type of the given value | [
"Type",
"returns",
"the",
"JSON",
"-",
"type",
"of",
"the",
"given",
"value"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/interface.go#L46-L63 |
3,358 | a8m/djson | decode.go | NewDecoder | func NewDecoder(data []byte) *Decoder {
return &Decoder{
data: data,
end: len(data),
}
} | go | func NewDecoder(data []byte) *Decoder {
return &Decoder{
data: data,
end: len(data),
}
} | [
"func",
"NewDecoder",
"(",
"data",
"[",
"]",
"byte",
")",
"*",
"Decoder",
"{",
"return",
"&",
"Decoder",
"{",
"data",
":",
"data",
",",
"end",
":",
"len",
"(",
"data",
")",
",",
"}",
"\n",
"}"
] | // NewDecoder creates new Decoder from the JSON-encoded data | [
"NewDecoder",
"creates",
"new",
"Decoder",
"from",
"the",
"JSON",
"-",
"encoded",
"data"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/decode.go#L18-L23 |
3,359 | a8m/djson | decode.go | number | func (d *Decoder) number() (float64, error) {
var (
n float64
isFloat bool
c = d.data[d.pos]
start = d.pos
)
// digits first
switch {
case c == '0':
c = d.next()
case '1' <= c && c <= '9':
for ; c >= '0' && c <= '9'; c = d.next() {
n = 10*n + float64(c-'0')
}
}
// . followed by 1 or more digits
if c == '.' {
d.pos++
isFloat = true
if c = d.data[d.pos]; c < '0' && c > '9' {
return 0, d.error(c, "after decimal point in numeric literal")
}
for c = d.next(); '0' <= c && c <= '9'; {
c = d.next()
}
}
// e or E followed by an optional - or + and
// 1 or more digits.
if c == 'e' || c == 'E' {
isFloat = true
if c = d.next(); c == '+' || c == '-' {
if c = d.next(); c < '0' || c > '9' {
return 0, d.error(c, "in exponent of numeric literal")
}
}
for c = d.next(); '0' <= c && c <= '9'; {
c = d.next()
}
}
if isFloat {
var (
err error
sn string
)
if d.usestring {
sn = d.sdata[start:d.pos]
} else {
sn = string(d.data[start:d.pos])
}
if n, err = strconv.ParseFloat(sn, 64); err != nil {
return 0, err
}
}
return n, nil
} | go | func (d *Decoder) number() (float64, error) {
var (
n float64
isFloat bool
c = d.data[d.pos]
start = d.pos
)
// digits first
switch {
case c == '0':
c = d.next()
case '1' <= c && c <= '9':
for ; c >= '0' && c <= '9'; c = d.next() {
n = 10*n + float64(c-'0')
}
}
// . followed by 1 or more digits
if c == '.' {
d.pos++
isFloat = true
if c = d.data[d.pos]; c < '0' && c > '9' {
return 0, d.error(c, "after decimal point in numeric literal")
}
for c = d.next(); '0' <= c && c <= '9'; {
c = d.next()
}
}
// e or E followed by an optional - or + and
// 1 or more digits.
if c == 'e' || c == 'E' {
isFloat = true
if c = d.next(); c == '+' || c == '-' {
if c = d.next(); c < '0' || c > '9' {
return 0, d.error(c, "in exponent of numeric literal")
}
}
for c = d.next(); '0' <= c && c <= '9'; {
c = d.next()
}
}
if isFloat {
var (
err error
sn string
)
if d.usestring {
sn = d.sdata[start:d.pos]
} else {
sn = string(d.data[start:d.pos])
}
if n, err = strconv.ParseFloat(sn, 64); err != nil {
return 0, err
}
}
return n, nil
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"number",
"(",
")",
"(",
"float64",
",",
"error",
")",
"{",
"var",
"(",
"n",
"float64",
"\n",
"isFloat",
"bool",
"\n",
"c",
"=",
"d",
".",
"data",
"[",
"d",
".",
"pos",
"]",
"\n",
"start",
"=",
"d",
".",
"pos",
"\n",
")",
"\n\n",
"// digits first",
"switch",
"{",
"case",
"c",
"==",
"'0'",
":",
"c",
"=",
"d",
".",
"next",
"(",
")",
"\n",
"case",
"'1'",
"<=",
"c",
"&&",
"c",
"<=",
"'9'",
":",
"for",
";",
"c",
">=",
"'0'",
"&&",
"c",
"<=",
"'9'",
";",
"c",
"=",
"d",
".",
"next",
"(",
")",
"{",
"n",
"=",
"10",
"*",
"n",
"+",
"float64",
"(",
"c",
"-",
"'0'",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// . followed by 1 or more digits",
"if",
"c",
"==",
"'.'",
"{",
"d",
".",
"pos",
"++",
"\n",
"isFloat",
"=",
"true",
"\n",
"if",
"c",
"=",
"d",
".",
"data",
"[",
"d",
".",
"pos",
"]",
";",
"c",
"<",
"'0'",
"&&",
"c",
">",
"'9'",
"{",
"return",
"0",
",",
"d",
".",
"error",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"for",
"c",
"=",
"d",
".",
"next",
"(",
")",
";",
"'0'",
"<=",
"c",
"&&",
"c",
"<=",
"'9'",
";",
"{",
"c",
"=",
"d",
".",
"next",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// e or E followed by an optional - or + and",
"// 1 or more digits.",
"if",
"c",
"==",
"'e'",
"||",
"c",
"==",
"'E'",
"{",
"isFloat",
"=",
"true",
"\n",
"if",
"c",
"=",
"d",
".",
"next",
"(",
")",
";",
"c",
"==",
"'+'",
"||",
"c",
"==",
"'-'",
"{",
"if",
"c",
"=",
"d",
".",
"next",
"(",
")",
";",
"c",
"<",
"'0'",
"||",
"c",
">",
"'9'",
"{",
"return",
"0",
",",
"d",
".",
"error",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"c",
"=",
"d",
".",
"next",
"(",
")",
";",
"'0'",
"<=",
"c",
"&&",
"c",
"<=",
"'9'",
";",
"{",
"c",
"=",
"d",
".",
"next",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"isFloat",
"{",
"var",
"(",
"err",
"error",
"\n",
"sn",
"string",
"\n",
")",
"\n",
"if",
"d",
".",
"usestring",
"{",
"sn",
"=",
"d",
".",
"sdata",
"[",
"start",
":",
"d",
".",
"pos",
"]",
"\n",
"}",
"else",
"{",
"sn",
"=",
"string",
"(",
"d",
".",
"data",
"[",
"start",
":",
"d",
".",
"pos",
"]",
")",
"\n",
"}",
"\n",
"if",
"n",
",",
"err",
"=",
"strconv",
".",
"ParseFloat",
"(",
"sn",
",",
"64",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"n",
",",
"nil",
"\n",
"}"
] | // number called by `any` after reading number between 0 to 9 | [
"number",
"called",
"by",
"any",
"after",
"reading",
"number",
"between",
"0",
"to",
"9"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/decode.go#L259-L318 |
3,360 | a8m/djson | decode.go | array | func (d *Decoder) array() ([]interface{}, error) {
// the '[' token already scanned
d.pos++
var (
c byte
v interface{}
err error
array = make([]interface{}, 0)
)
// look ahead for ] - if the array is empty.
if c = d.skipSpaces(); c == ']' {
d.pos++
goto out
}
scan:
if v, err = d.any(); err != nil {
goto out
}
array = append(array, v)
// next token must be ',' or ']'
if c = d.skipSpaces(); c == ',' {
d.pos++
goto scan
} else if c == ']' {
d.pos++
} else {
err = d.error(c, "after array element")
}
out:
return array, err
} | go | func (d *Decoder) array() ([]interface{}, error) {
// the '[' token already scanned
d.pos++
var (
c byte
v interface{}
err error
array = make([]interface{}, 0)
)
// look ahead for ] - if the array is empty.
if c = d.skipSpaces(); c == ']' {
d.pos++
goto out
}
scan:
if v, err = d.any(); err != nil {
goto out
}
array = append(array, v)
// next token must be ',' or ']'
if c = d.skipSpaces(); c == ',' {
d.pos++
goto scan
} else if c == ']' {
d.pos++
} else {
err = d.error(c, "after array element")
}
out:
return array, err
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"array",
"(",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// the '[' token already scanned",
"d",
".",
"pos",
"++",
"\n\n",
"var",
"(",
"c",
"byte",
"\n",
"v",
"interface",
"{",
"}",
"\n",
"err",
"error",
"\n",
"array",
"=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
")",
"\n",
")",
"\n\n",
"// look ahead for ] - if the array is empty.",
"if",
"c",
"=",
"d",
".",
"skipSpaces",
"(",
")",
";",
"c",
"==",
"']'",
"{",
"d",
".",
"pos",
"++",
"\n",
"goto",
"out",
"\n",
"}",
"\n\n",
"scan",
":",
"if",
"v",
",",
"err",
"=",
"d",
".",
"any",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"goto",
"out",
"\n",
"}",
"\n\n",
"array",
"=",
"append",
"(",
"array",
",",
"v",
")",
"\n\n",
"// next token must be ',' or ']'",
"if",
"c",
"=",
"d",
".",
"skipSpaces",
"(",
")",
";",
"c",
"==",
"','",
"{",
"d",
".",
"pos",
"++",
"\n",
"goto",
"scan",
"\n",
"}",
"else",
"if",
"c",
"==",
"']'",
"{",
"d",
".",
"pos",
"++",
"\n",
"}",
"else",
"{",
"err",
"=",
"d",
".",
"error",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"out",
":",
"return",
"array",
",",
"err",
"\n",
"}"
] | // array accept valid JSON array value | [
"array",
"accept",
"valid",
"JSON",
"array",
"value"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/decode.go#L321-L357 |
3,361 | a8m/djson | decode.go | object | func (d *Decoder) object() (map[string]interface{}, error) {
// the '{' token already scanned
d.pos++
var (
c byte
k string
v interface{}
err error
obj = make(map[string]interface{})
)
// look ahead for } - if the object has no keys.
if c = d.skipSpaces(); c == '}' {
d.pos++
return obj, nil
}
for {
// read string key
if c = d.skipSpaces(); c != '"' {
err = d.error(c, "looking for beginning of object key string")
break
}
if k, err = d.string(); err != nil {
break
}
// read colon before value
c = d.skipSpaces()
if c != ':' {
err = d.error(c, "after object key")
break
}
d.pos++
// read and assign value
if v, err = d.any(); err != nil {
break
}
obj[k] = v
// next token must be ',' or '}'
if c = d.skipSpaces(); c == '}' {
d.pos++
break
} else if c == ',' {
d.pos++
} else {
err = d.error(c, "after object key:value pair")
break
}
}
return obj, err
} | go | func (d *Decoder) object() (map[string]interface{}, error) {
// the '{' token already scanned
d.pos++
var (
c byte
k string
v interface{}
err error
obj = make(map[string]interface{})
)
// look ahead for } - if the object has no keys.
if c = d.skipSpaces(); c == '}' {
d.pos++
return obj, nil
}
for {
// read string key
if c = d.skipSpaces(); c != '"' {
err = d.error(c, "looking for beginning of object key string")
break
}
if k, err = d.string(); err != nil {
break
}
// read colon before value
c = d.skipSpaces()
if c != ':' {
err = d.error(c, "after object key")
break
}
d.pos++
// read and assign value
if v, err = d.any(); err != nil {
break
}
obj[k] = v
// next token must be ',' or '}'
if c = d.skipSpaces(); c == '}' {
d.pos++
break
} else if c == ',' {
d.pos++
} else {
err = d.error(c, "after object key:value pair")
break
}
}
return obj, err
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"object",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// the '{' token already scanned",
"d",
".",
"pos",
"++",
"\n\n",
"var",
"(",
"c",
"byte",
"\n",
"k",
"string",
"\n",
"v",
"interface",
"{",
"}",
"\n",
"err",
"error",
"\n",
"obj",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
")",
"\n\n",
"// look ahead for } - if the object has no keys.",
"if",
"c",
"=",
"d",
".",
"skipSpaces",
"(",
")",
";",
"c",
"==",
"'}'",
"{",
"d",
".",
"pos",
"++",
"\n",
"return",
"obj",
",",
"nil",
"\n",
"}",
"\n\n",
"for",
"{",
"// read string key",
"if",
"c",
"=",
"d",
".",
"skipSpaces",
"(",
")",
";",
"c",
"!=",
"'\"'",
"{",
"err",
"=",
"d",
".",
"error",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"break",
"\n",
"}",
"\n",
"if",
"k",
",",
"err",
"=",
"d",
".",
"string",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"// read colon before value",
"c",
"=",
"d",
".",
"skipSpaces",
"(",
")",
"\n",
"if",
"c",
"!=",
"':'",
"{",
"err",
"=",
"d",
".",
"error",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"break",
"\n",
"}",
"\n",
"d",
".",
"pos",
"++",
"\n\n",
"// read and assign value",
"if",
"v",
",",
"err",
"=",
"d",
".",
"any",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"obj",
"[",
"k",
"]",
"=",
"v",
"\n\n",
"// next token must be ',' or '}'",
"if",
"c",
"=",
"d",
".",
"skipSpaces",
"(",
")",
";",
"c",
"==",
"'}'",
"{",
"d",
".",
"pos",
"++",
"\n",
"break",
"\n",
"}",
"else",
"if",
"c",
"==",
"','",
"{",
"d",
".",
"pos",
"++",
"\n",
"}",
"else",
"{",
"err",
"=",
"d",
".",
"error",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"obj",
",",
"err",
"\n",
"}"
] | // object accept valid JSON array value | [
"object",
"accept",
"valid",
"JSON",
"array",
"value"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/decode.go#L360-L416 |
3,362 | a8m/djson | decode.go | next | func (d *Decoder) next() byte {
d.pos++
if d.pos < d.end {
return d.data[d.pos]
}
return 0
} | go | func (d *Decoder) next() byte {
d.pos++
if d.pos < d.end {
return d.data[d.pos]
}
return 0
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"next",
"(",
")",
"byte",
"{",
"d",
".",
"pos",
"++",
"\n",
"if",
"d",
".",
"pos",
"<",
"d",
".",
"end",
"{",
"return",
"d",
".",
"data",
"[",
"d",
".",
"pos",
"]",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
] | // next return the next byte in the input | [
"next",
"return",
"the",
"next",
"byte",
"in",
"the",
"input"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/decode.go#L419-L425 |
3,363 | a8m/djson | decode.go | skipSpaces | func (d *Decoder) skipSpaces() byte {
loop:
if d.pos == d.end {
return 0
}
switch c := d.data[d.pos]; c {
case ' ', '\t', '\n', '\r':
d.pos++
goto loop
default:
return c
}
} | go | func (d *Decoder) skipSpaces() byte {
loop:
if d.pos == d.end {
return 0
}
switch c := d.data[d.pos]; c {
case ' ', '\t', '\n', '\r':
d.pos++
goto loop
default:
return c
}
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"skipSpaces",
"(",
")",
"byte",
"{",
"loop",
":",
"if",
"d",
".",
"pos",
"==",
"d",
".",
"end",
"{",
"return",
"0",
"\n",
"}",
"\n",
"switch",
"c",
":=",
"d",
".",
"data",
"[",
"d",
".",
"pos",
"]",
";",
"c",
"{",
"case",
"' '",
",",
"'\\t'",
",",
"'\\n'",
",",
"'\\r'",
":",
"d",
".",
"pos",
"++",
"\n",
"goto",
"loop",
"\n",
"default",
":",
"return",
"c",
"\n",
"}",
"\n",
"}"
] | // returns the next char after white spaces | [
"returns",
"the",
"next",
"char",
"after",
"white",
"spaces"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/decode.go#L428-L440 |
3,364 | a8m/djson | decode.go | error | func (d *Decoder) error(c byte, context string) error {
if d.pos < d.end {
return &SyntaxError{"invalid character " + quoteChar(c) + " " + context, d.pos + 1}
}
return ErrUnexpectedEOF
} | go | func (d *Decoder) error(c byte, context string) error {
if d.pos < d.end {
return &SyntaxError{"invalid character " + quoteChar(c) + " " + context, d.pos + 1}
}
return ErrUnexpectedEOF
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"error",
"(",
"c",
"byte",
",",
"context",
"string",
")",
"error",
"{",
"if",
"d",
".",
"pos",
"<",
"d",
".",
"end",
"{",
"return",
"&",
"SyntaxError",
"{",
"\"",
"\"",
"+",
"quoteChar",
"(",
"c",
")",
"+",
"\"",
"\"",
"+",
"context",
",",
"d",
".",
"pos",
"+",
"1",
"}",
"\n",
"}",
"\n",
"return",
"ErrUnexpectedEOF",
"\n",
"}"
] | // emit sytax errors | [
"emit",
"sytax",
"errors"
] | c02c5aef757f1282dbe880f399ca5e30dbf33c15 | https://github.com/a8m/djson/blob/c02c5aef757f1282dbe880f399ca5e30dbf33c15/decode.go#L443-L448 |
3,365 | wirepair/gcd | gcdapi/fetch.go | FailRequestWithParams | func (c *Fetch) FailRequestWithParams(v *FetchFailRequestParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.failRequest", Params: v})
} | go | func (c *Fetch) FailRequestWithParams(v *FetchFailRequestParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.failRequest", Params: v})
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"FailRequestWithParams",
"(",
"v",
"*",
"FetchFailRequestParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // FailRequestWithParams - Causes the request to fail with specified reason. | [
"FailRequestWithParams",
"-",
"Causes",
"the",
"request",
"to",
"fail",
"with",
"specified",
"reason",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L110-L112 |
3,366 | wirepair/gcd | gcdapi/fetch.go | FulfillRequestWithParams | func (c *Fetch) FulfillRequestWithParams(v *FetchFulfillRequestParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.fulfillRequest", Params: v})
} | go | func (c *Fetch) FulfillRequestWithParams(v *FetchFulfillRequestParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.fulfillRequest", Params: v})
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"FulfillRequestWithParams",
"(",
"v",
"*",
"FetchFulfillRequestParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // FulfillRequestWithParams - Provides response to the request. | [
"FulfillRequestWithParams",
"-",
"Provides",
"response",
"to",
"the",
"request",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L138-L140 |
3,367 | wirepair/gcd | gcdapi/fetch.go | FulfillRequest | func (c *Fetch) FulfillRequest(requestId string, responseCode int, responseHeaders []*FetchHeaderEntry, body string, responsePhrase string) (*gcdmessage.ChromeResponse, error) {
var v FetchFulfillRequestParams
v.RequestId = requestId
v.ResponseCode = responseCode
v.ResponseHeaders = responseHeaders
v.Body = body
v.ResponsePhrase = responsePhrase
return c.FulfillRequestWithParams(&v)
} | go | func (c *Fetch) FulfillRequest(requestId string, responseCode int, responseHeaders []*FetchHeaderEntry, body string, responsePhrase string) (*gcdmessage.ChromeResponse, error) {
var v FetchFulfillRequestParams
v.RequestId = requestId
v.ResponseCode = responseCode
v.ResponseHeaders = responseHeaders
v.Body = body
v.ResponsePhrase = responsePhrase
return c.FulfillRequestWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"FulfillRequest",
"(",
"requestId",
"string",
",",
"responseCode",
"int",
",",
"responseHeaders",
"[",
"]",
"*",
"FetchHeaderEntry",
",",
"body",
"string",
",",
"responsePhrase",
"string",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"FetchFulfillRequestParams",
"\n",
"v",
".",
"RequestId",
"=",
"requestId",
"\n",
"v",
".",
"ResponseCode",
"=",
"responseCode",
"\n",
"v",
".",
"ResponseHeaders",
"=",
"responseHeaders",
"\n",
"v",
".",
"Body",
"=",
"body",
"\n",
"v",
".",
"ResponsePhrase",
"=",
"responsePhrase",
"\n",
"return",
"c",
".",
"FulfillRequestWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // FulfillRequest - Provides response to the request.
// requestId - An id the client received in requestPaused event.
// responseCode - An HTTP response code.
// responseHeaders - Response headers.
// body - A response body.
// responsePhrase - A textual representation of responseCode. If absent, a standard phrase mathcing responseCode is used. | [
"FulfillRequest",
"-",
"Provides",
"response",
"to",
"the",
"request",
".",
"requestId",
"-",
"An",
"id",
"the",
"client",
"received",
"in",
"requestPaused",
"event",
".",
"responseCode",
"-",
"An",
"HTTP",
"response",
"code",
".",
"responseHeaders",
"-",
"Response",
"headers",
".",
"body",
"-",
"A",
"response",
"body",
".",
"responsePhrase",
"-",
"A",
"textual",
"representation",
"of",
"responseCode",
".",
"If",
"absent",
"a",
"standard",
"phrase",
"mathcing",
"responseCode",
"is",
"used",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L148-L156 |
3,368 | wirepair/gcd | gcdapi/fetch.go | ContinueRequestWithParams | func (c *Fetch) ContinueRequestWithParams(v *FetchContinueRequestParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.continueRequest", Params: v})
} | go | func (c *Fetch) ContinueRequestWithParams(v *FetchContinueRequestParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.continueRequest", Params: v})
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"ContinueRequestWithParams",
"(",
"v",
"*",
"FetchContinueRequestParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // ContinueRequestWithParams - Continues the request, optionally modifying some of its parameters. | [
"ContinueRequestWithParams",
"-",
"Continues",
"the",
"request",
"optionally",
"modifying",
"some",
"of",
"its",
"parameters",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L172-L174 |
3,369 | wirepair/gcd | gcdapi/fetch.go | ContinueRequest | func (c *Fetch) ContinueRequest(requestId string, url string, method string, postData string, headers []*FetchHeaderEntry) (*gcdmessage.ChromeResponse, error) {
var v FetchContinueRequestParams
v.RequestId = requestId
v.Url = url
v.Method = method
v.PostData = postData
v.Headers = headers
return c.ContinueRequestWithParams(&v)
} | go | func (c *Fetch) ContinueRequest(requestId string, url string, method string, postData string, headers []*FetchHeaderEntry) (*gcdmessage.ChromeResponse, error) {
var v FetchContinueRequestParams
v.RequestId = requestId
v.Url = url
v.Method = method
v.PostData = postData
v.Headers = headers
return c.ContinueRequestWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"ContinueRequest",
"(",
"requestId",
"string",
",",
"url",
"string",
",",
"method",
"string",
",",
"postData",
"string",
",",
"headers",
"[",
"]",
"*",
"FetchHeaderEntry",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"FetchContinueRequestParams",
"\n",
"v",
".",
"RequestId",
"=",
"requestId",
"\n",
"v",
".",
"Url",
"=",
"url",
"\n",
"v",
".",
"Method",
"=",
"method",
"\n",
"v",
".",
"PostData",
"=",
"postData",
"\n",
"v",
".",
"Headers",
"=",
"headers",
"\n",
"return",
"c",
".",
"ContinueRequestWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // ContinueRequest - Continues the request, optionally modifying some of its parameters.
// requestId - An id the client received in requestPaused event.
// url - If set, the request url will be modified in a way that's not observable by page.
// method - If set, the request method is overridden.
// postData - If set, overrides the post data in the request.
// headers - If set, overrides the request headrts. | [
"ContinueRequest",
"-",
"Continues",
"the",
"request",
"optionally",
"modifying",
"some",
"of",
"its",
"parameters",
".",
"requestId",
"-",
"An",
"id",
"the",
"client",
"received",
"in",
"requestPaused",
"event",
".",
"url",
"-",
"If",
"set",
"the",
"request",
"url",
"will",
"be",
"modified",
"in",
"a",
"way",
"that",
"s",
"not",
"observable",
"by",
"page",
".",
"method",
"-",
"If",
"set",
"the",
"request",
"method",
"is",
"overridden",
".",
"postData",
"-",
"If",
"set",
"overrides",
"the",
"post",
"data",
"in",
"the",
"request",
".",
"headers",
"-",
"If",
"set",
"overrides",
"the",
"request",
"headrts",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L182-L190 |
3,370 | wirepair/gcd | gcdapi/fetch.go | ContinueWithAuthWithParams | func (c *Fetch) ContinueWithAuthWithParams(v *FetchContinueWithAuthParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.continueWithAuth", Params: v})
} | go | func (c *Fetch) ContinueWithAuthWithParams(v *FetchContinueWithAuthParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Fetch.continueWithAuth", Params: v})
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"ContinueWithAuthWithParams",
"(",
"v",
"*",
"FetchContinueWithAuthParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // ContinueWithAuthWithParams - Continues a request supplying authChallengeResponse following authRequired event. | [
"ContinueWithAuthWithParams",
"-",
"Continues",
"a",
"request",
"supplying",
"authChallengeResponse",
"following",
"authRequired",
"event",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L200-L202 |
3,371 | wirepair/gcd | gcdapi/fetch.go | ContinueWithAuth | func (c *Fetch) ContinueWithAuth(requestId string, authChallengeResponse *FetchAuthChallengeResponse) (*gcdmessage.ChromeResponse, error) {
var v FetchContinueWithAuthParams
v.RequestId = requestId
v.AuthChallengeResponse = authChallengeResponse
return c.ContinueWithAuthWithParams(&v)
} | go | func (c *Fetch) ContinueWithAuth(requestId string, authChallengeResponse *FetchAuthChallengeResponse) (*gcdmessage.ChromeResponse, error) {
var v FetchContinueWithAuthParams
v.RequestId = requestId
v.AuthChallengeResponse = authChallengeResponse
return c.ContinueWithAuthWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"ContinueWithAuth",
"(",
"requestId",
"string",
",",
"authChallengeResponse",
"*",
"FetchAuthChallengeResponse",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"FetchContinueWithAuthParams",
"\n",
"v",
".",
"RequestId",
"=",
"requestId",
"\n",
"v",
".",
"AuthChallengeResponse",
"=",
"authChallengeResponse",
"\n",
"return",
"c",
".",
"ContinueWithAuthWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // ContinueWithAuth - Continues a request supplying authChallengeResponse following authRequired event.
// requestId - An id the client received in authRequired event.
// authChallengeResponse - Response to with an authChallenge. | [
"ContinueWithAuth",
"-",
"Continues",
"a",
"request",
"supplying",
"authChallengeResponse",
"following",
"authRequired",
"event",
".",
"requestId",
"-",
"An",
"id",
"the",
"client",
"received",
"in",
"authRequired",
"event",
".",
"authChallengeResponse",
"-",
"Response",
"to",
"with",
"an",
"authChallenge",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L207-L212 |
3,372 | wirepair/gcd | gcdapi/fetch.go | GetResponseBody | func (c *Fetch) GetResponseBody(requestId string) (string, bool, error) {
var v FetchGetResponseBodyParams
v.RequestId = requestId
return c.GetResponseBodyWithParams(&v)
} | go | func (c *Fetch) GetResponseBody(requestId string) (string, bool, error) {
var v FetchGetResponseBodyParams
v.RequestId = requestId
return c.GetResponseBodyWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Fetch",
")",
"GetResponseBody",
"(",
"requestId",
"string",
")",
"(",
"string",
",",
"bool",
",",
"error",
")",
"{",
"var",
"v",
"FetchGetResponseBodyParams",
"\n",
"v",
".",
"RequestId",
"=",
"requestId",
"\n",
"return",
"c",
".",
"GetResponseBodyWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // GetResponseBody - Causes the body of the response to be received from the server and returned as a single string. May only be issued for a request that is paused in the Response stage and is mutually exclusive with takeResponseBodyForInterceptionAsStream. Calling other methods that affect the request or disabling fetch domain before body is received results in an undefined behavior.
// requestId - Identifier for the intercepted request to get body for.
// Returns - body - Response body. base64Encoded - True, if content was sent as base64. | [
"GetResponseBody",
"-",
"Causes",
"the",
"body",
"of",
"the",
"response",
"to",
"be",
"received",
"from",
"the",
"server",
"and",
"returned",
"as",
"a",
"single",
"string",
".",
"May",
"only",
"be",
"issued",
"for",
"a",
"request",
"that",
"is",
"paused",
"in",
"the",
"Response",
"stage",
"and",
"is",
"mutually",
"exclusive",
"with",
"takeResponseBodyForInterceptionAsStream",
".",
"Calling",
"other",
"methods",
"that",
"affect",
"the",
"request",
"or",
"disabling",
"fetch",
"domain",
"before",
"body",
"is",
"received",
"results",
"in",
"an",
"undefined",
"behavior",
".",
"requestId",
"-",
"Identifier",
"for",
"the",
"intercepted",
"request",
"to",
"get",
"body",
"for",
".",
"Returns",
"-",
"body",
"-",
"Response",
"body",
".",
"base64Encoded",
"-",
"True",
"if",
"content",
"was",
"sent",
"as",
"base64",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/fetch.go#L255-L259 |
3,373 | wirepair/gcd | gcdapi/database.go | ExecuteSQLWithParams | func (c *Database) ExecuteSQLWithParams(v *DatabaseExecuteSQLParams) ([]string, []interface{}, *DatabaseError, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Database.executeSQL", Params: v})
if err != nil {
return nil, nil, nil, err
}
var chromeData struct {
Result struct {
ColumnNames []string
Values []interface{}
SqlError *DatabaseError
}
}
if resp == nil {
return nil, nil, nil, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return nil, nil, nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return nil, nil, nil, err
}
return chromeData.Result.ColumnNames, chromeData.Result.Values, chromeData.Result.SqlError, nil
} | go | func (c *Database) ExecuteSQLWithParams(v *DatabaseExecuteSQLParams) ([]string, []interface{}, *DatabaseError, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Database.executeSQL", Params: v})
if err != nil {
return nil, nil, nil, err
}
var chromeData struct {
Result struct {
ColumnNames []string
Values []interface{}
SqlError *DatabaseError
}
}
if resp == nil {
return nil, nil, nil, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return nil, nil, nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return nil, nil, nil, err
}
return chromeData.Result.ColumnNames, chromeData.Result.Values, chromeData.Result.SqlError, nil
} | [
"func",
"(",
"c",
"*",
"Database",
")",
"ExecuteSQLWithParams",
"(",
"v",
"*",
"DatabaseExecuteSQLParams",
")",
"(",
"[",
"]",
"string",
",",
"[",
"]",
"interface",
"{",
"}",
",",
"*",
"DatabaseError",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"gcdmessage",
".",
"SendCustomReturn",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"chromeData",
"struct",
"{",
"Result",
"struct",
"{",
"ColumnNames",
"[",
"]",
"string",
"\n",
"Values",
"[",
"]",
"interface",
"{",
"}",
"\n",
"SqlError",
"*",
"DatabaseError",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"resp",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"nil",
",",
"&",
"gcdmessage",
".",
"ChromeEmptyResponseErr",
"{",
"}",
"\n",
"}",
"\n\n",
"// test if error first",
"cerr",
":=",
"&",
"gcdmessage",
".",
"ChromeErrorResponse",
"{",
"}",
"\n",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"cerr",
")",
"\n",
"if",
"cerr",
"!=",
"nil",
"&&",
"cerr",
".",
"Error",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"nil",
",",
"&",
"gcdmessage",
".",
"ChromeRequestErr",
"{",
"Resp",
":",
"cerr",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"&",
"chromeData",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"chromeData",
".",
"Result",
".",
"ColumnNames",
",",
"chromeData",
".",
"Result",
".",
"Values",
",",
"chromeData",
".",
"Result",
".",
"SqlError",
",",
"nil",
"\n",
"}"
] | // ExecuteSQLWithParams -
// Returns - columnNames - values - sqlError - | [
"ExecuteSQLWithParams",
"-",
"Returns",
"-",
"columnNames",
"-",
"values",
"-",
"sqlError",
"-"
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/database.go#L62-L92 |
3,374 | wirepair/gcd | gcdapi/database.go | ExecuteSQL | func (c *Database) ExecuteSQL(databaseId string, query string) ([]string, []interface{}, *DatabaseError, error) {
var v DatabaseExecuteSQLParams
v.DatabaseId = databaseId
v.Query = query
return c.ExecuteSQLWithParams(&v)
} | go | func (c *Database) ExecuteSQL(databaseId string, query string) ([]string, []interface{}, *DatabaseError, error) {
var v DatabaseExecuteSQLParams
v.DatabaseId = databaseId
v.Query = query
return c.ExecuteSQLWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Database",
")",
"ExecuteSQL",
"(",
"databaseId",
"string",
",",
"query",
"string",
")",
"(",
"[",
"]",
"string",
",",
"[",
"]",
"interface",
"{",
"}",
",",
"*",
"DatabaseError",
",",
"error",
")",
"{",
"var",
"v",
"DatabaseExecuteSQLParams",
"\n",
"v",
".",
"DatabaseId",
"=",
"databaseId",
"\n",
"v",
".",
"Query",
"=",
"query",
"\n",
"return",
"c",
".",
"ExecuteSQLWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // ExecuteSQL -
// databaseId -
// query -
// Returns - columnNames - values - sqlError - | [
"ExecuteSQL",
"-",
"databaseId",
"-",
"query",
"-",
"Returns",
"-",
"columnNames",
"-",
"values",
"-",
"sqlError",
"-"
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/database.go#L98-L103 |
3,375 | wirepair/gcd | gcdapi/database.go | GetDatabaseTableNames | func (c *Database) GetDatabaseTableNames(databaseId string) ([]string, error) {
var v DatabaseGetDatabaseTableNamesParams
v.DatabaseId = databaseId
return c.GetDatabaseTableNamesWithParams(&v)
} | go | func (c *Database) GetDatabaseTableNames(databaseId string) ([]string, error) {
var v DatabaseGetDatabaseTableNamesParams
v.DatabaseId = databaseId
return c.GetDatabaseTableNamesWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Database",
")",
"GetDatabaseTableNames",
"(",
"databaseId",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"v",
"DatabaseGetDatabaseTableNamesParams",
"\n",
"v",
".",
"DatabaseId",
"=",
"databaseId",
"\n",
"return",
"c",
".",
"GetDatabaseTableNamesWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // GetDatabaseTableNames -
// databaseId -
// Returns - tableNames - | [
"GetDatabaseTableNames",
"-",
"databaseId",
"-",
"Returns",
"-",
"tableNames",
"-"
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/database.go#L145-L149 |
3,376 | wirepair/gcd | gcdapi/input.go | DispatchKeyEventWithParams | func (c *Input) DispatchKeyEventWithParams(v *InputDispatchKeyEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.dispatchKeyEvent", Params: v})
} | go | func (c *Input) DispatchKeyEventWithParams(v *InputDispatchKeyEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.dispatchKeyEvent", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"DispatchKeyEventWithParams",
"(",
"v",
"*",
"InputDispatchKeyEventParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // DispatchKeyEventWithParams - Dispatches a key event to the page. | [
"DispatchKeyEventWithParams",
"-",
"Dispatches",
"a",
"key",
"event",
"to",
"the",
"page",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L63-L65 |
3,377 | wirepair/gcd | gcdapi/input.go | InsertTextWithParams | func (c *Input) InsertTextWithParams(v *InputInsertTextParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.insertText", Params: v})
} | go | func (c *Input) InsertTextWithParams(v *InputInsertTextParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.insertText", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"InsertTextWithParams",
"(",
"v",
"*",
"InputInsertTextParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // InsertTextWithParams - This method emulates inserting text that doesn't come from a key press, for example an emoji keyboard or an IME. | [
"InsertTextWithParams",
"-",
"This",
"method",
"emulates",
"inserting",
"text",
"that",
"doesn",
"t",
"come",
"from",
"a",
"key",
"press",
"for",
"example",
"an",
"emoji",
"keyboard",
"or",
"an",
"IME",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L107-L109 |
3,378 | wirepair/gcd | gcdapi/input.go | InsertText | func (c *Input) InsertText(text string) (*gcdmessage.ChromeResponse, error) {
var v InputInsertTextParams
v.Text = text
return c.InsertTextWithParams(&v)
} | go | func (c *Input) InsertText(text string) (*gcdmessage.ChromeResponse, error) {
var v InputInsertTextParams
v.Text = text
return c.InsertTextWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"InsertText",
"(",
"text",
"string",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"InputInsertTextParams",
"\n",
"v",
".",
"Text",
"=",
"text",
"\n",
"return",
"c",
".",
"InsertTextWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // InsertText - This method emulates inserting text that doesn't come from a key press, for example an emoji keyboard or an IME.
// text - The text to insert. | [
"InsertText",
"-",
"This",
"method",
"emulates",
"inserting",
"text",
"that",
"doesn",
"t",
"come",
"from",
"a",
"key",
"press",
"for",
"example",
"an",
"emoji",
"keyboard",
"or",
"an",
"IME",
".",
"text",
"-",
"The",
"text",
"to",
"insert",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L113-L117 |
3,379 | wirepair/gcd | gcdapi/input.go | DispatchMouseEventWithParams | func (c *Input) DispatchMouseEventWithParams(v *InputDispatchMouseEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.dispatchMouseEvent", Params: v})
} | go | func (c *Input) DispatchMouseEventWithParams(v *InputDispatchMouseEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.dispatchMouseEvent", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"DispatchMouseEventWithParams",
"(",
"v",
"*",
"InputDispatchMouseEventParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // DispatchMouseEventWithParams - Dispatches a mouse event to the page. | [
"DispatchMouseEventWithParams",
"-",
"Dispatches",
"a",
"mouse",
"event",
"to",
"the",
"page",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L145-L147 |
3,380 | wirepair/gcd | gcdapi/input.go | DispatchTouchEventWithParams | func (c *Input) DispatchTouchEventWithParams(v *InputDispatchTouchEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.dispatchTouchEvent", Params: v})
} | go | func (c *Input) DispatchTouchEventWithParams(v *InputDispatchTouchEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.dispatchTouchEvent", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"DispatchTouchEventWithParams",
"(",
"v",
"*",
"InputDispatchTouchEventParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // DispatchTouchEventWithParams - Dispatches a touch event to the page. | [
"DispatchTouchEventWithParams",
"-",
"Dispatches",
"a",
"touch",
"event",
"to",
"the",
"page",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L189-L191 |
3,381 | wirepair/gcd | gcdapi/input.go | EmulateTouchFromMouseEventWithParams | func (c *Input) EmulateTouchFromMouseEventWithParams(v *InputEmulateTouchFromMouseEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.emulateTouchFromMouseEvent", Params: v})
} | go | func (c *Input) EmulateTouchFromMouseEventWithParams(v *InputEmulateTouchFromMouseEventParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.emulateTouchFromMouseEvent", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"EmulateTouchFromMouseEventWithParams",
"(",
"v",
"*",
"InputEmulateTouchFromMouseEventParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // EmulateTouchFromMouseEventWithParams - Emulates touch event from the mouse event parameters. | [
"EmulateTouchFromMouseEventWithParams",
"-",
"Emulates",
"touch",
"event",
"from",
"the",
"mouse",
"event",
"parameters",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L229-L231 |
3,382 | wirepair/gcd | gcdapi/input.go | SynthesizePinchGestureWithParams | func (c *Input) SynthesizePinchGestureWithParams(v *InputSynthesizePinchGestureParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.synthesizePinchGesture", Params: v})
} | go | func (c *Input) SynthesizePinchGestureWithParams(v *InputSynthesizePinchGestureParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.synthesizePinchGesture", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"SynthesizePinchGestureWithParams",
"(",
"v",
"*",
"InputSynthesizePinchGestureParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // SynthesizePinchGestureWithParams - Synthesizes a pinch gesture over a time period by issuing appropriate touch events. | [
"SynthesizePinchGestureWithParams",
"-",
"Synthesizes",
"a",
"pinch",
"gesture",
"over",
"a",
"time",
"period",
"by",
"issuing",
"appropriate",
"touch",
"events",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L289-L291 |
3,383 | wirepair/gcd | gcdapi/input.go | SynthesizeScrollGestureWithParams | func (c *Input) SynthesizeScrollGestureWithParams(v *InputSynthesizeScrollGestureParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.synthesizeScrollGesture", Params: v})
} | go | func (c *Input) SynthesizeScrollGestureWithParams(v *InputSynthesizeScrollGestureParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.synthesizeScrollGesture", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"SynthesizeScrollGestureWithParams",
"(",
"v",
"*",
"InputSynthesizeScrollGestureParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // SynthesizeScrollGestureWithParams - Synthesizes a scroll gesture over a time period by issuing appropriate touch events. | [
"SynthesizeScrollGestureWithParams",
"-",
"Synthesizes",
"a",
"scroll",
"gesture",
"over",
"a",
"time",
"period",
"by",
"issuing",
"appropriate",
"touch",
"events",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L337-L339 |
3,384 | wirepair/gcd | gcdapi/input.go | SynthesizeTapGestureWithParams | func (c *Input) SynthesizeTapGestureWithParams(v *InputSynthesizeTapGestureParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.synthesizeTapGesture", Params: v})
} | go | func (c *Input) SynthesizeTapGestureWithParams(v *InputSynthesizeTapGestureParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Input.synthesizeTapGesture", Params: v})
} | [
"func",
"(",
"c",
"*",
"Input",
")",
"SynthesizeTapGestureWithParams",
"(",
"v",
"*",
"InputSynthesizeTapGestureParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // SynthesizeTapGestureWithParams - Synthesizes a tap gesture over a time period by issuing appropriate touch events. | [
"SynthesizeTapGestureWithParams",
"-",
"Synthesizes",
"a",
"tap",
"gesture",
"over",
"a",
"time",
"period",
"by",
"issuing",
"appropriate",
"touch",
"events",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/input.go#L385-L387 |
3,385 | wirepair/gcd | gcdapi/performance.go | SetTimeDomainWithParams | func (c *Performance) SetTimeDomainWithParams(v *PerformanceSetTimeDomainParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Performance.setTimeDomain", Params: v})
} | go | func (c *Performance) SetTimeDomainWithParams(v *PerformanceSetTimeDomainParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Performance.setTimeDomain", Params: v})
} | [
"func",
"(",
"c",
"*",
"Performance",
")",
"SetTimeDomainWithParams",
"(",
"v",
"*",
"PerformanceSetTimeDomainParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // SetTimeDomainWithParams - Sets time domain to use for collecting and reporting duration metrics. Note that this must be called before enabling metrics collection. Calling this method while metrics collection is enabled returns an error. | [
"SetTimeDomainWithParams",
"-",
"Sets",
"time",
"domain",
"to",
"use",
"for",
"collecting",
"and",
"reporting",
"duration",
"metrics",
".",
"Note",
"that",
"this",
"must",
"be",
"called",
"before",
"enabling",
"metrics",
"collection",
".",
"Calling",
"this",
"method",
"while",
"metrics",
"collection",
"is",
"enabled",
"returns",
"an",
"error",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/performance.go#L52-L54 |
3,386 | wirepair/gcd | gcdapi/performance.go | SetTimeDomain | func (c *Performance) SetTimeDomain(timeDomain string) (*gcdmessage.ChromeResponse, error) {
var v PerformanceSetTimeDomainParams
v.TimeDomain = timeDomain
return c.SetTimeDomainWithParams(&v)
} | go | func (c *Performance) SetTimeDomain(timeDomain string) (*gcdmessage.ChromeResponse, error) {
var v PerformanceSetTimeDomainParams
v.TimeDomain = timeDomain
return c.SetTimeDomainWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Performance",
")",
"SetTimeDomain",
"(",
"timeDomain",
"string",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"PerformanceSetTimeDomainParams",
"\n",
"v",
".",
"TimeDomain",
"=",
"timeDomain",
"\n",
"return",
"c",
".",
"SetTimeDomainWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // SetTimeDomain - Sets time domain to use for collecting and reporting duration metrics. Note that this must be called before enabling metrics collection. Calling this method while metrics collection is enabled returns an error.
// timeDomain - Time domain | [
"SetTimeDomain",
"-",
"Sets",
"time",
"domain",
"to",
"use",
"for",
"collecting",
"and",
"reporting",
"duration",
"metrics",
".",
"Note",
"that",
"this",
"must",
"be",
"called",
"before",
"enabling",
"metrics",
"collection",
".",
"Calling",
"this",
"method",
"while",
"metrics",
"collection",
"is",
"enabled",
"returns",
"an",
"error",
".",
"timeDomain",
"-",
"Time",
"domain"
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/performance.go#L58-L62 |
3,387 | wirepair/gcd | gcdapi/performance.go | GetMetrics | func (c *Performance) GetMetrics() ([]*PerformanceMetric, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Performance.getMetrics"})
if err != nil {
return nil, err
}
var chromeData struct {
Result struct {
Metrics []*PerformanceMetric
}
}
if resp == nil {
return nil, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return nil, err
}
return chromeData.Result.Metrics, nil
} | go | func (c *Performance) GetMetrics() ([]*PerformanceMetric, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Performance.getMetrics"})
if err != nil {
return nil, err
}
var chromeData struct {
Result struct {
Metrics []*PerformanceMetric
}
}
if resp == nil {
return nil, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return nil, err
}
return chromeData.Result.Metrics, nil
} | [
"func",
"(",
"c",
"*",
"Performance",
")",
"GetMetrics",
"(",
")",
"(",
"[",
"]",
"*",
"PerformanceMetric",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"gcdmessage",
".",
"SendCustomReturn",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"chromeData",
"struct",
"{",
"Result",
"struct",
"{",
"Metrics",
"[",
"]",
"*",
"PerformanceMetric",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"resp",
"==",
"nil",
"{",
"return",
"nil",
",",
"&",
"gcdmessage",
".",
"ChromeEmptyResponseErr",
"{",
"}",
"\n",
"}",
"\n\n",
"// test if error first",
"cerr",
":=",
"&",
"gcdmessage",
".",
"ChromeErrorResponse",
"{",
"}",
"\n",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"cerr",
")",
"\n",
"if",
"cerr",
"!=",
"nil",
"&&",
"cerr",
".",
"Error",
"!=",
"nil",
"{",
"return",
"nil",
",",
"&",
"gcdmessage",
".",
"ChromeRequestErr",
"{",
"Resp",
":",
"cerr",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"&",
"chromeData",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"chromeData",
".",
"Result",
".",
"Metrics",
",",
"nil",
"\n",
"}"
] | // GetMetrics - Retrieve current values of run-time metrics.
// Returns - metrics - Current values for run-time metrics. | [
"GetMetrics",
"-",
"Retrieve",
"current",
"values",
"of",
"run",
"-",
"time",
"metrics",
".",
"Returns",
"-",
"metrics",
"-",
"Current",
"values",
"for",
"run",
"-",
"time",
"metrics",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/performance.go#L66-L94 |
3,388 | wirepair/gcd | gcdapi/animation.go | GetCurrentTimeWithParams | func (c *Animation) GetCurrentTimeWithParams(v *AnimationGetCurrentTimeParams) (float64, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.getCurrentTime", Params: v})
if err != nil {
return 0, err
}
var chromeData struct {
Result struct {
CurrentTime float64
}
}
if resp == nil {
return 0, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return 0, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return 0, err
}
return chromeData.Result.CurrentTime, nil
} | go | func (c *Animation) GetCurrentTimeWithParams(v *AnimationGetCurrentTimeParams) (float64, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.getCurrentTime", Params: v})
if err != nil {
return 0, err
}
var chromeData struct {
Result struct {
CurrentTime float64
}
}
if resp == nil {
return 0, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return 0, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return 0, err
}
return chromeData.Result.CurrentTime, nil
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"GetCurrentTimeWithParams",
"(",
"v",
"*",
"AnimationGetCurrentTimeParams",
")",
"(",
"float64",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"gcdmessage",
".",
"SendCustomReturn",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"chromeData",
"struct",
"{",
"Result",
"struct",
"{",
"CurrentTime",
"float64",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"resp",
"==",
"nil",
"{",
"return",
"0",
",",
"&",
"gcdmessage",
".",
"ChromeEmptyResponseErr",
"{",
"}",
"\n",
"}",
"\n\n",
"// test if error first",
"cerr",
":=",
"&",
"gcdmessage",
".",
"ChromeErrorResponse",
"{",
"}",
"\n",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"cerr",
")",
"\n",
"if",
"cerr",
"!=",
"nil",
"&&",
"cerr",
".",
"Error",
"!=",
"nil",
"{",
"return",
"0",
",",
"&",
"gcdmessage",
".",
"ChromeRequestErr",
"{",
"Resp",
":",
"cerr",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"&",
"chromeData",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"chromeData",
".",
"Result",
".",
"CurrentTime",
",",
"nil",
"\n",
"}"
] | // GetCurrentTimeWithParams - Returns the current time of the an animation.
// Returns - currentTime - Current time of the page. | [
"GetCurrentTimeWithParams",
"-",
"Returns",
"the",
"current",
"time",
"of",
"the",
"an",
"animation",
".",
"Returns",
"-",
"currentTime",
"-",
"Current",
"time",
"of",
"the",
"page",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L102-L130 |
3,389 | wirepair/gcd | gcdapi/animation.go | GetCurrentTime | func (c *Animation) GetCurrentTime(id string) (float64, error) {
var v AnimationGetCurrentTimeParams
v.Id = id
return c.GetCurrentTimeWithParams(&v)
} | go | func (c *Animation) GetCurrentTime(id string) (float64, error) {
var v AnimationGetCurrentTimeParams
v.Id = id
return c.GetCurrentTimeWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"GetCurrentTime",
"(",
"id",
"string",
")",
"(",
"float64",
",",
"error",
")",
"{",
"var",
"v",
"AnimationGetCurrentTimeParams",
"\n",
"v",
".",
"Id",
"=",
"id",
"\n",
"return",
"c",
".",
"GetCurrentTimeWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // GetCurrentTime - Returns the current time of the an animation.
// id - Id of animation.
// Returns - currentTime - Current time of the page. | [
"GetCurrentTime",
"-",
"Returns",
"the",
"current",
"time",
"of",
"the",
"an",
"animation",
".",
"id",
"-",
"Id",
"of",
"animation",
".",
"Returns",
"-",
"currentTime",
"-",
"Current",
"time",
"of",
"the",
"page",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L135-L139 |
3,390 | wirepair/gcd | gcdapi/animation.go | GetPlaybackRate | func (c *Animation) GetPlaybackRate() (float64, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.getPlaybackRate"})
if err != nil {
return 0, err
}
var chromeData struct {
Result struct {
PlaybackRate float64
}
}
if resp == nil {
return 0, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return 0, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return 0, err
}
return chromeData.Result.PlaybackRate, nil
} | go | func (c *Animation) GetPlaybackRate() (float64, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.getPlaybackRate"})
if err != nil {
return 0, err
}
var chromeData struct {
Result struct {
PlaybackRate float64
}
}
if resp == nil {
return 0, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return 0, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return 0, err
}
return chromeData.Result.PlaybackRate, nil
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"GetPlaybackRate",
"(",
")",
"(",
"float64",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"gcdmessage",
".",
"SendCustomReturn",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"chromeData",
"struct",
"{",
"Result",
"struct",
"{",
"PlaybackRate",
"float64",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"resp",
"==",
"nil",
"{",
"return",
"0",
",",
"&",
"gcdmessage",
".",
"ChromeEmptyResponseErr",
"{",
"}",
"\n",
"}",
"\n\n",
"// test if error first",
"cerr",
":=",
"&",
"gcdmessage",
".",
"ChromeErrorResponse",
"{",
"}",
"\n",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"cerr",
")",
"\n",
"if",
"cerr",
"!=",
"nil",
"&&",
"cerr",
".",
"Error",
"!=",
"nil",
"{",
"return",
"0",
",",
"&",
"gcdmessage",
".",
"ChromeRequestErr",
"{",
"Resp",
":",
"cerr",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"&",
"chromeData",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"chromeData",
".",
"Result",
".",
"PlaybackRate",
",",
"nil",
"\n",
"}"
] | // GetPlaybackRate - Gets the playback rate of the document timeline.
// Returns - playbackRate - Playback rate for animations on page. | [
"GetPlaybackRate",
"-",
"Gets",
"the",
"playback",
"rate",
"of",
"the",
"document",
"timeline",
".",
"Returns",
"-",
"playbackRate",
"-",
"Playback",
"rate",
"for",
"animations",
"on",
"page",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L143-L171 |
3,391 | wirepair/gcd | gcdapi/animation.go | ReleaseAnimationsWithParams | func (c *Animation) ReleaseAnimationsWithParams(v *AnimationReleaseAnimationsParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.releaseAnimations", Params: v})
} | go | func (c *Animation) ReleaseAnimationsWithParams(v *AnimationReleaseAnimationsParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.releaseAnimations", Params: v})
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"ReleaseAnimationsWithParams",
"(",
"v",
"*",
"AnimationReleaseAnimationsParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // ReleaseAnimationsWithParams - Releases a set of animations to no longer be manipulated. | [
"ReleaseAnimationsWithParams",
"-",
"Releases",
"a",
"set",
"of",
"animations",
"to",
"no",
"longer",
"be",
"manipulated",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L179-L181 |
3,392 | wirepair/gcd | gcdapi/animation.go | ReleaseAnimations | func (c *Animation) ReleaseAnimations(animations []string) (*gcdmessage.ChromeResponse, error) {
var v AnimationReleaseAnimationsParams
v.Animations = animations
return c.ReleaseAnimationsWithParams(&v)
} | go | func (c *Animation) ReleaseAnimations(animations []string) (*gcdmessage.ChromeResponse, error) {
var v AnimationReleaseAnimationsParams
v.Animations = animations
return c.ReleaseAnimationsWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"ReleaseAnimations",
"(",
"animations",
"[",
"]",
"string",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"AnimationReleaseAnimationsParams",
"\n",
"v",
".",
"Animations",
"=",
"animations",
"\n",
"return",
"c",
".",
"ReleaseAnimationsWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // ReleaseAnimations - Releases a set of animations to no longer be manipulated.
// animations - List of animation ids to seek. | [
"ReleaseAnimations",
"-",
"Releases",
"a",
"set",
"of",
"animations",
"to",
"no",
"longer",
"be",
"manipulated",
".",
"animations",
"-",
"List",
"of",
"animation",
"ids",
"to",
"seek",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L185-L189 |
3,393 | wirepair/gcd | gcdapi/animation.go | ResolveAnimationWithParams | func (c *Animation) ResolveAnimationWithParams(v *AnimationResolveAnimationParams) (*RuntimeRemoteObject, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.resolveAnimation", Params: v})
if err != nil {
return nil, err
}
var chromeData struct {
Result struct {
RemoteObject *RuntimeRemoteObject
}
}
if resp == nil {
return nil, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return nil, err
}
return chromeData.Result.RemoteObject, nil
} | go | func (c *Animation) ResolveAnimationWithParams(v *AnimationResolveAnimationParams) (*RuntimeRemoteObject, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.resolveAnimation", Params: v})
if err != nil {
return nil, err
}
var chromeData struct {
Result struct {
RemoteObject *RuntimeRemoteObject
}
}
if resp == nil {
return nil, &gcdmessage.ChromeEmptyResponseErr{}
}
// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
}
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return nil, err
}
return chromeData.Result.RemoteObject, nil
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"ResolveAnimationWithParams",
"(",
"v",
"*",
"AnimationResolveAnimationParams",
")",
"(",
"*",
"RuntimeRemoteObject",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"gcdmessage",
".",
"SendCustomReturn",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"chromeData",
"struct",
"{",
"Result",
"struct",
"{",
"RemoteObject",
"*",
"RuntimeRemoteObject",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"resp",
"==",
"nil",
"{",
"return",
"nil",
",",
"&",
"gcdmessage",
".",
"ChromeEmptyResponseErr",
"{",
"}",
"\n",
"}",
"\n\n",
"// test if error first",
"cerr",
":=",
"&",
"gcdmessage",
".",
"ChromeErrorResponse",
"{",
"}",
"\n",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"cerr",
")",
"\n",
"if",
"cerr",
"!=",
"nil",
"&&",
"cerr",
".",
"Error",
"!=",
"nil",
"{",
"return",
"nil",
",",
"&",
"gcdmessage",
".",
"ChromeRequestErr",
"{",
"Resp",
":",
"cerr",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"resp",
".",
"Data",
",",
"&",
"chromeData",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"chromeData",
".",
"Result",
".",
"RemoteObject",
",",
"nil",
"\n",
"}"
] | // ResolveAnimationWithParams - Gets the remote object of the Animation.
// Returns - remoteObject - Corresponding remote object. | [
"ResolveAnimationWithParams",
"-",
"Gets",
"the",
"remote",
"object",
"of",
"the",
"Animation",
".",
"Returns",
"-",
"remoteObject",
"-",
"Corresponding",
"remote",
"object",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L198-L226 |
3,394 | wirepair/gcd | gcdapi/animation.go | ResolveAnimation | func (c *Animation) ResolveAnimation(animationId string) (*RuntimeRemoteObject, error) {
var v AnimationResolveAnimationParams
v.AnimationId = animationId
return c.ResolveAnimationWithParams(&v)
} | go | func (c *Animation) ResolveAnimation(animationId string) (*RuntimeRemoteObject, error) {
var v AnimationResolveAnimationParams
v.AnimationId = animationId
return c.ResolveAnimationWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"ResolveAnimation",
"(",
"animationId",
"string",
")",
"(",
"*",
"RuntimeRemoteObject",
",",
"error",
")",
"{",
"var",
"v",
"AnimationResolveAnimationParams",
"\n",
"v",
".",
"AnimationId",
"=",
"animationId",
"\n",
"return",
"c",
".",
"ResolveAnimationWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // ResolveAnimation - Gets the remote object of the Animation.
// animationId - Animation id.
// Returns - remoteObject - Corresponding remote object. | [
"ResolveAnimation",
"-",
"Gets",
"the",
"remote",
"object",
"of",
"the",
"Animation",
".",
"animationId",
"-",
"Animation",
"id",
".",
"Returns",
"-",
"remoteObject",
"-",
"Corresponding",
"remote",
"object",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L231-L235 |
3,395 | wirepair/gcd | gcdapi/animation.go | SeekAnimationsWithParams | func (c *Animation) SeekAnimationsWithParams(v *AnimationSeekAnimationsParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.seekAnimations", Params: v})
} | go | func (c *Animation) SeekAnimationsWithParams(v *AnimationSeekAnimationsParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.seekAnimations", Params: v})
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"SeekAnimationsWithParams",
"(",
"v",
"*",
"AnimationSeekAnimationsParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // SeekAnimationsWithParams - Seek a set of animations to a particular time within each animation. | [
"SeekAnimationsWithParams",
"-",
"Seek",
"a",
"set",
"of",
"animations",
"to",
"a",
"particular",
"time",
"within",
"each",
"animation",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L245-L247 |
3,396 | wirepair/gcd | gcdapi/animation.go | SeekAnimations | func (c *Animation) SeekAnimations(animations []string, currentTime float64) (*gcdmessage.ChromeResponse, error) {
var v AnimationSeekAnimationsParams
v.Animations = animations
v.CurrentTime = currentTime
return c.SeekAnimationsWithParams(&v)
} | go | func (c *Animation) SeekAnimations(animations []string, currentTime float64) (*gcdmessage.ChromeResponse, error) {
var v AnimationSeekAnimationsParams
v.Animations = animations
v.CurrentTime = currentTime
return c.SeekAnimationsWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"SeekAnimations",
"(",
"animations",
"[",
"]",
"string",
",",
"currentTime",
"float64",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"AnimationSeekAnimationsParams",
"\n",
"v",
".",
"Animations",
"=",
"animations",
"\n",
"v",
".",
"CurrentTime",
"=",
"currentTime",
"\n",
"return",
"c",
".",
"SeekAnimationsWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // SeekAnimations - Seek a set of animations to a particular time within each animation.
// animations - List of animation ids to seek.
// currentTime - Set the current time of each animation. | [
"SeekAnimations",
"-",
"Seek",
"a",
"set",
"of",
"animations",
"to",
"a",
"particular",
"time",
"within",
"each",
"animation",
".",
"animations",
"-",
"List",
"of",
"animation",
"ids",
"to",
"seek",
".",
"currentTime",
"-",
"Set",
"the",
"current",
"time",
"of",
"each",
"animation",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L252-L257 |
3,397 | wirepair/gcd | gcdapi/animation.go | SetPausedWithParams | func (c *Animation) SetPausedWithParams(v *AnimationSetPausedParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.setPaused", Params: v})
} | go | func (c *Animation) SetPausedWithParams(v *AnimationSetPausedParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.setPaused", Params: v})
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"SetPausedWithParams",
"(",
"v",
"*",
"AnimationSetPausedParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // SetPausedWithParams - Sets the paused state of a set of animations. | [
"SetPausedWithParams",
"-",
"Sets",
"the",
"paused",
"state",
"of",
"a",
"set",
"of",
"animations",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L267-L269 |
3,398 | wirepair/gcd | gcdapi/animation.go | SetPaused | func (c *Animation) SetPaused(animations []string, paused bool) (*gcdmessage.ChromeResponse, error) {
var v AnimationSetPausedParams
v.Animations = animations
v.Paused = paused
return c.SetPausedWithParams(&v)
} | go | func (c *Animation) SetPaused(animations []string, paused bool) (*gcdmessage.ChromeResponse, error) {
var v AnimationSetPausedParams
v.Animations = animations
v.Paused = paused
return c.SetPausedWithParams(&v)
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"SetPaused",
"(",
"animations",
"[",
"]",
"string",
",",
"paused",
"bool",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"var",
"v",
"AnimationSetPausedParams",
"\n",
"v",
".",
"Animations",
"=",
"animations",
"\n",
"v",
".",
"Paused",
"=",
"paused",
"\n",
"return",
"c",
".",
"SetPausedWithParams",
"(",
"&",
"v",
")",
"\n",
"}"
] | // SetPaused - Sets the paused state of a set of animations.
// animations - Animations to set the pause state of.
// paused - Paused state to set to. | [
"SetPaused",
"-",
"Sets",
"the",
"paused",
"state",
"of",
"a",
"set",
"of",
"animations",
".",
"animations",
"-",
"Animations",
"to",
"set",
"the",
"pause",
"state",
"of",
".",
"paused",
"-",
"Paused",
"state",
"to",
"set",
"to",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L274-L279 |
3,399 | wirepair/gcd | gcdapi/animation.go | SetPlaybackRateWithParams | func (c *Animation) SetPlaybackRateWithParams(v *AnimationSetPlaybackRateParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.setPlaybackRate", Params: v})
} | go | func (c *Animation) SetPlaybackRateWithParams(v *AnimationSetPlaybackRateParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Animation.setPlaybackRate", Params: v})
} | [
"func",
"(",
"c",
"*",
"Animation",
")",
"SetPlaybackRateWithParams",
"(",
"v",
"*",
"AnimationSetPlaybackRateParams",
")",
"(",
"*",
"gcdmessage",
".",
"ChromeResponse",
",",
"error",
")",
"{",
"return",
"gcdmessage",
".",
"SendDefaultRequest",
"(",
"c",
".",
"target",
",",
"c",
".",
"target",
".",
"GetSendCh",
"(",
")",
",",
"&",
"gcdmessage",
".",
"ParamRequest",
"{",
"Id",
":",
"c",
".",
"target",
".",
"GetId",
"(",
")",
",",
"Method",
":",
"\"",
"\"",
",",
"Params",
":",
"v",
"}",
")",
"\n",
"}"
] | // SetPlaybackRateWithParams - Sets the playback rate of the document timeline. | [
"SetPlaybackRateWithParams",
"-",
"Sets",
"the",
"playback",
"rate",
"of",
"the",
"document",
"timeline",
"."
] | 2f7807e117ff2d25c3c702d6eef0155ba9d1a556 | https://github.com/wirepair/gcd/blob/2f7807e117ff2d25c3c702d6eef0155ba9d1a556/gcdapi/animation.go#L287-L289 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.