id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
30,100
denverdino/aliyungo
nas/client.go
NewClient
func NewClient(accessKeyId, accessKeySecret string) *Client { client := &Client{} client.Init(END_POINT, VERSION, accessKeyId, accessKeySecret) return client }
go
func NewClient(accessKeyId, accessKeySecret string) *Client { client := &Client{} client.Init(END_POINT, VERSION, accessKeyId, accessKeySecret) return client }
[ "func", "NewClient", "(", "accessKeyId", ",", "accessKeySecret", "string", ")", "*", "Client", "{", "client", ":=", "&", "Client", "{", "}", "\n", "client", ".", "Init", "(", "END_POINT", ",", "VERSION", ",", "accessKeyId", ",", "accessKeySecret", ")", "\n...
// NewClient creates a new instance of NAS client
[ "NewClient", "creates", "a", "new", "instance", "of", "NAS", "client" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/nas/client.go#L20-L24
30,101
denverdino/aliyungo
util/util.go
EncodeWithoutEscape
func EncodeWithoutEscape(v url.Values) string { if v == nil { return "" } var buf bytes.Buffer keys := make([]string, 0, len(v)) for k := range v { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { vs := v[k] prefix := k for _, v := range vs { if buf.Len() > 0 { buf.WriteByte...
go
func EncodeWithoutEscape(v url.Values) string { if v == nil { return "" } var buf bytes.Buffer keys := make([]string, 0, len(v)) for k := range v { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { vs := v[k] prefix := k for _, v := range vs { if buf.Len() > 0 { buf.WriteByte...
[ "func", "EncodeWithoutEscape", "(", "v", "url", ".", "Values", ")", "string", "{", "if", "v", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "var", "buf", "bytes", ".", "Buffer", "\n", "keys", ":=", "make", "(", "[", "]", "string", ",", ...
// Like Encode, but key and value are not escaped
[ "Like", "Encode", "but", "key", "and", "value", "are", "not", "escaped" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/util/util.go#L70-L95
30,102
denverdino/aliyungo
ecs/instances.go
WaitForInstanceAsyn
func (client *Client) WaitForInstanceAsyn(instanceId string, status InstanceStatus, timeout int) error { if timeout <= 0 { timeout = InstanceDefaultTimeout } for { instance, err := client.DescribeInstanceAttribute(instanceId) if err != nil { e, _ := err.(*common.Error) if e.Code != "InvalidInstanceId.Not...
go
func (client *Client) WaitForInstanceAsyn(instanceId string, status InstanceStatus, timeout int) error { if timeout <= 0 { timeout = InstanceDefaultTimeout } for { instance, err := client.DescribeInstanceAttribute(instanceId) if err != nil { e, _ := err.(*common.Error) if e.Code != "InvalidInstanceId.Not...
[ "func", "(", "client", "*", "Client", ")", "WaitForInstanceAsyn", "(", "instanceId", "string", ",", "status", "InstanceStatus", ",", "timeout", "int", ")", "error", "{", "if", "timeout", "<=", "0", "{", "timeout", "=", "InstanceDefaultTimeout", "\n", "}", "\...
// WaitForInstance waits for instance to given status // when instance.NotFound wait until timeout
[ "WaitForInstance", "waits", "for", "instance", "to", "given", "status", "when", "instance", ".", "NotFound", "wait", "until", "timeout" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ecs/instances.go#L343-L366
30,103
denverdino/aliyungo
util/iso6801.go
GetISO8601TimeStamp
func GetISO8601TimeStamp(ts time.Time) string { t := ts.UTC() return fmt.Sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()) }
go
func GetISO8601TimeStamp(ts time.Time) string { t := ts.UTC() return fmt.Sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()) }
[ "func", "GetISO8601TimeStamp", "(", "ts", "time", ".", "Time", ")", "string", "{", "t", ":=", "ts", ".", "UTC", "(", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t", ".", "Year", "(", ")", ",", "t", ".", "Month", "(", ")",...
// GetISO8601TimeStamp gets timestamp string in ISO8601 format
[ "GetISO8601TimeStamp", "gets", "timestamp", "string", "in", "ISO8601", "format" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/util/iso6801.go#L10-L13
30,104
denverdino/aliyungo
util/iso6801.go
MarshalJSON
func (it ISO6801Time) MarshalJSON() ([]byte, error) { return []byte(time.Time(it).Format(jsonFormatISO8601)), nil }
go
func (it ISO6801Time) MarshalJSON() ([]byte, error) { return []byte(time.Time(it).Format(jsonFormatISO8601)), nil }
[ "func", "(", "it", "ISO6801Time", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "[", "]", "byte", "(", "time", ".", "Time", "(", "it", ")", ".", "Format", "(", "jsonFormatISO8601", ")", ")", ",", "nil", "\...
// MarshalJSON serializes the ISO6801Time into JSON string
[ "MarshalJSON", "serializes", "the", "ISO6801Time", "into", "JSON", "string" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/util/iso6801.go#L46-L48
30,105
denverdino/aliyungo
util/iso6801.go
UnmarshalJSON
func (it *ISO6801Time) UnmarshalJSON(data []byte) error { str := string(data) if str == "\"\"" || len(data) == 0 { return nil } var t time.Time var err error if str[0] == '"' { t, err = time.ParseInLocation(jsonFormatISO8601, str, time.UTC) if err != nil { t, err = time.ParseInLocation(jsonFormatISO8601...
go
func (it *ISO6801Time) UnmarshalJSON(data []byte) error { str := string(data) if str == "\"\"" || len(data) == 0 { return nil } var t time.Time var err error if str[0] == '"' { t, err = time.ParseInLocation(jsonFormatISO8601, str, time.UTC) if err != nil { t, err = time.ParseInLocation(jsonFormatISO8601...
[ "func", "(", "it", "*", "ISO6801Time", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "str", ":=", "string", "(", "data", ")", "\n\n", "if", "str", "==", "\"", "\\\"", "\\\"", "\"", "||", "len", "(", "data", ")", "==", "0...
// UnmarshalJSON deserializes the ISO6801Time from JSON string
[ "UnmarshalJSON", "deserializes", "the", "ISO6801Time", "from", "JSON", "string" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/util/iso6801.go#L51-L75
30,106
denverdino/aliyungo
ecs/disks.go
WaitForDisk
func (client *Client) WaitForDisk(regionId common.Region, diskId string, status DiskStatus, timeout int) error { if timeout <= 0 { timeout = DefaultTimeout } args := DescribeDisksArgs{ RegionId: regionId, DiskIds: []string{diskId}, } for { disks, _, err := client.DescribeDisks(&args) if err != nil { ...
go
func (client *Client) WaitForDisk(regionId common.Region, diskId string, status DiskStatus, timeout int) error { if timeout <= 0 { timeout = DefaultTimeout } args := DescribeDisksArgs{ RegionId: regionId, DiskIds: []string{diskId}, } for { disks, _, err := client.DescribeDisks(&args) if err != nil { ...
[ "func", "(", "client", "*", "Client", ")", "WaitForDisk", "(", "regionId", "common", ".", "Region", ",", "diskId", "string", ",", "status", "DiskStatus", ",", "timeout", "int", ")", "error", "{", "if", "timeout", "<=", "0", "{", "timeout", "=", "DefaultT...
// WaitForDisk waits for disk to given status
[ "WaitForDisk", "waits", "for", "disk", "to", "given", "status" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/ecs/disks.go#L336-L363
30,107
denverdino/aliyungo
cms/bytesbuffer/bytesbuffer.go
WriteByteString
func (this *BytesBuffer) WriteByteString(byteStr string) error { var tmp []byte = make([]byte, 2) re := regexp.MustCompile("[^a-fA-F0-9]") clean_str := re.ReplaceAllString(byteStr, "") src := bytes.NewBufferString(clean_str) cnt := src.Len() / 2 for i := 0; i < cnt; i++ { num := 0 _, err := src.Read(tmp) ...
go
func (this *BytesBuffer) WriteByteString(byteStr string) error { var tmp []byte = make([]byte, 2) re := regexp.MustCompile("[^a-fA-F0-9]") clean_str := re.ReplaceAllString(byteStr, "") src := bytes.NewBufferString(clean_str) cnt := src.Len() / 2 for i := 0; i < cnt; i++ { num := 0 _, err := src.Read(tmp) ...
[ "func", "(", "this", "*", "BytesBuffer", ")", "WriteByteString", "(", "byteStr", "string", ")", "error", "{", "var", "tmp", "[", "]", "byte", "=", "make", "(", "[", "]", "byte", ",", "2", ")", "\n\n", "re", ":=", "regexp", ".", "MustCompile", "(", ...
// \x31\x32\x33\x34 -> 1234 // %31%32%33%34 -> 1234 // 31323334 -> 1234
[ "\\", "x31", "\\", "x32", "\\", "x33", "\\", "x34", "-", ">", "1234", "%31%32%33%34", "-", ">", "1234", "31323334", "-", ">", "1234" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/cms/bytesbuffer/bytesbuffer.go#L61-L81
30,108
denverdino/aliyungo
cms/bytesbuffer/bytesbuffer.go
WriteToByteString
func (this *BytesBuffer) WriteToByteString(w io.Writer, prefix string) (n int64, err error) { slen := this.Buffer.Len() dst := bytes.NewBufferString("") for i := 0; i < slen; i++ { c, _ := this.Buffer.ReadByte() dst.WriteString(fmt.Sprintf("%s%02X", prefix, c)) } return dst.WriteTo(w) }
go
func (this *BytesBuffer) WriteToByteString(w io.Writer, prefix string) (n int64, err error) { slen := this.Buffer.Len() dst := bytes.NewBufferString("") for i := 0; i < slen; i++ { c, _ := this.Buffer.ReadByte() dst.WriteString(fmt.Sprintf("%s%02X", prefix, c)) } return dst.WriteTo(w) }
[ "func", "(", "this", "*", "BytesBuffer", ")", "WriteToByteString", "(", "w", "io", ".", "Writer", ",", "prefix", "string", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "slen", ":=", "this", ".", "Buffer", ".", "Len", "(", ")", "\n", "dst"...
// Buffer will be empty after Write
[ "Buffer", "will", "be", "empty", "after", "Write" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/cms/bytesbuffer/bytesbuffer.go#L99-L109
30,109
denverdino/aliyungo
common/regions.go
IsValidRegion
func IsValidRegion(r string) bool { for _, v := range ValidRegions { if r == string(v) { return true } } return false }
go
func IsValidRegion(r string) bool { for _, v := range ValidRegions { if r == string(v) { return true } } return false }
[ "func", "IsValidRegion", "(", "r", "string", ")", "bool", "{", "for", "_", ",", "v", ":=", "range", "ValidRegions", "{", "if", "r", "==", "string", "(", "v", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsValidRegion checks if r is an Ali supported region.
[ "IsValidRegion", "checks", "if", "r", "is", "an", "Ali", "supported", "region", "." ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/common/regions.go#L48-L55
30,110
denverdino/aliyungo
oss/client.go
NewOSSClientForAssumeRole
func NewOSSClientForAssumeRole(region Region, internal bool, accessKeyId string, accessKeySecret string, securityToken string, secure bool) *Client { return &Client{ AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, SecurityToken: securityToken, Region: region, Internal: inter...
go
func NewOSSClientForAssumeRole(region Region, internal bool, accessKeyId string, accessKeySecret string, securityToken string, secure bool) *Client { return &Client{ AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, SecurityToken: securityToken, Region: region, Internal: inter...
[ "func", "NewOSSClientForAssumeRole", "(", "region", "Region", ",", "internal", "bool", ",", "accessKeyId", "string", ",", "accessKeySecret", "string", ",", "securityToken", "string", ",", "secure", "bool", ")", "*", "Client", "{", "return", "&", "Client", "{", ...
// NewOSSClient creates a new OSS.
[ "NewOSSClient", "creates", "a", "new", "OSS", "." ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L96-L106
30,111
denverdino/aliyungo
oss/client.go
GetWithParams
func (b *Bucket) GetWithParams(path string, params url.Values) (data []byte, err error) { resp, err := b.GetResponseWithParamsAndHeaders(path, params, nil) if err != nil { return nil, err } data, err = ioutil.ReadAll(resp.Body) resp.Body.Close() return data, err }
go
func (b *Bucket) GetWithParams(path string, params url.Values) (data []byte, err error) { resp, err := b.GetResponseWithParamsAndHeaders(path, params, nil) if err != nil { return nil, err } data, err = ioutil.ReadAll(resp.Body) resp.Body.Close() return data, err }
[ "func", "(", "b", "*", "Bucket", ")", "GetWithParams", "(", "path", "string", ",", "params", "url", ".", "Values", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "resp", ",", "err", ":=", "b", ".", "GetResponseWithParamsAndHeaders",...
// Get retrieves an object from an bucket.
[ "Get", "retrieves", "an", "object", "from", "an", "bucket", "." ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L319-L327
30,112
denverdino/aliyungo
oss/client.go
Exists
func (b *Bucket) Exists(path string) (exists bool, err error) { for attempt := attempts.Start(); attempt.Next(); { req := &request{ method: "HEAD", bucket: b.Name, path: path, } err = b.Client.prepare(req) if err != nil { return } resp, err := b.Client.run(req, nil) if shouldRetry(err) &&...
go
func (b *Bucket) Exists(path string) (exists bool, err error) { for attempt := attempts.Start(); attempt.Next(); { req := &request{ method: "HEAD", bucket: b.Name, path: path, } err = b.Client.prepare(req) if err != nil { return } resp, err := b.Client.run(req, nil) if shouldRetry(err) &&...
[ "func", "(", "b", "*", "Bucket", ")", "Exists", "(", "path", "string", ")", "(", "exists", "bool", ",", "err", "error", ")", "{", "for", "attempt", ":=", "attempts", ".", "Start", "(", ")", ";", "attempt", ".", "Next", "(", ")", ";", "{", "req", ...
// Exists checks whether or not an object exists on an bucket using a HEAD request.
[ "Exists", "checks", "whether", "or", "not", "an", "object", "exists", "on", "an", "bucket", "using", "a", "HEAD", "request", "." ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L355-L390
30,113
denverdino/aliyungo
oss/client.go
SignedURLWithArgs
func (b *Bucket) SignedURLWithArgs(path string, expires time.Time, params url.Values, headers http.Header) string { return b.SignedURLWithMethod("GET", path, expires, params, headers) }
go
func (b *Bucket) SignedURLWithArgs(path string, expires time.Time, params url.Values, headers http.Header) string { return b.SignedURLWithMethod("GET", path, expires, params, headers) }
[ "func", "(", "b", "*", "Bucket", ")", "SignedURLWithArgs", "(", "path", "string", ",", "expires", "time", ".", "Time", ",", "params", "url", ".", "Values", ",", "headers", "http", ".", "Header", ")", "string", "{", "return", "b", ".", "SignedURLWithMetho...
// SignedURLWithArgs returns a signed URL that allows anyone holding the URL // to retrieve the object at path. The signature is valid until expires.
[ "SignedURLWithArgs", "returns", "a", "signed", "URL", "that", "allows", "anyone", "holding", "the", "URL", "to", "retrieve", "the", "object", "at", "path", ".", "The", "signature", "is", "valid", "until", "expires", "." ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L850-L852
30,114
denverdino/aliyungo
oss/client.go
SignedURLWithMethod
func (b *Bucket) SignedURLWithMethod(method, path string, expires time.Time, params url.Values, headers http.Header) string { var uv = url.Values{} if params != nil { uv = params } uv.Set("Expires", strconv.FormatInt(expires.Unix(), 10)) uv.Set("OSSAccessKeyId", b.AccessKeyId) req := &request{ method: met...
go
func (b *Bucket) SignedURLWithMethod(method, path string, expires time.Time, params url.Values, headers http.Header) string { var uv = url.Values{} if params != nil { uv = params } uv.Set("Expires", strconv.FormatInt(expires.Unix(), 10)) uv.Set("OSSAccessKeyId", b.AccessKeyId) req := &request{ method: met...
[ "func", "(", "b", "*", "Bucket", ")", "SignedURLWithMethod", "(", "method", ",", "path", "string", ",", "expires", "time", ".", "Time", ",", "params", "url", ".", "Values", ",", "headers", "http", ".", "Header", ")", "string", "{", "var", "uv", "=", ...
// SignedURLWithMethod returns a signed URL that allows anyone holding the URL // to either retrieve the object at path or make a HEAD request against it. The signature is valid until expires.
[ "SignedURLWithMethod", "returns", "a", "signed", "URL", "that", "allows", "anyone", "holding", "the", "URL", "to", "either", "retrieve", "the", "object", "at", "path", "or", "make", "a", "HEAD", "request", "against", "it", ".", "The", "signature", "is", "val...
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L867-L894
30,115
denverdino/aliyungo
oss/client.go
PostFormArgsEx
func (b *Bucket) PostFormArgsEx(path string, expires time.Time, redirect string, conds []string) (action string, fields map[string]string) { conditions := []string{} fields = map[string]string{ "AWSAccessKeyId": b.AccessKeyId, "key": path, } if conds != nil { conditions = append(conditions, conds....
go
func (b *Bucket) PostFormArgsEx(path string, expires time.Time, redirect string, conds []string) (action string, fields map[string]string) { conditions := []string{} fields = map[string]string{ "AWSAccessKeyId": b.AccessKeyId, "key": path, } if conds != nil { conditions = append(conditions, conds....
[ "func", "(", "b", "*", "Bucket", ")", "PostFormArgsEx", "(", "path", "string", ",", "expires", "time", ".", "Time", ",", "redirect", "string", ",", "conds", "[", "]", "string", ")", "(", "action", "string", ",", "fields", "map", "[", "string", "]", "...
// PostFormArgsEx returns the action and input fields needed to allow anonymous // uploads to a bucket within the expiration limit // Additional conditions can be specified with conds
[ "PostFormArgsEx", "returns", "the", "action", "and", "input", "fields", "needed", "to", "allow", "anonymous", "uploads", "to", "a", "bucket", "within", "the", "expiration", "limit", "Additional", "conditions", "can", "be", "specified", "with", "conds" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L936-L966
30,116
denverdino/aliyungo
oss/client.go
PostFormArgs
func (b *Bucket) PostFormArgs(path string, expires time.Time, redirect string) (action string, fields map[string]string) { return b.PostFormArgsEx(path, expires, redirect, nil) }
go
func (b *Bucket) PostFormArgs(path string, expires time.Time, redirect string) (action string, fields map[string]string) { return b.PostFormArgsEx(path, expires, redirect, nil) }
[ "func", "(", "b", "*", "Bucket", ")", "PostFormArgs", "(", "path", "string", ",", "expires", "time", ".", "Time", ",", "redirect", "string", ")", "(", "action", "string", ",", "fields", "map", "[", "string", "]", "string", ")", "{", "return", "b", "....
// PostFormArgs returns the action and input fields needed to allow anonymous // uploads to a bucket within the expiration limit
[ "PostFormArgs", "returns", "the", "action", "and", "input", "fields", "needed", "to", "allow", "anonymous", "uploads", "to", "a", "bucket", "within", "the", "expiration", "limit" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L970-L972
30,117
denverdino/aliyungo
oss/client.go
prepare
func (client *Client) prepare(req *request) error { // Copy so they can be mutated without affecting on retries. headers := copyHeader(req.headers) // security-token should be in either Params or Header, cannot be in both if len(req.params.Get("security-token")) == 0 && len(client.SecurityToken) != 0 { headers.Se...
go
func (client *Client) prepare(req *request) error { // Copy so they can be mutated without affecting on retries. headers := copyHeader(req.headers) // security-token should be in either Params or Header, cannot be in both if len(req.params.Get("security-token")) == 0 && len(client.SecurityToken) != 0 { headers.Se...
[ "func", "(", "client", "*", "Client", ")", "prepare", "(", "req", "*", "request", ")", "error", "{", "// Copy so they can be mutated without affecting on retries.", "headers", ":=", "copyHeader", "(", "req", ".", "headers", ")", "\n", "// security-token should be in e...
// prepare sets up req to be delivered to OSS.
[ "prepare", "sets", "up", "req", "to", "be", "delivered", "to", "OSS", "." ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L1050-L1087
30,118
denverdino/aliyungo
oss/client.go
CopyLargeFileInParallel
func (b *Bucket) CopyLargeFileInParallel(sourcePath string, destPath string, contentType string, perm ACL, options Options, maxConcurrency int) error { if maxConcurrency < 1 { maxConcurrency = 1 } currentLength, err := b.GetContentLength(sourcePath) log.Printf("Parallel Copy large file[size: %d] from %s to %s\...
go
func (b *Bucket) CopyLargeFileInParallel(sourcePath string, destPath string, contentType string, perm ACL, options Options, maxConcurrency int) error { if maxConcurrency < 1 { maxConcurrency = 1 } currentLength, err := b.GetContentLength(sourcePath) log.Printf("Parallel Copy large file[size: %d] from %s to %s\...
[ "func", "(", "b", "*", "Bucket", ")", "CopyLargeFileInParallel", "(", "sourcePath", "string", ",", "destPath", "string", ",", "contentType", "string", ",", "perm", "ACL", ",", "options", "Options", ",", "maxConcurrency", "int", ")", "error", "{", "if", "maxC...
// Copy large file in the same bucket
[ "Copy", "large", "file", "in", "the", "same", "bucket" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/oss/client.go#L1346-L1421
30,119
denverdino/aliyungo
util/signature.go
CreateSignature
func CreateSignature(stringToSignature, accessKeySecret string) string { // Crypto by HMAC-SHA1 hmacSha1 := hmac.New(sha1.New, []byte(accessKeySecret)) hmacSha1.Write([]byte(stringToSignature)) sign := hmacSha1.Sum(nil) // Encode to Base64 base64Sign := base64.StdEncoding.EncodeToString(sign) return base64Sign...
go
func CreateSignature(stringToSignature, accessKeySecret string) string { // Crypto by HMAC-SHA1 hmacSha1 := hmac.New(sha1.New, []byte(accessKeySecret)) hmacSha1.Write([]byte(stringToSignature)) sign := hmacSha1.Sum(nil) // Encode to Base64 base64Sign := base64.StdEncoding.EncodeToString(sign) return base64Sign...
[ "func", "CreateSignature", "(", "stringToSignature", ",", "accessKeySecret", "string", ")", "string", "{", "// Crypto by HMAC-SHA1", "hmacSha1", ":=", "hmac", ".", "New", "(", "sha1", ".", "New", ",", "[", "]", "byte", "(", "accessKeySecret", ")", ")", "\n", ...
//CreateSignature creates signature for string following Aliyun rules
[ "CreateSignature", "creates", "signature", "for", "string", "following", "Aliyun", "rules" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/util/signature.go#L12-L22
30,120
denverdino/aliyungo
util/signature.go
CreateSignatureForRequest
func CreateSignatureForRequest(method string, values *url.Values, accessKeySecret string) string { canonicalizedQueryString := percentReplace(values.Encode()) stringToSign := method + "&%2F&" + url.QueryEscape(canonicalizedQueryString) return CreateSignature(stringToSign, accessKeySecret) }
go
func CreateSignatureForRequest(method string, values *url.Values, accessKeySecret string) string { canonicalizedQueryString := percentReplace(values.Encode()) stringToSign := method + "&%2F&" + url.QueryEscape(canonicalizedQueryString) return CreateSignature(stringToSign, accessKeySecret) }
[ "func", "CreateSignatureForRequest", "(", "method", "string", ",", "values", "*", "url", ".", "Values", ",", "accessKeySecret", "string", ")", "string", "{", "canonicalizedQueryString", ":=", "percentReplace", "(", "values", ".", "Encode", "(", ")", ")", "\n\n",...
// CreateSignatureForRequest creates signature for query string values
[ "CreateSignatureForRequest", "creates", "signature", "for", "query", "string", "values" ]
611ead8a6fedf409d6512b6e4f44f3f1cbc65755
https://github.com/denverdino/aliyungo/blob/611ead8a6fedf409d6512b6e4f44f3f1cbc65755/util/signature.go#L33-L39
30,121
alecthomas/jsonschema
reflect.go
ReflectFromType
func ReflectFromType(t reflect.Type) *Schema { r := &Reflector{} return r.ReflectFromType(t) }
go
func ReflectFromType(t reflect.Type) *Schema { r := &Reflector{} return r.ReflectFromType(t) }
[ "func", "ReflectFromType", "(", "t", "reflect", ".", "Type", ")", "*", "Schema", "{", "r", ":=", "&", "Reflector", "{", "}", "\n", "return", "r", ".", "ReflectFromType", "(", "t", ")", "\n", "}" ]
// ReflectFromType generates root schema using the default Reflector
[ "ReflectFromType", "generates", "root", "schema", "using", "the", "default", "Reflector" ]
eff3f6c90428ddd2d988c9b686d92488c6430b77
https://github.com/alecthomas/jsonschema/blob/eff3f6c90428ddd2d988c9b686d92488c6430b77/reflect.go#L81-L84
30,122
alecthomas/jsonschema
reflect.go
Reflect
func (r *Reflector) Reflect(v interface{}) *Schema { return r.ReflectFromType(reflect.TypeOf(v)) }
go
func (r *Reflector) Reflect(v interface{}) *Schema { return r.ReflectFromType(reflect.TypeOf(v)) }
[ "func", "(", "r", "*", "Reflector", ")", "Reflect", "(", "v", "interface", "{", "}", ")", "*", "Schema", "{", "return", "r", ".", "ReflectFromType", "(", "reflect", ".", "TypeOf", "(", "v", ")", ")", "\n", "}" ]
// Reflect reflects to Schema from a value.
[ "Reflect", "reflects", "to", "Schema", "from", "a", "value", "." ]
eff3f6c90428ddd2d988c9b686d92488c6430b77
https://github.com/alecthomas/jsonschema/blob/eff3f6c90428ddd2d988c9b686d92488c6430b77/reflect.go#L106-L108
30,123
alecthomas/jsonschema
reflect.go
ReflectFromType
func (r *Reflector) ReflectFromType(t reflect.Type) *Schema { definitions := Definitions{} if r.ExpandedStruct { st := &Type{ Version: Version, Type: "object", Properties: map[string]*Type{}, AdditionalProperties: []byte("false"), } if r.AllowAdditionalProperti...
go
func (r *Reflector) ReflectFromType(t reflect.Type) *Schema { definitions := Definitions{} if r.ExpandedStruct { st := &Type{ Version: Version, Type: "object", Properties: map[string]*Type{}, AdditionalProperties: []byte("false"), } if r.AllowAdditionalProperti...
[ "func", "(", "r", "*", "Reflector", ")", "ReflectFromType", "(", "t", "reflect", ".", "Type", ")", "*", "Schema", "{", "definitions", ":=", "Definitions", "{", "}", "\n", "if", "r", ".", "ExpandedStruct", "{", "st", ":=", "&", "Type", "{", "Version", ...
// ReflectFromType generates root schema
[ "ReflectFromType", "generates", "root", "schema" ]
eff3f6c90428ddd2d988c9b686d92488c6430b77
https://github.com/alecthomas/jsonschema/blob/eff3f6c90428ddd2d988c9b686d92488c6430b77/reflect.go#L111-L134
30,124
alecthomas/jsonschema
reflect.go
reflectStruct
func (r *Reflector) reflectStruct(definitions Definitions, t reflect.Type) *Type { st := &Type{ Type: "object", Properties: map[string]*Type{}, AdditionalProperties: []byte("false"), } if r.AllowAdditionalProperties { st.AdditionalProperties = []byte("true") } definitions[t.Name()...
go
func (r *Reflector) reflectStruct(definitions Definitions, t reflect.Type) *Type { st := &Type{ Type: "object", Properties: map[string]*Type{}, AdditionalProperties: []byte("false"), } if r.AllowAdditionalProperties { st.AdditionalProperties = []byte("true") } definitions[t.Name()...
[ "func", "(", "r", "*", "Reflector", ")", "reflectStruct", "(", "definitions", "Definitions", ",", "t", "reflect", ".", "Type", ")", "*", "Type", "{", "st", ":=", "&", "Type", "{", "Type", ":", "\"", "\"", ",", "Properties", ":", "map", "[", "string",...
// Refects a struct to a JSON Schema type.
[ "Refects", "a", "struct", "to", "a", "JSON", "Schema", "type", "." ]
eff3f6c90428ddd2d988c9b686d92488c6430b77
https://github.com/alecthomas/jsonschema/blob/eff3f6c90428ddd2d988c9b686d92488c6430b77/reflect.go#L248-L264
30,125
alecthomas/jsonschema
reflect.go
genericKeywords
func (t *Type) genericKeywords(tags []string) { for _, tag := range tags { nameValue := strings.Split(tag, "=") if len(nameValue) == 2 { name, val := nameValue[0], nameValue[1] switch name { case "title": t.Title = val case "description": t.Description = val } } } }
go
func (t *Type) genericKeywords(tags []string) { for _, tag := range tags { nameValue := strings.Split(tag, "=") if len(nameValue) == 2 { name, val := nameValue[0], nameValue[1] switch name { case "title": t.Title = val case "description": t.Description = val } } } }
[ "func", "(", "t", "*", "Type", ")", "genericKeywords", "(", "tags", "[", "]", "string", ")", "{", "for", "_", ",", "tag", ":=", "range", "tags", "{", "nameValue", ":=", "strings", ".", "Split", "(", "tag", ",", "\"", "\"", ")", "\n", "if", "len",...
// read struct tags for generic keyworks
[ "read", "struct", "tags", "for", "generic", "keyworks" ]
eff3f6c90428ddd2d988c9b686d92488c6430b77
https://github.com/alecthomas/jsonschema/blob/eff3f6c90428ddd2d988c9b686d92488c6430b77/reflect.go#L312-L325
30,126
alecthomas/jsonschema
reflect.go
stringKeywords
func (t *Type) stringKeywords(tags []string) { for _, tag := range tags { nameValue := strings.Split(tag, "=") if len(nameValue) == 2 { name, val := nameValue[0], nameValue[1] switch name { case "minLength": i, _ := strconv.Atoi(val) t.MinLength = i case "maxLength": i, _ := strconv.Atoi(va...
go
func (t *Type) stringKeywords(tags []string) { for _, tag := range tags { nameValue := strings.Split(tag, "=") if len(nameValue) == 2 { name, val := nameValue[0], nameValue[1] switch name { case "minLength": i, _ := strconv.Atoi(val) t.MinLength = i case "maxLength": i, _ := strconv.Atoi(va...
[ "func", "(", "t", "*", "Type", ")", "stringKeywords", "(", "tags", "[", "]", "string", ")", "{", "for", "_", ",", "tag", ":=", "range", "tags", "{", "nameValue", ":=", "strings", ".", "Split", "(", "tag", ",", "\"", "\"", ")", "\n", "if", "len", ...
// read struct tags for string type keyworks
[ "read", "struct", "tags", "for", "string", "type", "keyworks" ]
eff3f6c90428ddd2d988c9b686d92488c6430b77
https://github.com/alecthomas/jsonschema/blob/eff3f6c90428ddd2d988c9b686d92488c6430b77/reflect.go#L328-L355
30,127
alecthomas/jsonschema
reflect.go
numbericKeywords
func (t *Type) numbericKeywords(tags []string) { for _, tag := range tags { nameValue := strings.Split(tag, "=") if len(nameValue) == 2 { name, val := nameValue[0], nameValue[1] switch name { case "multipleOf": i, _ := strconv.Atoi(val) t.MultipleOf = i case "minimum": i, _ := strconv.Atoi(...
go
func (t *Type) numbericKeywords(tags []string) { for _, tag := range tags { nameValue := strings.Split(tag, "=") if len(nameValue) == 2 { name, val := nameValue[0], nameValue[1] switch name { case "multipleOf": i, _ := strconv.Atoi(val) t.MultipleOf = i case "minimum": i, _ := strconv.Atoi(...
[ "func", "(", "t", "*", "Type", ")", "numbericKeywords", "(", "tags", "[", "]", "string", ")", "{", "for", "_", ",", "tag", ":=", "range", "tags", "{", "nameValue", ":=", "strings", ".", "Split", "(", "tag", ",", "\"", "\"", ")", "\n", "if", "len"...
// read struct tags for numberic type keyworks
[ "read", "struct", "tags", "for", "numberic", "type", "keyworks" ]
eff3f6c90428ddd2d988c9b686d92488c6430b77
https://github.com/alecthomas/jsonschema/blob/eff3f6c90428ddd2d988c9b686d92488c6430b77/reflect.go#L358-L389
30,128
bitfinexcom/bitfinex-api-go
utils/nonce.go
GetNonce
func (u *EpochNonceGenerator) GetNonce() string { return strconv.FormatUint(atomic.AddUint64(&u.nonce, 1), 10) }
go
func (u *EpochNonceGenerator) GetNonce() string { return strconv.FormatUint(atomic.AddUint64(&u.nonce, 1), 10) }
[ "func", "(", "u", "*", "EpochNonceGenerator", ")", "GetNonce", "(", ")", "string", "{", "return", "strconv", ".", "FormatUint", "(", "atomic", ".", "AddUint64", "(", "&", "u", ".", "nonce", ",", "1", ")", ",", "10", ")", "\n", "}" ]
// GetNonce is a naive nonce producer that takes the current Unix nano epoch // and counts upwards. // This is a naive approach because the nonce bound to the currently used API // key and as such needs to be synchronised with other instances using the same // key in order to avoid race conditions.
[ "GetNonce", "is", "a", "naive", "nonce", "producer", "that", "takes", "the", "current", "Unix", "nano", "epoch", "and", "counts", "upwards", ".", "This", "is", "a", "naive", "approach", "because", "the", "nonce", "bound", "to", "the", "currently", "used", ...
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/utils/nonce.go#L24-L26
30,129
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
Send
func (c *Client) Send(ctx context.Context, msg interface{}) error { return c.asynchronous.Send(ctx, msg) }
go
func (c *Client) Send(ctx context.Context, msg interface{}) error { return c.asynchronous.Send(ctx, msg) }
[ "func", "(", "c", "*", "Client", ")", "Send", "(", "ctx", "context", ".", "Context", ",", "msg", "interface", "{", "}", ")", "error", "{", "return", "c", ".", "asynchronous", ".", "Send", "(", "ctx", ",", "msg", ")", "\n", "}" ]
// API for end-users to interact with Bitfinex. // Send publishes a generic message to the Bitfinex API.
[ "API", "for", "end", "-", "users", "to", "interact", "with", "Bitfinex", ".", "Send", "publishes", "a", "generic", "message", "to", "the", "Bitfinex", "API", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L17-L19
30,130
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
Subscribe
func (c *Client) Subscribe(ctx context.Context, req *SubscriptionRequest) (string, error) { c.subscriptions.add(req) err := c.asynchronous.Send(ctx, req) if err != nil { // propagate send error return "", err } return req.SubID, nil }
go
func (c *Client) Subscribe(ctx context.Context, req *SubscriptionRequest) (string, error) { c.subscriptions.add(req) err := c.asynchronous.Send(ctx, req) if err != nil { // propagate send error return "", err } return req.SubID, nil }
[ "func", "(", "c", "*", "Client", ")", "Subscribe", "(", "ctx", "context", ".", "Context", ",", "req", "*", "SubscriptionRequest", ")", "(", "string", ",", "error", ")", "{", "c", ".", "subscriptions", ".", "add", "(", "req", ")", "\n", "err", ":=", ...
// Subscribe sends a subscription request to the Bitfinex API and tracks the subscription status by ID.
[ "Subscribe", "sends", "a", "subscription", "request", "to", "the", "Bitfinex", "API", "and", "tracks", "the", "subscription", "status", "by", "ID", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L34-L42
30,131
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
SubscribeTicker
func (c *Client) SubscribeTicker(ctx context.Context, symbol string) (string, error) { req := &SubscriptionRequest{ SubID: c.nonce.GetNonce(), Event: EventSubscribe, Channel: ChanTicker, Symbol: symbol, } return c.Subscribe(ctx, req) }
go
func (c *Client) SubscribeTicker(ctx context.Context, symbol string) (string, error) { req := &SubscriptionRequest{ SubID: c.nonce.GetNonce(), Event: EventSubscribe, Channel: ChanTicker, Symbol: symbol, } return c.Subscribe(ctx, req) }
[ "func", "(", "c", "*", "Client", ")", "SubscribeTicker", "(", "ctx", "context", ".", "Context", ",", "symbol", "string", ")", "(", "string", ",", "error", ")", "{", "req", ":=", "&", "SubscriptionRequest", "{", "SubID", ":", "c", ".", "nonce", ".", "...
// SubscribeTicker sends a subscription request for the ticker.
[ "SubscribeTicker", "sends", "a", "subscription", "request", "for", "the", "ticker", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L45-L53
30,132
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
SubscribeBook
func (c *Client) SubscribeBook(ctx context.Context, symbol string, precision bitfinex.BookPrecision, frequency bitfinex.BookFrequency, priceLevel int) (string, error) { if priceLevel < 0 { return "", fmt.Errorf("negative price levels not supported: %d", priceLevel) } req := &SubscriptionRequest{ SubID: c.non...
go
func (c *Client) SubscribeBook(ctx context.Context, symbol string, precision bitfinex.BookPrecision, frequency bitfinex.BookFrequency, priceLevel int) (string, error) { if priceLevel < 0 { return "", fmt.Errorf("negative price levels not supported: %d", priceLevel) } req := &SubscriptionRequest{ SubID: c.non...
[ "func", "(", "c", "*", "Client", ")", "SubscribeBook", "(", "ctx", "context", ".", "Context", ",", "symbol", "string", ",", "precision", "bitfinex", ".", "BookPrecision", ",", "frequency", "bitfinex", ".", "BookFrequency", ",", "priceLevel", "int", ")", "(",...
// SubscribeBook sends a subscription request for market data for a given symbol, at a given frequency, with a given precision, returning no more than priceLevels price entries. // Default values are Precision0, Frequency0, and priceLevels=25.
[ "SubscribeBook", "sends", "a", "subscription", "request", "for", "market", "data", "for", "a", "given", "symbol", "at", "a", "given", "frequency", "with", "a", "given", "precision", "returning", "no", "more", "than", "priceLevels", "price", "entries", ".", "De...
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L68-L84
30,133
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
SubscribeCandles
func (c *Client) SubscribeCandles(ctx context.Context, symbol string, resolution bitfinex.CandleResolution) (string, error) { req := &SubscriptionRequest{ SubID: c.nonce.GetNonce(), Event: EventSubscribe, Channel: ChanCandles, Key: fmt.Sprintf("trade:%s:%s", resolution, symbol), } return c.Subscribe(...
go
func (c *Client) SubscribeCandles(ctx context.Context, symbol string, resolution bitfinex.CandleResolution) (string, error) { req := &SubscriptionRequest{ SubID: c.nonce.GetNonce(), Event: EventSubscribe, Channel: ChanCandles, Key: fmt.Sprintf("trade:%s:%s", resolution, symbol), } return c.Subscribe(...
[ "func", "(", "c", "*", "Client", ")", "SubscribeCandles", "(", "ctx", "context", ".", "Context", ",", "symbol", "string", ",", "resolution", "bitfinex", ".", "CandleResolution", ")", "(", "string", ",", "error", ")", "{", "req", ":=", "&", "SubscriptionReq...
// SubscribeCandles sends a subscription request for OHLC candles.
[ "SubscribeCandles", "sends", "a", "subscription", "request", "for", "OHLC", "candles", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L87-L95
30,134
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
SubmitOrder
func (c *Client) SubmitOrder(ctx context.Context, order *bitfinex.OrderNewRequest) error { return c.asynchronous.Send(ctx, order) }
go
func (c *Client) SubmitOrder(ctx context.Context, order *bitfinex.OrderNewRequest) error { return c.asynchronous.Send(ctx, order) }
[ "func", "(", "c", "*", "Client", ")", "SubmitOrder", "(", "ctx", "context", ".", "Context", ",", "order", "*", "bitfinex", ".", "OrderNewRequest", ")", "error", "{", "return", "c", ".", "asynchronous", ".", "Send", "(", "ctx", ",", "order", ")", "\n", ...
// SubmitOrder sends an order request.
[ "SubmitOrder", "sends", "an", "order", "request", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L106-L108
30,135
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
SubmitCancel
func (c *Client) SubmitCancel(ctx context.Context, cancel *bitfinex.OrderCancelRequest) error { return c.asynchronous.Send(ctx, cancel) }
go
func (c *Client) SubmitCancel(ctx context.Context, cancel *bitfinex.OrderCancelRequest) error { return c.asynchronous.Send(ctx, cancel) }
[ "func", "(", "c", "*", "Client", ")", "SubmitCancel", "(", "ctx", "context", ".", "Context", ",", "cancel", "*", "bitfinex", ".", "OrderCancelRequest", ")", "error", "{", "return", "c", ".", "asynchronous", ".", "Send", "(", "ctx", ",", "cancel", ")", ...
// SubmitCancel sends a cancel request.
[ "SubmitCancel", "sends", "a", "cancel", "request", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L115-L117
30,136
bitfinexcom/bitfinex-api-go
v2/websocket/api.go
LookupSubscription
func (c *Client) LookupSubscription(subID string) (*SubscriptionRequest, error) { s, err := c.subscriptions.lookupBySubscriptionID(subID) if err != nil { return nil, err } return s.Request, nil }
go
func (c *Client) LookupSubscription(subID string) (*SubscriptionRequest, error) { s, err := c.subscriptions.lookupBySubscriptionID(subID) if err != nil { return nil, err } return s.Request, nil }
[ "func", "(", "c", "*", "Client", ")", "LookupSubscription", "(", "subID", "string", ")", "(", "*", "SubscriptionRequest", ",", "error", ")", "{", "s", ",", "err", ":=", "c", ".", "subscriptions", ".", "lookupBySubscriptionID", "(", "subID", ")", "\n", "i...
// LookupSubscription looks up a subscription request by ID
[ "LookupSubscription", "looks", "up", "a", "subscription", "request", "by", "ID" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/api.go#L120-L126
30,137
bitfinexcom/bitfinex-api-go
v2/websocket/transport.go
Send
func (w *ws) Send(ctx context.Context, msg interface{}) error { if w.ws == nil { return ErrWSNotConnected } bs, err := json.Marshal(msg) if err != nil { return err } select { case <- ctx.Done(): return ctx.Err() case <- w.quit: // ws closed return fmt.Errorf("websocket connection closed") default: }...
go
func (w *ws) Send(ctx context.Context, msg interface{}) error { if w.ws == nil { return ErrWSNotConnected } bs, err := json.Marshal(msg) if err != nil { return err } select { case <- ctx.Done(): return ctx.Err() case <- w.quit: // ws closed return fmt.Errorf("websocket connection closed") default: }...
[ "func", "(", "w", "*", "ws", ")", "Send", "(", "ctx", "context", ".", "Context", ",", "msg", "interface", "{", "}", ")", "error", "{", "if", "w", ".", "ws", "==", "nil", "{", "return", "ErrWSNotConnected", "\n", "}", "\n\n", "bs", ",", "err", ":=...
// Send marshals the given interface and then sends it to the API. This method // can block so specify a context with timeout if you don't want to wait for too // long.
[ "Send", "marshals", "the", "given", "interface", "and", "then", "sends", "it", "to", "the", "API", ".", "This", "method", "can", "block", "so", "specify", "a", "context", "with", "timeout", "if", "you", "don", "t", "want", "to", "wait", "for", "too", "...
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/transport.go#L69-L95
30,138
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
Create
func (w *WebsocketAsynchronousFactory) Create() Asynchronous { return newWs(w.parameters.URL, w.parameters.LogTransport, w.parameters.Logger) }
go
func (w *WebsocketAsynchronousFactory) Create() Asynchronous { return newWs(w.parameters.URL, w.parameters.LogTransport, w.parameters.Logger) }
[ "func", "(", "w", "*", "WebsocketAsynchronousFactory", ")", "Create", "(", ")", "Asynchronous", "{", "return", "newWs", "(", "w", ".", "parameters", ".", "URL", ",", "w", ".", "parameters", ".", "LogTransport", ",", "w", ".", "parameters", ".", "Logger", ...
// Create returns a new websocket transport.
[ "Create", "returns", "a", "new", "websocket", "transport", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L89-L91
30,139
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
Credentials
func (c *Client) Credentials(key string, secret string) *Client { c.apiKey = key c.apiSecret = secret return c }
go
func (c *Client) Credentials(key string, secret string) *Client { c.apiKey = key c.apiSecret = secret return c }
[ "func", "(", "c", "*", "Client", ")", "Credentials", "(", "key", "string", ",", "secret", "string", ")", "*", "Client", "{", "c", ".", "apiKey", "=", "key", "\n", "c", ".", "apiSecret", "=", "secret", "\n", "return", "c", "\n", "}" ]
// Credentials assigns authentication credentials to a connection request.
[ "Credentials", "assigns", "authentication", "credentials", "to", "a", "connection", "request", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L132-L136
30,140
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
CancelOnDisconnect
func (c *Client) CancelOnDisconnect(cxl bool) *Client { c.cancelOnDisconnect = cxl return c }
go
func (c *Client) CancelOnDisconnect(cxl bool) *Client { c.cancelOnDisconnect = cxl return c }
[ "func", "(", "c", "*", "Client", ")", "CancelOnDisconnect", "(", "cxl", "bool", ")", "*", "Client", "{", "c", ".", "cancelOnDisconnect", "=", "cxl", "\n", "return", "c", "\n", "}" ]
// CancelOnDisconnect ensures all orders will be canceled if this API session is disconnected.
[ "CancelOnDisconnect", "ensures", "all", "orders", "will", "be", "canceled", "if", "this", "API", "session", "is", "disconnected", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L139-L142
30,141
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
NewWithAsyncFactoryNonce
func NewWithAsyncFactoryNonce(async AsynchronousFactory, nonce utils.NonceGenerator) *Client { return NewWithParamsAsyncFactoryNonce(NewDefaultParameters(), async, nonce) }
go
func NewWithAsyncFactoryNonce(async AsynchronousFactory, nonce utils.NonceGenerator) *Client { return NewWithParamsAsyncFactoryNonce(NewDefaultParameters(), async, nonce) }
[ "func", "NewWithAsyncFactoryNonce", "(", "async", "AsynchronousFactory", ",", "nonce", "utils", ".", "NonceGenerator", ")", "*", "Client", "{", "return", "NewWithParamsAsyncFactoryNonce", "(", "NewDefaultParameters", "(", ")", ",", "async", ",", "nonce", ")", "\n", ...
// NewWithAsyncFactoryNonce creates a new default client with a given asynchronous transport factory and nonce generator.
[ "NewWithAsyncFactoryNonce", "creates", "a", "new", "default", "client", "with", "a", "given", "asynchronous", "transport", "factory", "and", "nonce", "generator", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L173-L175
30,142
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
NewWithParamsNonce
func NewWithParamsNonce(params *Parameters, nonce utils.NonceGenerator) *Client { return NewWithParamsAsyncFactoryNonce(params, NewWebsocketAsynchronousFactory(params), nonce) }
go
func NewWithParamsNonce(params *Parameters, nonce utils.NonceGenerator) *Client { return NewWithParamsAsyncFactoryNonce(params, NewWebsocketAsynchronousFactory(params), nonce) }
[ "func", "NewWithParamsNonce", "(", "params", "*", "Parameters", ",", "nonce", "utils", ".", "NonceGenerator", ")", "*", "Client", "{", "return", "NewWithParamsAsyncFactoryNonce", "(", "params", ",", "NewWebsocketAsynchronousFactory", "(", "params", ")", ",", "nonce"...
// NewWithParamsNonce creates a new default client with a given set of parameters and nonce generator.
[ "NewWithParamsNonce", "creates", "a", "new", "default", "client", "with", "a", "given", "set", "of", "parameters", "and", "nonce", "generator", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L178-L180
30,143
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
NewWithParamsAsyncFactory
func NewWithParamsAsyncFactory(params *Parameters, async AsynchronousFactory) *Client { return NewWithParamsAsyncFactoryNonce(params, async, utils.NewEpochNonceGenerator()) }
go
func NewWithParamsAsyncFactory(params *Parameters, async AsynchronousFactory) *Client { return NewWithParamsAsyncFactoryNonce(params, async, utils.NewEpochNonceGenerator()) }
[ "func", "NewWithParamsAsyncFactory", "(", "params", "*", "Parameters", ",", "async", "AsynchronousFactory", ")", "*", "Client", "{", "return", "NewWithParamsAsyncFactoryNonce", "(", "params", ",", "async", ",", "utils", ".", "NewEpochNonceGenerator", "(", ")", ")", ...
// NewWithParamsAsyncFactory creates a new default client with a given set of parameters and asynchronous transport factory interface.
[ "NewWithParamsAsyncFactory", "creates", "a", "new", "default", "client", "with", "a", "given", "set", "of", "parameters", "and", "asynchronous", "transport", "factory", "interface", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L183-L185
30,144
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
NewWithParamsAsyncFactoryNonce
func NewWithParamsAsyncFactoryNonce(params *Parameters, async AsynchronousFactory, nonce utils.NonceGenerator) *Client { c := &Client{ asyncFactory: async, Authentication: NoAuthentication, factories: make(map[string]messageFactory), subscriptions: newSubscriptions(params.HeartbeatTimeout, params.Logge...
go
func NewWithParamsAsyncFactoryNonce(params *Parameters, async AsynchronousFactory, nonce utils.NonceGenerator) *Client { c := &Client{ asyncFactory: async, Authentication: NoAuthentication, factories: make(map[string]messageFactory), subscriptions: newSubscriptions(params.HeartbeatTimeout, params.Logge...
[ "func", "NewWithParamsAsyncFactoryNonce", "(", "params", "*", "Parameters", ",", "async", "AsynchronousFactory", ",", "nonce", "utils", ".", "NonceGenerator", ")", "*", "Client", "{", "c", ":=", "&", "Client", "{", "asyncFactory", ":", "async", ",", "Authenticat...
// NewWithParamsAsyncFactoryNonce creates a new client with a given set of parameters, asynchronous transport factory, and nonce generator interfaces.
[ "NewWithParamsAsyncFactoryNonce", "creates", "a", "new", "client", "with", "a", "given", "set", "of", "parameters", "asynchronous", "transport", "factory", "and", "nonce", "generator", "interfaces", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L188-L207
30,145
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
Connect
func (c *Client) Connect() error { c.dumpParams() c.terminal = false // wait for reset websocket signals go c.listenDisconnect() c.reset() return c.connect() }
go
func (c *Client) Connect() error { c.dumpParams() c.terminal = false // wait for reset websocket signals go c.listenDisconnect() c.reset() return c.connect() }
[ "func", "(", "c", "*", "Client", ")", "Connect", "(", ")", "error", "{", "c", ".", "dumpParams", "(", ")", "\n", "c", ".", "terminal", "=", "false", "\n", "// wait for reset websocket signals", "go", "c", ".", "listenDisconnect", "(", ")", "\n", "c", "...
// Connect to the Bitfinex API, this should only be called once.
[ "Connect", "to", "the", "Bitfinex", "API", "this", "should", "only", "be", "called", "once", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L287-L294
30,146
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
reset
func (c *Client) reset() { subs := c.subscriptions.Reset() if subs != nil { c.resetSubscriptions = subs } c.init = true ws := c.asyncFactory.Create() c.asynchronous = ws // listen to data from async go c.listenUpstream(ws) }
go
func (c *Client) reset() { subs := c.subscriptions.Reset() if subs != nil { c.resetSubscriptions = subs } c.init = true ws := c.asyncFactory.Create() c.asynchronous = ws // listen to data from async go c.listenUpstream(ws) }
[ "func", "(", "c", "*", "Client", ")", "reset", "(", ")", "{", "subs", ":=", "c", ".", "subscriptions", ".", "Reset", "(", ")", "\n", "if", "subs", "!=", "nil", "{", "c", ".", "resetSubscriptions", "=", "subs", "\n", "}", "\n", "c", ".", "init", ...
// reset assumes transport has already died or been closed
[ "reset", "assumes", "transport", "has", "already", "died", "or", "been", "closed" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L297-L308
30,147
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
listenUpstream
func (c *Client) listenUpstream(ws Asynchronous) { for { select { case <- ws.Done(): // transport shutdown c.resetWebsocket <- true return case msg := <- ws.Listen(): if msg != nil { // Errors here should be non critical so we just log them. // log.Printf("[DEBUG]: %s\n", msg) err := c.handl...
go
func (c *Client) listenUpstream(ws Asynchronous) { for { select { case <- ws.Done(): // transport shutdown c.resetWebsocket <- true return case msg := <- ws.Listen(): if msg != nil { // Errors here should be non critical so we just log them. // log.Printf("[DEBUG]: %s\n", msg) err := c.handl...
[ "func", "(", "c", "*", "Client", ")", "listenUpstream", "(", "ws", "Asynchronous", ")", "{", "for", "{", "select", "{", "case", "<-", "ws", ".", "Done", "(", ")", ":", "// transport shutdown", "c", ".", "resetWebsocket", "<-", "true", "\n", "return", "...
// start this goroutine before connecting, but this should die during a connection failure
[ "start", "this", "goroutine", "before", "connecting", "but", "this", "should", "die", "during", "a", "connection", "failure" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L359-L376
30,148
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
killListener
func (c *Client) killListener(e error) { if c.listener != nil { if e != nil { c.listener <- e } close(c.listener) } }
go
func (c *Client) killListener(e error) { if c.listener != nil { if e != nil { c.listener <- e } close(c.listener) } }
[ "func", "(", "c", "*", "Client", ")", "killListener", "(", "e", "error", ")", "{", "if", "c", ".", "listener", "!=", "nil", "{", "if", "e", "!=", "nil", "{", "c", ".", "listener", "<-", "e", "\n", "}", "\n", "close", "(", "c", ".", "listener", ...
// terminal, unrecoverable state. called after async is closed.
[ "terminal", "unrecoverable", "state", ".", "called", "after", "async", "is", "closed", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L379-L386
30,149
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
handleOpen
func (c *Client) handleOpen() error { if c.hasCredentials() { err_auth := c.authenticate(context.Background()) if err_auth != nil { return err_auth } } else { c.checkResubscription() } return nil }
go
func (c *Client) handleOpen() error { if c.hasCredentials() { err_auth := c.authenticate(context.Background()) if err_auth != nil { return err_auth } } else { c.checkResubscription() } return nil }
[ "func", "(", "c", "*", "Client", ")", "handleOpen", "(", ")", "error", "{", "if", "c", ".", "hasCredentials", "(", ")", "{", "err_auth", ":=", "c", ".", "authenticate", "(", "context", ".", "Background", "(", ")", ")", "\n", "if", "err_auth", "!=", ...
// called when an info event is received
[ "called", "when", "an", "info", "event", "is", "received" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L478-L488
30,150
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
handleAuthAck
func (c *Client) handleAuthAck(auth *AuthEvent) { if c.Authentication == SuccessfulAuthentication { err := c.subscriptions.activate(auth.SubID, auth.ChanID) if err != nil { c.log.Errorf("could not activate auth subscription: %s", err.Error()) } c.checkResubscription() } else { c.log.Error("authentication...
go
func (c *Client) handleAuthAck(auth *AuthEvent) { if c.Authentication == SuccessfulAuthentication { err := c.subscriptions.activate(auth.SubID, auth.ChanID) if err != nil { c.log.Errorf("could not activate auth subscription: %s", err.Error()) } c.checkResubscription() } else { c.log.Error("authentication...
[ "func", "(", "c", "*", "Client", ")", "handleAuthAck", "(", "auth", "*", "AuthEvent", ")", "{", "if", "c", ".", "Authentication", "==", "SuccessfulAuthentication", "{", "err", ":=", "c", ".", "subscriptions", ".", "activate", "(", "auth", ".", "SubID", "...
// called when an auth event is received
[ "called", "when", "an", "auth", "event", "is", "received" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L491-L501
30,151
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
Unsubscribe
func (c *Client) Unsubscribe(ctx context.Context, id string) error { sub, err := c.subscriptions.lookupBySubscriptionID(id) if err != nil { return err } // sub is removed from manager on ack from API return c.sendUnsubscribeMessage(ctx, sub.ChanID) }
go
func (c *Client) Unsubscribe(ctx context.Context, id string) error { sub, err := c.subscriptions.lookupBySubscriptionID(id) if err != nil { return err } // sub is removed from manager on ack from API return c.sendUnsubscribeMessage(ctx, sub.ChanID) }
[ "func", "(", "c", "*", "Client", ")", "Unsubscribe", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "error", "{", "sub", ",", "err", ":=", "c", ".", "subscriptions", ".", "lookupBySubscriptionID", "(", "id", ")", "\n", "if", "err", ...
// Unsubscribe looks up an existing subscription by ID and sends an unsubscribe request.
[ "Unsubscribe", "looks", "up", "an", "existing", "subscription", "by", "ID", "and", "sends", "an", "unsubscribe", "request", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L508-L515
30,152
bitfinexcom/bitfinex-api-go
v2/websocket/client.go
authenticate
func (c *Client) authenticate(ctx context.Context, filter ...string) error { nonce := c.nonce.GetNonce() payload := "AUTH" + nonce sig, err := c.sign(payload) if err != nil { return err } s := &SubscriptionRequest{ Event: "auth", APIKey: c.apiKey, AuthSig: sig, AuthPayload: payload, Aut...
go
func (c *Client) authenticate(ctx context.Context, filter ...string) error { nonce := c.nonce.GetNonce() payload := "AUTH" + nonce sig, err := c.sign(payload) if err != nil { return err } s := &SubscriptionRequest{ Event: "auth", APIKey: c.apiKey, AuthSig: sig, AuthPayload: payload, Aut...
[ "func", "(", "c", "*", "Client", ")", "authenticate", "(", "ctx", "context", ".", "Context", ",", "filter", "...", "string", ")", "error", "{", "nonce", ":=", "c", ".", "nonce", ".", "GetNonce", "(", ")", "\n", "payload", ":=", "\"", "\"", "+", "no...
// Authenticate creates the payload for the authentication request and sends it // to the API. The filters will be applied to the authenticated channel, i.e. // only subscribe to the filtered messages.
[ "Authenticate", "creates", "the", "payload", "for", "the", "authentication", "request", "and", "sends", "it", "to", "the", "API", ".", "The", "filters", "will", "be", "applied", "to", "the", "authenticated", "channel", "i", ".", "e", ".", "only", "subscribe"...
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/client.go#L520-L547
30,153
bitfinexcom/bitfinex-api-go
v1/websocket.go
NewWebSocketService
func NewWebSocketService(c *Client) *WebSocketService { return &WebSocketService{ client: c, chanMap: make(map[float64]chan []float64), subscribes: make([]subscribeToChannel, 0), } }
go
func NewWebSocketService(c *Client) *WebSocketService { return &WebSocketService{ client: c, chanMap: make(map[float64]chan []float64), subscribes: make([]subscribeToChannel, 0), } }
[ "func", "NewWebSocketService", "(", "c", "*", "Client", ")", "*", "WebSocketService", "{", "return", "&", "WebSocketService", "{", "client", ":", "c", ",", "chanMap", ":", "make", "(", "map", "[", "float64", "]", "chan", "[", "]", "float64", ")", ",", ...
// NewWebSocketService returns a WebSocketService using the given client.
[ "NewWebSocketService", "returns", "a", "WebSocketService", "using", "the", "given", "client", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/websocket.go#L82-L88
30,154
bitfinexcom/bitfinex-api-go
v1/websocket.go
Connect
func (w *WebSocketService) Connect() error { var d = websocket.Dialer{ Subprotocols: []string{"p1", "p2"}, ReadBufferSize: 1024, WriteBufferSize: 1024, Proxy: http.ProxyFromEnvironment, } if w.client.WebSocketTLSSkipVerify { d.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} } ws, ...
go
func (w *WebSocketService) Connect() error { var d = websocket.Dialer{ Subprotocols: []string{"p1", "p2"}, ReadBufferSize: 1024, WriteBufferSize: 1024, Proxy: http.ProxyFromEnvironment, } if w.client.WebSocketTLSSkipVerify { d.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} } ws, ...
[ "func", "(", "w", "*", "WebSocketService", ")", "Connect", "(", ")", "error", "{", "var", "d", "=", "websocket", ".", "Dialer", "{", "Subprotocols", ":", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "ReadBufferSize", ":", "1024", ...
// Connect create new bitfinex websocket connection
[ "Connect", "create", "new", "bitfinex", "websocket", "connection" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/websocket.go#L91-L109
30,155
bitfinexcom/bitfinex-api-go
v1/client.go
newRequest
func (c *Client) newRequest(method string, refURL string, params url.Values) (*http.Request, error) { rel, err := url.Parse(refURL) if err != nil { return nil, err } if params != nil { rel.RawQuery = params.Encode() } var req *http.Request u := c.BaseURL.ResolveReference(rel) req, err = http.NewRequest(meth...
go
func (c *Client) newRequest(method string, refURL string, params url.Values) (*http.Request, error) { rel, err := url.Parse(refURL) if err != nil { return nil, err } if params != nil { rel.RawQuery = params.Encode() } var req *http.Request u := c.BaseURL.ResolveReference(rel) req, err = http.NewRequest(meth...
[ "func", "(", "c", "*", "Client", ")", "newRequest", "(", "method", "string", ",", "refURL", "string", ",", "params", "url", ".", "Values", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "rel", ",", "err", ":=", "url", ".", "Parse", ...
// NewRequest create new API request. Relative url can be provided in refURL.
[ "NewRequest", "create", "new", "API", "request", ".", "Relative", "url", "can", "be", "provided", "in", "refURL", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/client.go#L86-L103
30,156
bitfinexcom/bitfinex-api-go
v1/client.go
newAuthenticatedRequest
func (c *Client) newAuthenticatedRequest(m string, refURL string, data map[string]interface{}) (*http.Request, error) { req, err := c.newRequest(m, refURL, nil) if err != nil { return nil, err } nonce := utils.GetNonce() payload := map[string]interface{}{ "request": "/v1/" + refURL, "nonce": nonce, } f...
go
func (c *Client) newAuthenticatedRequest(m string, refURL string, data map[string]interface{}) (*http.Request, error) { req, err := c.newRequest(m, refURL, nil) if err != nil { return nil, err } nonce := utils.GetNonce() payload := map[string]interface{}{ "request": "/v1/" + refURL, "nonce": nonce, } f...
[ "func", "(", "c", "*", "Client", ")", "newAuthenticatedRequest", "(", "m", "string", ",", "refURL", "string", ",", "data", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "req", ",", ...
// newAuthenticatedRequest creates new http request for authenticated routes.
[ "newAuthenticatedRequest", "creates", "new", "http", "request", "for", "authenticated", "routes", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/client.go#L106-L140
30,157
bitfinexcom/bitfinex-api-go
v1/client.go
Auth
func (c *Client) Auth(key string, secret string) *Client { c.APIKey = key c.APISecret = secret return c }
go
func (c *Client) Auth(key string, secret string) *Client { c.APIKey = key c.APISecret = secret return c }
[ "func", "(", "c", "*", "Client", ")", "Auth", "(", "key", "string", ",", "secret", "string", ")", "*", "Client", "{", "c", ".", "APIKey", "=", "key", "\n", "c", ".", "APISecret", "=", "secret", "\n\n", "return", "c", "\n", "}" ]
// Auth sets api key and secret for usage is requests that requires authentication.
[ "Auth", "sets", "api", "key", "and", "secret", "for", "usage", "is", "requests", "that", "requires", "authentication", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/client.go#L152-L157
30,158
bitfinexcom/bitfinex-api-go
v1/client.go
newResponse
func newResponse(r *http.Response) *Response { body, err := ioutil.ReadAll(r.Body) if err != nil { body = []byte(`Error reading body:` + err.Error()) } return &Response{r, body} }
go
func newResponse(r *http.Response) *Response { body, err := ioutil.ReadAll(r.Body) if err != nil { body = []byte(`Error reading body:` + err.Error()) } return &Response{r, body} }
[ "func", "newResponse", "(", "r", "*", "http", ".", "Response", ")", "*", "Response", "{", "body", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "body", "=", "[", "]", "byte", "(", "...
// newResponse creates new wrapper.
[ "newResponse", "creates", "new", "wrapper", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/client.go#L198-L205
30,159
bitfinexcom/bitfinex-api-go
v2/rest/client.go
NewClientWithSynchronousURLNonce
func NewClientWithSynchronousURLNonce(sync Synchronous, url string, nonce utils.NonceGenerator) *Client { c := &Client{ Synchronous: sync, nonce: nonce, } c.Orders = OrderService{Synchronous: c, requestFactory: c} c.Book = BookService{Synchronous: c} c.Candles = CandleService{Synchronous: c} c.Trades = ...
go
func NewClientWithSynchronousURLNonce(sync Synchronous, url string, nonce utils.NonceGenerator) *Client { c := &Client{ Synchronous: sync, nonce: nonce, } c.Orders = OrderService{Synchronous: c, requestFactory: c} c.Book = BookService{Synchronous: c} c.Candles = CandleService{Synchronous: c} c.Trades = ...
[ "func", "NewClientWithSynchronousURLNonce", "(", "sync", "Synchronous", ",", "url", "string", ",", "nonce", "utils", ".", "NonceGenerator", ")", "*", "Client", "{", "c", ":=", "&", "Client", "{", "Synchronous", ":", "sync", ",", "nonce", ":", "nonce", ",", ...
// mock me in tests
[ "mock", "me", "in", "tests" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/rest/client.go#L88-L103
30,160
bitfinexcom/bitfinex-api-go
v2/websocket/subscriptions.go
Reset
func (s *subscriptions) Reset() []*subscription { subs := s.reset() s.lock.Lock() s.hbActive = false s.subsBySubID = make(map[string]*subscription) s.subsByChanID = make(map[int64]*subscription) s.lock.Unlock() return subs }
go
func (s *subscriptions) Reset() []*subscription { subs := s.reset() s.lock.Lock() s.hbActive = false s.subsBySubID = make(map[string]*subscription) s.subsByChanID = make(map[int64]*subscription) s.lock.Unlock() return subs }
[ "func", "(", "s", "*", "subscriptions", ")", "Reset", "(", ")", "[", "]", "*", "subscription", "{", "subs", ":=", "s", ".", "reset", "(", ")", "\n", "s", ".", "lock", ".", "Lock", "(", ")", "\n", "s", ".", "hbActive", "=", "false", "\n", "s", ...
// Reset clears all subscriptions from the currently managed list, and returns // a slice of the existing subscriptions prior to reset. Returns nil if no subscriptions exist.
[ "Reset", "clears", "all", "subscriptions", "from", "the", "currently", "managed", "list", "and", "returns", "a", "slice", "of", "the", "existing", "subscriptions", "prior", "to", "reset", ".", "Returns", "nil", "if", "no", "subscriptions", "exist", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/subscriptions.go#L200-L208
30,161
bitfinexcom/bitfinex-api-go
v2/types.go
MarshalJSON
func (o *OrderCancelRequest) MarshalJSON() ([]byte, error) { aux := struct { ID int64 `json:"id,omitempty"` CID int64 `json:"cid,omitempty"` CIDDate string `json:"cid_date,omitempty"` }{ ID: o.ID, CID: o.CID, CIDDate: o.CIDDate, } body := []interface{}{0, "oc", nil, aux} return jso...
go
func (o *OrderCancelRequest) MarshalJSON() ([]byte, error) { aux := struct { ID int64 `json:"id,omitempty"` CID int64 `json:"cid,omitempty"` CIDDate string `json:"cid_date,omitempty"` }{ ID: o.ID, CID: o.CID, CIDDate: o.CIDDate, } body := []interface{}{0, "oc", nil, aux} return jso...
[ "func", "(", "o", "*", "OrderCancelRequest", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "aux", ":=", "struct", "{", "ID", "int64", "`json:\"id,omitempty\"`", "\n", "CID", "int64", "`json:\"cid,omitempty\"`", "\n", "CIDDate",...
// MarshalJSON converts the order cancel object into the format required by the // bitfinex websocket service.
[ "MarshalJSON", "converts", "the", "order", "cancel", "object", "into", "the", "format", "required", "by", "the", "bitfinex", "websocket", "service", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/types.go#L271-L284
30,162
bitfinexcom/bitfinex-api-go
v2/types.go
NewOrderFromRaw
func NewOrderFromRaw(raw []interface{}) (o *Order, err error) { if len(raw) == 12 { o = &Order{ ID: int64(f64ValOrZero(raw[0])), Symbol: sValOrEmpty(raw[1]), Amount: f64ValOrZero(raw[2]), AmountOrig: f64ValOrZero(raw[3]), Type: sValOrEmpty(raw[4]), Status: OrderStatus(sVal...
go
func NewOrderFromRaw(raw []interface{}) (o *Order, err error) { if len(raw) == 12 { o = &Order{ ID: int64(f64ValOrZero(raw[0])), Symbol: sValOrEmpty(raw[1]), Amount: f64ValOrZero(raw[2]), AmountOrig: f64ValOrZero(raw[3]), Type: sValOrEmpty(raw[4]), Status: OrderStatus(sVal...
[ "func", "NewOrderFromRaw", "(", "raw", "[", "]", "interface", "{", "}", ")", "(", "o", "*", "Order", ",", "err", "error", ")", "{", "if", "len", "(", "raw", ")", "==", "12", "{", "o", "=", "&", "Order", "{", "ID", ":", "int64", "(", "f64ValOrZe...
// NewOrderFromRaw takes the raw list of values as returned from the websocket // service and tries to convert it into an Order.
[ "NewOrderFromRaw", "takes", "the", "raw", "list", "of", "values", "as", "returned", "from", "the", "websocket", "service", "and", "tries", "to", "convert", "it", "into", "an", "Order", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/types.go#L346-L389
30,163
bitfinexcom/bitfinex-api-go
v2/types.go
NewOrderSnapshotFromRaw
func NewOrderSnapshotFromRaw(raw []interface{}) (s *OrderSnapshot, err error) { if len(raw) == 0 { return } os := make([]*Order, 0) switch raw[0].(type) { case []interface{}: for _, v := range raw { if l, ok := v.([]interface{}); ok { o, err := NewOrderFromRaw(l) if err != nil { return s, err ...
go
func NewOrderSnapshotFromRaw(raw []interface{}) (s *OrderSnapshot, err error) { if len(raw) == 0 { return } os := make([]*Order, 0) switch raw[0].(type) { case []interface{}: for _, v := range raw { if l, ok := v.([]interface{}); ok { o, err := NewOrderFromRaw(l) if err != nil { return s, err ...
[ "func", "NewOrderSnapshotFromRaw", "(", "raw", "[", "]", "interface", "{", "}", ")", "(", "s", "*", "OrderSnapshot", ",", "err", "error", ")", "{", "if", "len", "(", "raw", ")", "==", "0", "{", "return", "\n", "}", "\n\n", "os", ":=", "make", "(", ...
// OrderSnapshotFromRaw takes a raw list of values as returned from the websocket // service and tries to convert it into an OrderSnapshot.
[ "OrderSnapshotFromRaw", "takes", "a", "raw", "list", "of", "values", "as", "returned", "from", "the", "websocket", "service", "and", "tries", "to", "convert", "it", "into", "an", "OrderSnapshot", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/types.go#L393-L416
30,164
bitfinexcom/bitfinex-api-go
v2/types.go
NewTradeExecutionUpdateFromRaw
func NewTradeExecutionUpdateFromRaw(raw []interface{}) (o *TradeExecutionUpdate, err error) { if len(raw) == 4 { o = &TradeExecutionUpdate{ ID: i64ValOrZero(raw[0]), MTS: i64ValOrZero(raw[1]), ExecAmount: f64ValOrZero(raw[2]), ExecPrice: f64ValOrZero(raw[3]), } return } if len(raw) ...
go
func NewTradeExecutionUpdateFromRaw(raw []interface{}) (o *TradeExecutionUpdate, err error) { if len(raw) == 4 { o = &TradeExecutionUpdate{ ID: i64ValOrZero(raw[0]), MTS: i64ValOrZero(raw[1]), ExecAmount: f64ValOrZero(raw[2]), ExecPrice: f64ValOrZero(raw[3]), } return } if len(raw) ...
[ "func", "NewTradeExecutionUpdateFromRaw", "(", "raw", "[", "]", "interface", "{", "}", ")", "(", "o", "*", "TradeExecutionUpdate", ",", "err", "error", ")", "{", "if", "len", "(", "raw", ")", "==", "4", "{", "o", "=", "&", "TradeExecutionUpdate", "{", ...
// public trade update just looks like a trade
[ "public", "trade", "update", "just", "looks", "like", "a", "trade" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/types.go#L586-L613
30,165
bitfinexcom/bitfinex-api-go
v2/types.go
NewMarginInfoFromRaw
func NewMarginInfoFromRaw(raw []interface{}) (o interface{}, err error) { if len(raw) < 2 { return o, fmt.Errorf("data slice too short for margin info base: %#v", raw) } typ, ok := raw[0].(string) if !ok { return o, fmt.Errorf("expected margin info type in first position for margin info but got %#v", raw) } ...
go
func NewMarginInfoFromRaw(raw []interface{}) (o interface{}, err error) { if len(raw) < 2 { return o, fmt.Errorf("data slice too short for margin info base: %#v", raw) } typ, ok := raw[0].(string) if !ok { return o, fmt.Errorf("expected margin info type in first position for margin info but got %#v", raw) } ...
[ "func", "NewMarginInfoFromRaw", "(", "raw", "[", "]", "interface", "{", "}", ")", "(", "o", "interface", "{", "}", ",", "err", "error", ")", "{", "if", "len", "(", "raw", ")", "<", "2", "{", "return", "o", ",", "fmt", ".", "Errorf", "(", "\"", ...
// marginInfoFromRaw returns either a MarginInfoBase or MarginInfoUpdate, since // the Margin Info is split up into a base and per symbol parts.
[ "marginInfoFromRaw", "returns", "either", "a", "MarginInfoBase", "or", "MarginInfoUpdate", "since", "the", "Margin", "Info", "is", "split", "up", "into", "a", "base", "and", "per", "symbol", "parts", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/types.go#L768-L800
30,166
bitfinexcom/bitfinex-api-go
v2/types.go
NewLedgerFromRaw
func NewLedgerFromRaw(raw []interface{}) (o *Ledger, err error) { if len(raw) == 9 { o = &Ledger{ ID: int64(f64ValOrZero(raw[0])), Currency: sValOrEmpty(raw[1]), Nil1: f64ValOrZero(raw[2]), MTS: i64ValOrZero(raw[3]), Nil2: f64ValOrZero(raw[4]), Amount: f64ValOrZero(raw[5]), ...
go
func NewLedgerFromRaw(raw []interface{}) (o *Ledger, err error) { if len(raw) == 9 { o = &Ledger{ ID: int64(f64ValOrZero(raw[0])), Currency: sValOrEmpty(raw[1]), Nil1: f64ValOrZero(raw[2]), MTS: i64ValOrZero(raw[3]), Nil2: f64ValOrZero(raw[4]), Amount: f64ValOrZero(raw[5]), ...
[ "func", "NewLedgerFromRaw", "(", "raw", "[", "]", "interface", "{", "}", ")", "(", "o", "*", "Ledger", ",", "err", "error", ")", "{", "if", "len", "(", "raw", ")", "==", "9", "{", "o", "=", "&", "Ledger", "{", "ID", ":", "int64", "(", "f64ValOr...
// NewLedgerFromRaw takes the raw list of values as returned from the websocket // service and tries to convert it into an Ledger.
[ "NewLedgerFromRaw", "takes", "the", "raw", "list", "of", "values", "as", "returned", "from", "the", "websocket", "service", "and", "tries", "to", "convert", "it", "into", "an", "Ledger", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/types.go#L1561-L1580
30,167
bitfinexcom/bitfinex-api-go
v2/types.go
NewLedgerSnapshotFromRaw
func NewLedgerSnapshotFromRaw(raw []interface{}) (s *LedgerSnapshot, err error) { if len(raw) == 0 { return s, fmt.Errorf("data slice too short for ledgers: %#v", raw) } os := make([]*Ledger, 0) switch raw[0].(type) { case []interface{}: for _, v := range raw { if l, ok := v.([]interface{}); ok { o, er...
go
func NewLedgerSnapshotFromRaw(raw []interface{}) (s *LedgerSnapshot, err error) { if len(raw) == 0 { return s, fmt.Errorf("data slice too short for ledgers: %#v", raw) } os := make([]*Ledger, 0) switch raw[0].(type) { case []interface{}: for _, v := range raw { if l, ok := v.([]interface{}); ok { o, er...
[ "func", "NewLedgerSnapshotFromRaw", "(", "raw", "[", "]", "interface", "{", "}", ")", "(", "s", "*", "LedgerSnapshot", ",", "err", "error", ")", "{", "if", "len", "(", "raw", ")", "==", "0", "{", "return", "s", ",", "fmt", ".", "Errorf", "(", "\"",...
// LedgerSnapshotFromRaw takes a raw list of values as returned from the websocket // service and tries to convert it into an LedgerSnapshot.
[ "LedgerSnapshotFromRaw", "takes", "a", "raw", "list", "of", "values", "as", "returned", "from", "the", "websocket", "service", "and", "tries", "to", "convert", "it", "into", "an", "LedgerSnapshot", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/types.go#L1588-L1610
30,168
bitfinexcom/bitfinex-api-go
v2/rest/platform_status.go
Status
func (p *PlatformService) Status() (bool, error) { raw, err := p.Request(NewRequestWithMethod("platform/status", "GET")) if err != nil { return false, err } /* // raw is an interface type, but we only care about len & index 0 s := make([]int, len(raw)) for i, v := range raw { s[i] = v.(int) } */ ret...
go
func (p *PlatformService) Status() (bool, error) { raw, err := p.Request(NewRequestWithMethod("platform/status", "GET")) if err != nil { return false, err } /* // raw is an interface type, but we only care about len & index 0 s := make([]int, len(raw)) for i, v := range raw { s[i] = v.(int) } */ ret...
[ "func", "(", "p", "*", "PlatformService", ")", "Status", "(", ")", "(", "bool", ",", "error", ")", "{", "raw", ",", "err", ":=", "p", ".", "Request", "(", "NewRequestWithMethod", "(", "\"", "\"", ",", "\"", "\"", ")", ")", "\n\n", "if", "err", "!...
// Status indicates whether the platform is currently operative or not.
[ "Status", "indicates", "whether", "the", "platform", "is", "currently", "operative", "or", "not", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/rest/platform_status.go#L8-L22
30,169
bitfinexcom/bitfinex-api-go
v2/rest/positions.go
All
func (s *PositionService) All() (*bitfinex.PositionSnapshot, error) { req, err := s.requestFactory.NewAuthenticatedRequest("positions") if err != nil { return nil, err } raw, err := s.Request(req) if err != nil { return nil, err } os, err := bitfinex.NewPositionSnapshotFromRaw(raw) if err != nil { retur...
go
func (s *PositionService) All() (*bitfinex.PositionSnapshot, error) { req, err := s.requestFactory.NewAuthenticatedRequest("positions") if err != nil { return nil, err } raw, err := s.Request(req) if err != nil { return nil, err } os, err := bitfinex.NewPositionSnapshotFromRaw(raw) if err != nil { retur...
[ "func", "(", "s", "*", "PositionService", ")", "All", "(", ")", "(", "*", "bitfinex", ".", "PositionSnapshot", ",", "error", ")", "{", "req", ",", "err", ":=", "s", ".", "requestFactory", ".", "NewAuthenticatedRequest", "(", "\"", "\"", ")", "\n", "if"...
// All returns all positions for the authenticated account.
[ "All", "returns", "all", "positions", "for", "the", "authenticated", "account", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/rest/positions.go#L14-L31
30,170
bitfinexcom/bitfinex-api-go
v1/offers.go
New
func (s *OffersService) New(currency string, amount, rate float64, period int64, direction string) (Offer, error) { payload := map[string]interface{}{ "currency": currency, "amount": strconv.FormatFloat(amount, 'f', -1, 32), "rate": strconv.FormatFloat(rate, 'f', -1, 32), "period": strconv.FormatI...
go
func (s *OffersService) New(currency string, amount, rate float64, period int64, direction string) (Offer, error) { payload := map[string]interface{}{ "currency": currency, "amount": strconv.FormatFloat(amount, 'f', -1, 32), "rate": strconv.FormatFloat(rate, 'f', -1, 32), "period": strconv.FormatI...
[ "func", "(", "s", "*", "OffersService", ")", "New", "(", "currency", "string", ",", "amount", ",", "rate", "float64", ",", "period", "int64", ",", "direction", "string", ")", "(", "Offer", ",", "error", ")", "{", "payload", ":=", "map", "[", "string", ...
// Create new offer for LEND or LOAN a currency, use LEND or LOAN constants as direction
[ "Create", "new", "offer", "for", "LEND", "or", "LOAN", "a", "currency", "use", "LEND", "or", "LOAN", "constants", "as", "direction" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/offers.go#L30-L55
30,171
bitfinexcom/bitfinex-api-go
v2/websocket/events.go
handleEvent
func (c *Client) handleEvent(msg []byte) error { event := &eventType{} err := json.Unmarshal(msg, event) if err != nil { return err } //var e interface{} switch event.Event { case "info": i := InfoEvent{} err = json.Unmarshal(msg, &i) if err != nil { return err } if i.Code == 0 && i.Version != 0 {...
go
func (c *Client) handleEvent(msg []byte) error { event := &eventType{} err := json.Unmarshal(msg, event) if err != nil { return err } //var e interface{} switch event.Event { case "info": i := InfoEvent{} err = json.Unmarshal(msg, &i) if err != nil { return err } if i.Code == 0 && i.Version != 0 {...
[ "func", "(", "c", "*", "Client", ")", "handleEvent", "(", "msg", "[", "]", "byte", ")", "error", "{", "event", ":=", "&", "eventType", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "msg", ",", "event", ")", "\n", "if", "err", "!=", ...
// onEvent handles all the event messages and connects SubID and ChannelID.
[ "onEvent", "handles", "all", "the", "event", "messages", "and", "connects", "SubID", "and", "ChannelID", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/events.go#L104-L184
30,172
bitfinexcom/bitfinex-api-go
v1/wallet.go
Transfer
func (c *WalletService) Transfer(amount float64, currency, from, to string) ([]TransferStatus, error) { payload := map[string]interface{}{ "amount": strconv.FormatFloat(amount, 'f', -1, 32), "currency": currency, "walletfrom": from, "walletto": to, } req, err := c.client.newAuthenticatedRequest("GE...
go
func (c *WalletService) Transfer(amount float64, currency, from, to string) ([]TransferStatus, error) { payload := map[string]interface{}{ "amount": strconv.FormatFloat(amount, 'f', -1, 32), "currency": currency, "walletfrom": from, "walletto": to, } req, err := c.client.newAuthenticatedRequest("GE...
[ "func", "(", "c", "*", "WalletService", ")", "Transfer", "(", "amount", "float64", ",", "currency", ",", "from", ",", "to", "string", ")", "(", "[", "]", "TransferStatus", ",", "error", ")", "{", "payload", ":=", "map", "[", "string", "]", "interface",...
// Transfer funds between wallets
[ "Transfer", "funds", "between", "wallets" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/wallet.go#L21-L41
30,173
bitfinexcom/bitfinex-api-go
v1/wallet.go
WithdrawCrypto
func (c *WalletService) WithdrawCrypto(amount float64, currency, wallet, destinationAddress string) ([]WithdrawStatus, error) { payload := map[string]interface{}{ "amount": strconv.FormatFloat(amount, 'f', -1, 32), "walletselected": wallet, "withdraw_type": currency, "address": destinationAddr...
go
func (c *WalletService) WithdrawCrypto(amount float64, currency, wallet, destinationAddress string) ([]WithdrawStatus, error) { payload := map[string]interface{}{ "amount": strconv.FormatFloat(amount, 'f', -1, 32), "walletselected": wallet, "withdraw_type": currency, "address": destinationAddr...
[ "func", "(", "c", "*", "WalletService", ")", "WithdrawCrypto", "(", "amount", "float64", ",", "currency", ",", "wallet", ",", "destinationAddress", "string", ")", "(", "[", "]", "WithdrawStatus", ",", "error", ")", "{", "payload", ":=", "map", "[", "string...
// Withdraw a cryptocurrency to a digital wallet
[ "Withdraw", "a", "cryptocurrency", "to", "a", "digital", "wallet" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/wallet.go#L50-L71
30,174
bitfinexcom/bitfinex-api-go
v2/rest/ledgers.go
Ledgers
func (s *LedgerService) Ledgers(currency string, start int64, end int64, max int32) (*bitfinex.LedgerSnapshot, error) { if max > 500 { return nil, fmt.Errorf("Max request limit is higher then 500 : %#v", max) } req, err := s.requestFactory.NewAuthenticatedRequestWithData(path.Join("ledgers", currency, "h...
go
func (s *LedgerService) Ledgers(currency string, start int64, end int64, max int32) (*bitfinex.LedgerSnapshot, error) { if max > 500 { return nil, fmt.Errorf("Max request limit is higher then 500 : %#v", max) } req, err := s.requestFactory.NewAuthenticatedRequestWithData(path.Join("ledgers", currency, "h...
[ "func", "(", "s", "*", "LedgerService", ")", "Ledgers", "(", "currency", "string", ",", "start", "int64", ",", "end", "int64", ",", "max", "int32", ")", "(", "*", "bitfinex", ".", "LedgerSnapshot", ",", "error", ")", "{", "if", "max", ">", "500", "{"...
// All returns all ledgers for the authenticated account.
[ "All", "returns", "all", "ledgers", "for", "the", "authenticated", "account", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/rest/ledgers.go#L16-L36
30,175
bitfinexcom/bitfinex-api-go
v1/pairs.go
All
func (p *PairsService) All() ([]string, error) { req, err := p.client.newRequest("GET", "symbols", nil) if err != nil { return nil, err } var v []string _, err = p.client.do(req, &v) if err != nil { return nil, err } return v, nil }
go
func (p *PairsService) All() ([]string, error) { req, err := p.client.newRequest("GET", "symbols", nil) if err != nil { return nil, err } var v []string _, err = p.client.do(req, &v) if err != nil { return nil, err } return v, nil }
[ "func", "(", "p", "*", "PairsService", ")", "All", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "req", ",", "err", ":=", "p", ".", "client", ".", "newRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ")", "\n", "if", "err"...
// Get all Pair names as array of strings
[ "Get", "all", "Pair", "names", "as", "array", "of", "strings" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/pairs.go#L8-L22
30,176
bitfinexcom/bitfinex-api-go
v1/pairs.go
AllDetailed
func (p *PairsService) AllDetailed() ([]Pair, error) { req, err := p.client.newRequest("GET", "symbols_details", nil) if err != nil { return nil, err } var v []Pair _, err = p.client.do(req, &v) if err != nil { return nil, err } return v, nil }
go
func (p *PairsService) AllDetailed() ([]Pair, error) { req, err := p.client.newRequest("GET", "symbols_details", nil) if err != nil { return nil, err } var v []Pair _, err = p.client.do(req, &v) if err != nil { return nil, err } return v, nil }
[ "func", "(", "p", "*", "PairsService", ")", "AllDetailed", "(", ")", "(", "[", "]", "Pair", ",", "error", ")", "{", "req", ",", "err", ":=", "p", ".", "client", ".", "newRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ")", "\n", "if", ...
// Return a list of detailed pairs
[ "Return", "a", "list", "of", "detailed", "pairs" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/pairs.go#L37-L50
30,177
bitfinexcom/bitfinex-api-go
v2/websocket/orderbook.go
copySide
func (ob *Orderbook) copySide(side []*bitfinex.BookUpdate) []bitfinex.BookUpdate { ob.lock.RLock() defer ob.lock.RUnlock() var cpy []bitfinex.BookUpdate for i := 0; i < len(side); i++ { cpy = append(cpy, *side[i]) } return cpy }
go
func (ob *Orderbook) copySide(side []*bitfinex.BookUpdate) []bitfinex.BookUpdate { ob.lock.RLock() defer ob.lock.RUnlock() var cpy []bitfinex.BookUpdate for i := 0; i < len(side); i++ { cpy = append(cpy, *side[i]) } return cpy }
[ "func", "(", "ob", "*", "Orderbook", ")", "copySide", "(", "side", "[", "]", "*", "bitfinex", ".", "BookUpdate", ")", "[", "]", "bitfinex", ".", "BookUpdate", "{", "ob", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "ob", ".", "lock", ".", ...
// return a dereferenced copy of an orderbook side. This is so consumers can access // the book but not change the values that are used to generate the crc32 checksum
[ "return", "a", "dereferenced", "copy", "of", "an", "orderbook", "side", ".", "This", "is", "so", "consumers", "can", "access", "the", "book", "but", "not", "change", "the", "values", "that", "are", "used", "to", "generate", "the", "crc32", "checksum" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/websocket/orderbook.go#L21-L29
30,178
bitfinexcom/bitfinex-api-go
v1/credits.go
All
func (c *CreditsService) All() ([]Credit, error) { req, err := c.client.newAuthenticatedRequest("GET", "credits", nil) if err != nil { return nil, err } credits := make([]Credit, 0) _, err = c.client.do(req, &credits) if err != nil { return nil, err } return credits, nil }
go
func (c *CreditsService) All() ([]Credit, error) { req, err := c.client.newAuthenticatedRequest("GET", "credits", nil) if err != nil { return nil, err } credits := make([]Credit, 0) _, err = c.client.do(req, &credits) if err != nil { return nil, err } return credits, nil }
[ "func", "(", "c", "*", "CreditsService", ")", "All", "(", ")", "(", "[", "]", "Credit", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "client", ".", "newAuthenticatedRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ")", "\n", ...
// Returns an array of Credit
[ "Returns", "an", "array", "of", "Credit" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/credits.go#L18-L31
30,179
bitfinexcom/bitfinex-api-go
v1/positions.go
All
func (b *PositionsService) All() ([]Position, error) { req, err := b.client.newAuthenticatedRequest("POST", "positions", nil) if err != nil { return nil, err } var positions []Position _, err = b.client.do(req, &positions) if err != nil { return nil, err } return positions, nil }
go
func (b *PositionsService) All() ([]Position, error) { req, err := b.client.newAuthenticatedRequest("POST", "positions", nil) if err != nil { return nil, err } var positions []Position _, err = b.client.do(req, &positions) if err != nil { return nil, err } return positions, nil }
[ "func", "(", "b", "*", "PositionsService", ")", "All", "(", ")", "(", "[", "]", "Position", ",", "error", ")", "{", "req", ",", "err", ":=", "b", ".", "client", ".", "newAuthenticatedRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ")", "\...
// All - gets all positions
[ "All", "-", "gets", "all", "positions" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/positions.go#L35-L48
30,180
bitfinexcom/bitfinex-api-go
v1/positions.go
Claim
func (b *PositionsService) Claim(positionId int, amount string) (Position, error) { request := map[string]interface{}{ "position_id": positionId, "amount": amount, } req, err := b.client.newAuthenticatedRequest("POST", "position/claim", request) if err != nil { return Position{}, err } var position...
go
func (b *PositionsService) Claim(positionId int, amount string) (Position, error) { request := map[string]interface{}{ "position_id": positionId, "amount": amount, } req, err := b.client.newAuthenticatedRequest("POST", "position/claim", request) if err != nil { return Position{}, err } var position...
[ "func", "(", "b", "*", "PositionsService", ")", "Claim", "(", "positionId", "int", ",", "amount", "string", ")", "(", "Position", ",", "error", ")", "{", "request", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "positi...
// Claim a position
[ "Claim", "a", "position" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/positions.go#L51-L73
30,181
bitfinexcom/bitfinex-api-go
v2/rest/orders.go
OrderTrades
func (s *OrderService) OrderTrades(symbol string, orderID int64) (*bitfinex.TradeExecutionUpdateSnapshot, error) { if symbol == "" { return nil, fmt.Errorf("symbol cannot be empty") } key := fmt.Sprintf("%s:%d", symbol, orderID) req, err := s.requestFactory.NewAuthenticatedRequest(path.Join("order", key, "trades"...
go
func (s *OrderService) OrderTrades(symbol string, orderID int64) (*bitfinex.TradeExecutionUpdateSnapshot, error) { if symbol == "" { return nil, fmt.Errorf("symbol cannot be empty") } key := fmt.Sprintf("%s:%d", symbol, orderID) req, err := s.requestFactory.NewAuthenticatedRequest(path.Join("order", key, "trades"...
[ "func", "(", "s", "*", "OrderService", ")", "OrderTrades", "(", "symbol", "string", ",", "orderID", "int64", ")", "(", "*", "bitfinex", ".", "TradeExecutionUpdateSnapshot", ",", "error", ")", "{", "if", "symbol", "==", "\"", "\"", "{", "return", "nil", "...
// OrderTrades returns a set of executed trades related to an order.
[ "OrderTrades", "returns", "a", "set", "of", "executed", "trades", "related", "to", "an", "order", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v2/rest/orders.go#L79-L93
30,182
bitfinexcom/bitfinex-api-go
v1/orders.go
CancelAll
func (s *OrderService) CancelAll() error { req, err := s.client.newAuthenticatedRequest("POST", "order/cancel/all", nil) if err != nil { return err } _, err = s.client.do(req, nil) if err != nil { return err } return nil }
go
func (s *OrderService) CancelAll() error { req, err := s.client.newAuthenticatedRequest("POST", "order/cancel/all", nil) if err != nil { return err } _, err = s.client.do(req, nil) if err != nil { return err } return nil }
[ "func", "(", "s", "*", "OrderService", ")", "CancelAll", "(", ")", "error", "{", "req", ",", "err", ":=", "s", ".", "client", ".", "newAuthenticatedRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", ...
// CancelAll active orders for the authenticated account.
[ "CancelAll", "active", "orders", "for", "the", "authenticated", "account", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/orders.go#L63-L75
30,183
bitfinexcom/bitfinex-api-go
v1/orders.go
Create
func (s *OrderService) Create(symbol string, amount float64, price float64, orderType string) (*Order, error) { var side string if amount < 0 { amount = math.Abs(amount) side = "sell" } else { side = "buy" } payload := map[string]interface{}{ "symbol": symbol, "amount": strconv.FormatFloat(amount, '...
go
func (s *OrderService) Create(symbol string, amount float64, price float64, orderType string) (*Order, error) { var side string if amount < 0 { amount = math.Abs(amount) side = "sell" } else { side = "buy" } payload := map[string]interface{}{ "symbol": symbol, "amount": strconv.FormatFloat(amount, '...
[ "func", "(", "s", "*", "OrderService", ")", "Create", "(", "symbol", "string", ",", "amount", "float64", ",", "price", "float64", ",", "orderType", "string", ")", "(", "*", "Order", ",", "error", ")", "{", "var", "side", "string", "\n", "if", "amount",...
// Create a new order.
[ "Create", "a", "new", "order", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/orders.go#L78-L108
30,184
bitfinexcom/bitfinex-api-go
v1/orders.go
Cancel
func (s *OrderService) Cancel(orderID int64) error { payload := map[string]interface{}{ "order_id": orderID, } req, err := s.client.newAuthenticatedRequest("POST", "order/cancel", payload) if err != nil { return err } _, err = s.client.do(req, nil) if err != nil { return err } return nil }
go
func (s *OrderService) Cancel(orderID int64) error { payload := map[string]interface{}{ "order_id": orderID, } req, err := s.client.newAuthenticatedRequest("POST", "order/cancel", payload) if err != nil { return err } _, err = s.client.do(req, nil) if err != nil { return err } return nil }
[ "func", "(", "s", "*", "OrderService", ")", "Cancel", "(", "orderID", "int64", ")", "error", "{", "payload", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "orderID", ",", "}", "\n\n", "req", ",", "err", ":=", "s", ...
// Cancel the order with id `orderID`.
[ "Cancel", "the", "order", "with", "id", "orderID", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/orders.go#L111-L127
30,185
bitfinexcom/bitfinex-api-go
v1/orders.go
CreateMulti
func (s *OrderService) CreateMulti(orders []SubmitOrder) (MultipleOrderResponse, error) { ordersMap := make([]interface{}, 0) for _, order := range orders { var side string if order.Amount < 0 { order.Amount = math.Abs(order.Amount) side = "sell" } else { side = "buy" } ordersMap = append(ordersMap...
go
func (s *OrderService) CreateMulti(orders []SubmitOrder) (MultipleOrderResponse, error) { ordersMap := make([]interface{}, 0) for _, order := range orders { var side string if order.Amount < 0 { order.Amount = math.Abs(order.Amount) side = "sell" } else { side = "buy" } ordersMap = append(ordersMap...
[ "func", "(", "s", "*", "OrderService", ")", "CreateMulti", "(", "orders", "[", "]", "SubmitOrder", ")", "(", "MultipleOrderResponse", ",", "error", ")", "{", "ordersMap", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ")", "\n", "for", ...
// CreateMulti allows batch creation of orders.
[ "CreateMulti", "allows", "batch", "creation", "of", "orders", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/orders.go#L144-L178
30,186
bitfinexcom/bitfinex-api-go
v1/orders.go
CancelMulti
func (s *OrderService) CancelMulti(orderIDS []int64) (string, error) { payload := map[string]interface{}{ "order_ids": orderIDS, } req, err := s.client.newAuthenticatedRequest("POST", "order/cancel/multi", payload) if err != nil { return "", err } response := make(map[string]string) _, err = s.client.do(r...
go
func (s *OrderService) CancelMulti(orderIDS []int64) (string, error) { payload := map[string]interface{}{ "order_ids": orderIDS, } req, err := s.client.newAuthenticatedRequest("POST", "order/cancel/multi", payload) if err != nil { return "", err } response := make(map[string]string) _, err = s.client.do(r...
[ "func", "(", "s", "*", "OrderService", ")", "CancelMulti", "(", "orderIDS", "[", "]", "int64", ")", "(", "string", ",", "error", ")", "{", "payload", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "orderIDS", ",", "}"...
// CancelMulti allows batch cancellation of orders.
[ "CancelMulti", "allows", "batch", "cancellation", "of", "orders", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/orders.go#L181-L196
30,187
bitfinexcom/bitfinex-api-go
v1/orders.go
Replace
func (s *OrderService) Replace(orderID int64, useRemaining bool, newOrder SubmitOrder) (Order, error) { var side string if newOrder.Amount < 0 { newOrder.Amount = math.Abs(newOrder.Amount) side = "sell" } else { side = "buy" } payload := map[string]interface{}{ "order_id": strconv.FormatInt(orderID, ...
go
func (s *OrderService) Replace(orderID int64, useRemaining bool, newOrder SubmitOrder) (Order, error) { var side string if newOrder.Amount < 0 { newOrder.Amount = math.Abs(newOrder.Amount) side = "sell" } else { side = "buy" } payload := map[string]interface{}{ "order_id": strconv.FormatInt(orderID, ...
[ "func", "(", "s", "*", "OrderService", ")", "Replace", "(", "orderID", "int64", ",", "useRemaining", "bool", ",", "newOrder", "SubmitOrder", ")", "(", "Order", ",", "error", ")", "{", "var", "side", "string", "\n", "if", "newOrder", ".", "Amount", "<", ...
// Replace an Order
[ "Replace", "an", "Order" ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/orders.go#L199-L231
30,188
bitfinexcom/bitfinex-api-go
v1/orders.go
Status
func (s *OrderService) Status(orderID int64) (Order, error) { payload := map[string]interface{}{ "order_id": orderID, } req, err := s.client.newAuthenticatedRequest("POST", "order/status", payload) if err != nil { return Order{}, err } order := new(Order) _, err = s.client.do(req, order) if err != nil {...
go
func (s *OrderService) Status(orderID int64) (Order, error) { payload := map[string]interface{}{ "order_id": orderID, } req, err := s.client.newAuthenticatedRequest("POST", "order/status", payload) if err != nil { return Order{}, err } order := new(Order) _, err = s.client.do(req, order) if err != nil {...
[ "func", "(", "s", "*", "OrderService", ")", "Status", "(", "orderID", "int64", ")", "(", "Order", ",", "error", ")", "{", "payload", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "orderID", ",", "}", "\n\n", "req", ...
// Status retrieves the given order from the API.
[ "Status", "retrieves", "the", "given", "order", "from", "the", "API", "." ]
c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b
https://github.com/bitfinexcom/bitfinex-api-go/blob/c16c61b288fbf09bfe1b22ee0a0e66b83f6c326b/v1/orders.go#L234-L253
30,189
firstrow/tcp_server
tcp_server.go
listen
func (c *Client) listen() { c.Server.onNewClientCallback(c) reader := bufio.NewReader(c.conn) for { message, err := reader.ReadString('\n') if err != nil { c.conn.Close() c.Server.onClientConnectionClosed(c, err) return } c.Server.onNewMessage(c, message) } }
go
func (c *Client) listen() { c.Server.onNewClientCallback(c) reader := bufio.NewReader(c.conn) for { message, err := reader.ReadString('\n') if err != nil { c.conn.Close() c.Server.onClientConnectionClosed(c, err) return } c.Server.onNewMessage(c, message) } }
[ "func", "(", "c", "*", "Client", ")", "listen", "(", ")", "{", "c", ".", "Server", ".", "onNewClientCallback", "(", "c", ")", "\n", "reader", ":=", "bufio", ".", "NewReader", "(", "c", ".", "conn", ")", "\n", "for", "{", "message", ",", "err", ":...
// Read client data from channel
[ "Read", "client", "data", "from", "channel" ]
b7a05ff2879d47e69dadf22f9149a86544d7efeb
https://github.com/firstrow/tcp_server/blob/b7a05ff2879d47e69dadf22f9149a86544d7efeb/tcp_server.go#L26-L38
30,190
firstrow/tcp_server
tcp_server.go
Send
func (c *Client) Send(message string) error { _, err := c.conn.Write([]byte(message)) return err }
go
func (c *Client) Send(message string) error { _, err := c.conn.Write([]byte(message)) return err }
[ "func", "(", "c", "*", "Client", ")", "Send", "(", "message", "string", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "conn", ".", "Write", "(", "[", "]", "byte", "(", "message", ")", ")", "\n", "return", "err", "\n", "}" ]
// Send text message to client
[ "Send", "text", "message", "to", "client" ]
b7a05ff2879d47e69dadf22f9149a86544d7efeb
https://github.com/firstrow/tcp_server/blob/b7a05ff2879d47e69dadf22f9149a86544d7efeb/tcp_server.go#L41-L44
30,191
firstrow/tcp_server
tcp_server.go
SendBytes
func (c *Client) SendBytes(b []byte) error { _, err := c.conn.Write(b) return err }
go
func (c *Client) SendBytes(b []byte) error { _, err := c.conn.Write(b) return err }
[ "func", "(", "c", "*", "Client", ")", "SendBytes", "(", "b", "[", "]", "byte", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "conn", ".", "Write", "(", "b", ")", "\n", "return", "err", "\n", "}" ]
// Send bytes to client
[ "Send", "bytes", "to", "client" ]
b7a05ff2879d47e69dadf22f9149a86544d7efeb
https://github.com/firstrow/tcp_server/blob/b7a05ff2879d47e69dadf22f9149a86544d7efeb/tcp_server.go#L47-L50
30,192
firstrow/tcp_server
tcp_server.go
OnClientConnectionClosed
func (s *server) OnClientConnectionClosed(callback func(c *Client, err error)) { s.onClientConnectionClosed = callback }
go
func (s *server) OnClientConnectionClosed(callback func(c *Client, err error)) { s.onClientConnectionClosed = callback }
[ "func", "(", "s", "*", "server", ")", "OnClientConnectionClosed", "(", "callback", "func", "(", "c", "*", "Client", ",", "err", "error", ")", ")", "{", "s", ".", "onClientConnectionClosed", "=", "callback", "\n", "}" ]
// Called right after connection closed
[ "Called", "right", "after", "connection", "closed" ]
b7a05ff2879d47e69dadf22f9149a86544d7efeb
https://github.com/firstrow/tcp_server/blob/b7a05ff2879d47e69dadf22f9149a86544d7efeb/tcp_server.go#L66-L68
30,193
firstrow/tcp_server
tcp_server.go
OnNewMessage
func (s *server) OnNewMessage(callback func(c *Client, message string)) { s.onNewMessage = callback }
go
func (s *server) OnNewMessage(callback func(c *Client, message string)) { s.onNewMessage = callback }
[ "func", "(", "s", "*", "server", ")", "OnNewMessage", "(", "callback", "func", "(", "c", "*", "Client", ",", "message", "string", ")", ")", "{", "s", ".", "onNewMessage", "=", "callback", "\n", "}" ]
// Called when Client receives new message
[ "Called", "when", "Client", "receives", "new", "message" ]
b7a05ff2879d47e69dadf22f9149a86544d7efeb
https://github.com/firstrow/tcp_server/blob/b7a05ff2879d47e69dadf22f9149a86544d7efeb/tcp_server.go#L71-L73
30,194
firstrow/tcp_server
tcp_server.go
Listen
func (s *server) Listen() { var listener net.Listener var err error if s.config == nil { listener, err = net.Listen("tcp", s.address) } else { listener, err = tls.Listen("tcp", s.address, s.config) } if err != nil { log.Fatal("Error starting TCP server.") } defer listener.Close() for { conn, _ := list...
go
func (s *server) Listen() { var listener net.Listener var err error if s.config == nil { listener, err = net.Listen("tcp", s.address) } else { listener, err = tls.Listen("tcp", s.address, s.config) } if err != nil { log.Fatal("Error starting TCP server.") } defer listener.Close() for { conn, _ := list...
[ "func", "(", "s", "*", "server", ")", "Listen", "(", ")", "{", "var", "listener", "net", ".", "Listener", "\n", "var", "err", "error", "\n", "if", "s", ".", "config", "==", "nil", "{", "listener", ",", "err", "=", "net", ".", "Listen", "(", "\"",...
// Listen starts network server
[ "Listen", "starts", "network", "server" ]
b7a05ff2879d47e69dadf22f9149a86544d7efeb
https://github.com/firstrow/tcp_server/blob/b7a05ff2879d47e69dadf22f9149a86544d7efeb/tcp_server.go#L76-L97
30,195
firstrow/tcp_server
tcp_server.go
New
func New(address string) *server { log.Println("Creating server with address", address) server := &server{ address: address, config: nil, } server.OnNewClient(func(c *Client) {}) server.OnNewMessage(func(c *Client, message string) {}) server.OnClientConnectionClosed(func(c *Client, err error) {}) return s...
go
func New(address string) *server { log.Println("Creating server with address", address) server := &server{ address: address, config: nil, } server.OnNewClient(func(c *Client) {}) server.OnNewMessage(func(c *Client, message string) {}) server.OnClientConnectionClosed(func(c *Client, err error) {}) return s...
[ "func", "New", "(", "address", "string", ")", "*", "server", "{", "log", ".", "Println", "(", "\"", "\"", ",", "address", ")", "\n", "server", ":=", "&", "server", "{", "address", ":", "address", ",", "config", ":", "nil", ",", "}", "\n\n", "server...
// Creates new tcp server instance
[ "Creates", "new", "tcp", "server", "instance" ]
b7a05ff2879d47e69dadf22f9149a86544d7efeb
https://github.com/firstrow/tcp_server/blob/b7a05ff2879d47e69dadf22f9149a86544d7efeb/tcp_server.go#L100-L112
30,196
rethinkdb/rethinkdb-go
cursor.go
Profile
func (c *Cursor) Profile() interface{} { if c == nil { return nil } c.mu.RLock() defer c.mu.RUnlock() return c.profile }
go
func (c *Cursor) Profile() interface{} { if c == nil { return nil } c.mu.RLock() defer c.mu.RUnlock() return c.profile }
[ "func", "(", "c", "*", "Cursor", ")", "Profile", "(", ")", "interface", "{", "}", "{", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "RUnlock", "("...
// Profile returns the information returned from the query profiler.
[ "Profile", "returns", "the", "information", "returned", "from", "the", "query", "profiler", "." ]
04a849766900ad9c936ba78770186640e3bede20
https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L86-L95
30,197
rethinkdb/rethinkdb-go
cursor.go
Close
func (c *Cursor) Close() error { if c == nil { return errNilCursor } c.mu.Lock() defer c.mu.Unlock() var err error // If cursor is already closed return immediately closed := c.closed if closed { return nil } // Get connection and check its valid, don't need to lock as this is only // set when the cu...
go
func (c *Cursor) Close() error { if c == nil { return errNilCursor } c.mu.Lock() defer c.mu.Unlock() var err error // If cursor is already closed return immediately closed := c.closed if closed { return nil } // Get connection and check its valid, don't need to lock as this is only // set when the cu...
[ "func", "(", "c", "*", "Cursor", ")", "Close", "(", ")", "error", "{", "if", "c", "==", "nil", "{", "return", "errNilCursor", "\n", "}", "\n\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\...
// Close closes the cursor, preventing further enumeration. If the end is // encountered, the cursor is closed automatically. Close is idempotent.
[ "Close", "closes", "the", "cursor", "preventing", "further", "enumeration", ".", "If", "the", "end", "is", "encountered", "the", "cursor", "is", "closed", "automatically", ".", "Close", "is", "idempotent", "." ]
04a849766900ad9c936ba78770186640e3bede20
https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L124-L171
30,198
rethinkdb/rethinkdb-go
cursor.go
Next
func (c *Cursor) Next(dest interface{}) bool { if c == nil { return false } c.mu.Lock() if c.closed { c.mu.Unlock() return false } hasMore, err := c.nextLocked(dest, true) if c.handleErrorLocked(err) != nil { c.mu.Unlock() c.Close() return false } c.mu.Unlock() if !hasMore { c.Close() } re...
go
func (c *Cursor) Next(dest interface{}) bool { if c == nil { return false } c.mu.Lock() if c.closed { c.mu.Unlock() return false } hasMore, err := c.nextLocked(dest, true) if c.handleErrorLocked(err) != nil { c.mu.Unlock() c.Close() return false } c.mu.Unlock() if !hasMore { c.Close() } re...
[ "func", "(", "c", "*", "Cursor", ")", "Next", "(", "dest", "interface", "{", "}", ")", "bool", "{", "if", "c", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "c", ".", "closed", "{",...
// Next retrieves the next document from the result set, blocking if necessary. // This method will also automatically retrieve another batch of documents from // the server when the current one is exhausted, or before that in background // if possible. // // Next returns true if a document was successfully unmarshalle...
[ "Next", "retrieves", "the", "next", "document", "from", "the", "result", "set", "blocking", "if", "necessary", ".", "This", "method", "will", "also", "automatically", "retrieve", "another", "batch", "of", "documents", "from", "the", "server", "when", "the", "c...
04a849766900ad9c936ba78770186640e3bede20
https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L185-L209
30,199
rethinkdb/rethinkdb-go
cursor.go
Skip
func (c *Cursor) Skip() { if c == nil { return } c.mu.Lock() defer c.mu.Unlock() c.pendingSkips++ }
go
func (c *Cursor) Skip() { if c == nil { return } c.mu.Lock() defer c.mu.Unlock() c.pendingSkips++ }
[ "func", "(", "c", "*", "Cursor", ")", "Skip", "(", ")", "{", "if", "c", "==", "nil", "{", "return", "\n", "}", "\n\n", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "c", ".", "pendingSk...
// Skip progresses the cursor by one record. It is useful after a successful // Peek to avoid duplicate decoding work.
[ "Skip", "progresses", "the", "cursor", "by", "one", "record", ".", "It", "is", "useful", "after", "a", "successful", "Peek", "to", "avoid", "duplicate", "decoding", "work", "." ]
04a849766900ad9c936ba78770186640e3bede20
https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L288-L296