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
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
151,900
ory/fosite
internal/access_request.go
NewMockAccessRequester
func NewMockAccessRequester(ctrl *gomock.Controller) *MockAccessRequester { mock := &MockAccessRequester{ctrl: ctrl} mock.recorder = &MockAccessRequesterMockRecorder{mock} return mock }
go
func NewMockAccessRequester(ctrl *gomock.Controller) *MockAccessRequester { mock := &MockAccessRequester{ctrl: ctrl} mock.recorder = &MockAccessRequesterMockRecorder{mock} return mock }
[ "func", "NewMockAccessRequester", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockAccessRequester", "{", "mock", ":=", "&", "MockAccessRequester", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockAccessRequesterMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockAccessRequester creates a new mock instance
[ "NewMockAccessRequester", "creates", "a", "new", "mock", "instance" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_request.go#L29-L33
151,901
ory/fosite
internal/access_request.go
GetGrantTypes
func (mr *MockAccessRequesterMockRecorder) GetGrantTypes() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGrantTypes", reflect.TypeOf((*MockAccessRequester)(nil).GetGrantTypes)) }
go
func (mr *MockAccessRequesterMockRecorder) GetGrantTypes() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGrantTypes", reflect.TypeOf((*MockAccessRequester)(nil).GetGrantTypes)) }
[ "func", "(", "mr", "*", "MockAccessRequesterMockRecorder", ")", "GetGrantTypes", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAccessRequester", ")", "(", "nil", ")", ".", "GetGrantTypes", ")", ")", "\n", "}" ]
// GetGrantTypes indicates an expected call of GetGrantTypes
[ "GetGrantTypes", "indicates", "an", "expected", "call", "of", "GetGrantTypes" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_request.go#L70-L72
151,902
ory/fosite
internal/access_request.go
GetGrantedAudience
func (m *MockAccessRequester) GetGrantedAudience() fosite.Arguments { ret := m.ctrl.Call(m, "GetGrantedAudience") ret0, _ := ret[0].(fosite.Arguments) return ret0 }
go
func (m *MockAccessRequester) GetGrantedAudience() fosite.Arguments { ret := m.ctrl.Call(m, "GetGrantedAudience") ret0, _ := ret[0].(fosite.Arguments) return ret0 }
[ "func", "(", "m", "*", "MockAccessRequester", ")", "GetGrantedAudience", "(", ")", "fosite", ".", "Arguments", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "fosite", ".", "Arguments", ")", "\n", "return", "ret0", "\n", "}" ]
// GetGrantedAudience mocks base method
[ "GetGrantedAudience", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_request.go#L75-L79
151,903
ory/fosite
internal/access_request.go
GetRequestedAt
func (m *MockAccessRequester) GetRequestedAt() time.Time { ret := m.ctrl.Call(m, "GetRequestedAt") ret0, _ := ret[0].(time.Time) return ret0 }
go
func (m *MockAccessRequester) GetRequestedAt() time.Time { ret := m.ctrl.Call(m, "GetRequestedAt") ret0, _ := ret[0].(time.Time) return ret0 }
[ "func", "(", "m", "*", "MockAccessRequester", ")", "GetRequestedAt", "(", ")", "time", ".", "Time", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "time", ".", "Time", ")", "\n", "return", "ret0", "\n", "}" ]
// GetRequestedAt mocks base method
[ "GetRequestedAt", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_request.go#L123-L127
151,904
ory/fosite
internal/access_request.go
SetSession
func (mr *MockAccessRequesterMockRecorder) SetSession(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSession", reflect.TypeOf((*MockAccessRequester)(nil).SetSession), arg0) }
go
func (mr *MockAccessRequesterMockRecorder) SetSession(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSession", reflect.TypeOf((*MockAccessRequester)(nil).SetSession), arg0) }
[ "func", "(", "mr", "*", "MockAccessRequesterMockRecorder", ")", "SetSession", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAccessRequester", ")", "(", "nil", ")", ".", "SetSession", ")", ",", "arg0", ")", "\n", "}" ]
// SetSession indicates an expected call of SetSession
[ "SetSession", "indicates", "an", "expected", "call", "of", "SetSession" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_request.go#L248-L250
151,905
ory/fosite
helper.go
StringInSlice
func StringInSlice(needle string, haystack []string) bool { for _, b := range haystack { if strings.ToLower(b) == strings.ToLower(needle) { return true } } return false }
go
func StringInSlice(needle string, haystack []string) bool { for _, b := range haystack { if strings.ToLower(b) == strings.ToLower(needle) { return true } } return false }
[ "func", "StringInSlice", "(", "needle", "string", ",", "haystack", "[", "]", "string", ")", "bool", "{", "for", "_", ",", "b", ":=", "range", "haystack", "{", "if", "strings", ".", "ToLower", "(", "b", ")", "==", "strings", ".", "ToLower", "(", "needle", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// StringInSlice returns true if needle exists in haystack
[ "StringInSlice", "returns", "true", "if", "needle", "exists", "in", "haystack" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/helper.go#L29-L36
151,906
ory/fosite
internal/openid_id_token_storage.go
NewMockOpenIDConnectRequestStorage
func NewMockOpenIDConnectRequestStorage(ctrl *gomock.Controller) *MockOpenIDConnectRequestStorage { mock := &MockOpenIDConnectRequestStorage{ctrl: ctrl} mock.recorder = &MockOpenIDConnectRequestStorageMockRecorder{mock} return mock }
go
func NewMockOpenIDConnectRequestStorage(ctrl *gomock.Controller) *MockOpenIDConnectRequestStorage { mock := &MockOpenIDConnectRequestStorage{ctrl: ctrl} mock.recorder = &MockOpenIDConnectRequestStorageMockRecorder{mock} return mock }
[ "func", "NewMockOpenIDConnectRequestStorage", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockOpenIDConnectRequestStorage", "{", "mock", ":=", "&", "MockOpenIDConnectRequestStorage", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockOpenIDConnectRequestStorageMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockOpenIDConnectRequestStorage creates a new mock instance
[ "NewMockOpenIDConnectRequestStorage", "creates", "a", "new", "mock", "instance" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/openid_id_token_storage.go#L28-L32
151,907
ory/fosite
internal/openid_id_token_storage.go
CreateOpenIDConnectSession
func (mr *MockOpenIDConnectRequestStorageMockRecorder) CreateOpenIDConnectSession(arg0, arg1, arg2 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOpenIDConnectSession", reflect.TypeOf((*MockOpenIDConnectRequestStorage)(nil).CreateOpenIDConnectSession), arg0, arg1, arg2) }
go
func (mr *MockOpenIDConnectRequestStorageMockRecorder) CreateOpenIDConnectSession(arg0, arg1, arg2 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOpenIDConnectSession", reflect.TypeOf((*MockOpenIDConnectRequestStorage)(nil).CreateOpenIDConnectSession), arg0, arg1, arg2) }
[ "func", "(", "mr", "*", "MockOpenIDConnectRequestStorageMockRecorder", ")", "CreateOpenIDConnectSession", "(", "arg0", ",", "arg1", ",", "arg2", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockOpenIDConnectRequestStorage", ")", "(", "nil", ")", ".", "CreateOpenIDConnectSession", ")", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "}" ]
// CreateOpenIDConnectSession indicates an expected call of CreateOpenIDConnectSession
[ "CreateOpenIDConnectSession", "indicates", "an", "expected", "call", "of", "CreateOpenIDConnectSession" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/openid_id_token_storage.go#L47-L49
151,908
ory/fosite
internal/openid_id_token_storage.go
DeleteOpenIDConnectSession
func (m *MockOpenIDConnectRequestStorage) DeleteOpenIDConnectSession(arg0 context.Context, arg1 string) error { ret := m.ctrl.Call(m, "DeleteOpenIDConnectSession", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockOpenIDConnectRequestStorage) DeleteOpenIDConnectSession(arg0 context.Context, arg1 string) error { ret := m.ctrl.Call(m, "DeleteOpenIDConnectSession", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockOpenIDConnectRequestStorage", ")", "DeleteOpenIDConnectSession", "(", "arg0", "context", ".", "Context", ",", "arg1", "string", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// DeleteOpenIDConnectSession mocks base method
[ "DeleteOpenIDConnectSession", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/openid_id_token_storage.go#L52-L56
151,909
ory/fosite
internal/openid_id_token_storage.go
GetOpenIDConnectSession
func (m *MockOpenIDConnectRequestStorage) GetOpenIDConnectSession(arg0 context.Context, arg1 string, arg2 fosite.Requester) (fosite.Requester, error) { ret := m.ctrl.Call(m, "GetOpenIDConnectSession", arg0, arg1, arg2) ret0, _ := ret[0].(fosite.Requester) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockOpenIDConnectRequestStorage) GetOpenIDConnectSession(arg0 context.Context, arg1 string, arg2 fosite.Requester) (fosite.Requester, error) { ret := m.ctrl.Call(m, "GetOpenIDConnectSession", arg0, arg1, arg2) ret0, _ := ret[0].(fosite.Requester) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockOpenIDConnectRequestStorage", ")", "GetOpenIDConnectSession", "(", "arg0", "context", ".", "Context", ",", "arg1", "string", ",", "arg2", "fosite", ".", "Requester", ")", "(", "fosite", ".", "Requester", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "fosite", ".", "Requester", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// GetOpenIDConnectSession mocks base method
[ "GetOpenIDConnectSession", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/openid_id_token_storage.go#L64-L69
151,910
ory/fosite
internal/access_response.go
NewMockAccessResponder
func NewMockAccessResponder(ctrl *gomock.Controller) *MockAccessResponder { mock := &MockAccessResponder{ctrl: ctrl} mock.recorder = &MockAccessResponderMockRecorder{mock} return mock }
go
func NewMockAccessResponder(ctrl *gomock.Controller) *MockAccessResponder { mock := &MockAccessResponder{ctrl: ctrl} mock.recorder = &MockAccessResponderMockRecorder{mock} return mock }
[ "func", "NewMockAccessResponder", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockAccessResponder", "{", "mock", ":=", "&", "MockAccessResponder", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockAccessResponderMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockAccessResponder creates a new mock instance
[ "NewMockAccessResponder", "creates", "a", "new", "mock", "instance" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L28-L32
151,911
ory/fosite
internal/access_response.go
GetAccessToken
func (m *MockAccessResponder) GetAccessToken() string { ret := m.ctrl.Call(m, "GetAccessToken") ret0, _ := ret[0].(string) return ret0 }
go
func (m *MockAccessResponder) GetAccessToken() string { ret := m.ctrl.Call(m, "GetAccessToken") ret0, _ := ret[0].(string) return ret0 }
[ "func", "(", "m", "*", "MockAccessResponder", ")", "GetAccessToken", "(", ")", "string", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "string", ")", "\n", "return", "ret0", "\n", "}" ]
// GetAccessToken mocks base method
[ "GetAccessToken", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L40-L44
151,912
ory/fosite
internal/access_response.go
GetExtra
func (m *MockAccessResponder) GetExtra(arg0 string) interface{} { ret := m.ctrl.Call(m, "GetExtra", arg0) ret0, _ := ret[0].(interface{}) return ret0 }
go
func (m *MockAccessResponder) GetExtra(arg0 string) interface{} { ret := m.ctrl.Call(m, "GetExtra", arg0) ret0, _ := ret[0].(interface{}) return ret0 }
[ "func", "(", "m", "*", "MockAccessResponder", ")", "GetExtra", "(", "arg0", "string", ")", "interface", "{", "}", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "interface", "{", "}", ")", "\n", "return", "ret0", "\n", "}" ]
// GetExtra mocks base method
[ "GetExtra", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L52-L56
151,913
ory/fosite
internal/access_response.go
GetExtra
func (mr *MockAccessResponderMockRecorder) GetExtra(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExtra", reflect.TypeOf((*MockAccessResponder)(nil).GetExtra), arg0) }
go
func (mr *MockAccessResponderMockRecorder) GetExtra(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExtra", reflect.TypeOf((*MockAccessResponder)(nil).GetExtra), arg0) }
[ "func", "(", "mr", "*", "MockAccessResponderMockRecorder", ")", "GetExtra", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAccessResponder", ")", "(", "nil", ")", ".", "GetExtra", ")", ",", "arg0", ")", "\n", "}" ]
// GetExtra indicates an expected call of GetExtra
[ "GetExtra", "indicates", "an", "expected", "call", "of", "GetExtra" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L59-L61
151,914
ory/fosite
internal/access_response.go
SetAccessToken
func (m *MockAccessResponder) SetAccessToken(arg0 string) { m.ctrl.Call(m, "SetAccessToken", arg0) }
go
func (m *MockAccessResponder) SetAccessToken(arg0 string) { m.ctrl.Call(m, "SetAccessToken", arg0) }
[ "func", "(", "m", "*", "MockAccessResponder", ")", "SetAccessToken", "(", "arg0", "string", ")", "{", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "}" ]
// SetAccessToken mocks base method
[ "SetAccessToken", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L76-L78
151,915
ory/fosite
internal/access_response.go
SetExpiresIn
func (m *MockAccessResponder) SetExpiresIn(arg0 time.Duration) { m.ctrl.Call(m, "SetExpiresIn", arg0) }
go
func (m *MockAccessResponder) SetExpiresIn(arg0 time.Duration) { m.ctrl.Call(m, "SetExpiresIn", arg0) }
[ "func", "(", "m", "*", "MockAccessResponder", ")", "SetExpiresIn", "(", "arg0", "time", ".", "Duration", ")", "{", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "}" ]
// SetExpiresIn mocks base method
[ "SetExpiresIn", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L86-L88
151,916
ory/fosite
internal/access_response.go
SetExtra
func (m *MockAccessResponder) SetExtra(arg0 string, arg1 interface{}) { m.ctrl.Call(m, "SetExtra", arg0, arg1) }
go
func (m *MockAccessResponder) SetExtra(arg0 string, arg1 interface{}) { m.ctrl.Call(m, "SetExtra", arg0, arg1) }
[ "func", "(", "m", "*", "MockAccessResponder", ")", "SetExtra", "(", "arg0", "string", ",", "arg1", "interface", "{", "}", ")", "{", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "}" ]
// SetExtra mocks base method
[ "SetExtra", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L96-L98
151,917
ory/fosite
internal/access_response.go
SetScopes
func (m *MockAccessResponder) SetScopes(arg0 fosite.Arguments) { m.ctrl.Call(m, "SetScopes", arg0) }
go
func (m *MockAccessResponder) SetScopes(arg0 fosite.Arguments) { m.ctrl.Call(m, "SetScopes", arg0) }
[ "func", "(", "m", "*", "MockAccessResponder", ")", "SetScopes", "(", "arg0", "fosite", ".", "Arguments", ")", "{", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "}" ]
// SetScopes mocks base method
[ "SetScopes", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L106-L108
151,918
ory/fosite
internal/access_response.go
SetTokenType
func (m *MockAccessResponder) SetTokenType(arg0 string) { m.ctrl.Call(m, "SetTokenType", arg0) }
go
func (m *MockAccessResponder) SetTokenType(arg0 string) { m.ctrl.Call(m, "SetTokenType", arg0) }
[ "func", "(", "m", "*", "MockAccessResponder", ")", "SetTokenType", "(", "arg0", "string", ")", "{", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "}" ]
// SetTokenType mocks base method
[ "SetTokenType", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L116-L118
151,919
ory/fosite
internal/access_response.go
ToMap
func (mr *MockAccessResponderMockRecorder) ToMap() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToMap", reflect.TypeOf((*MockAccessResponder)(nil).ToMap)) }
go
func (mr *MockAccessResponderMockRecorder) ToMap() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToMap", reflect.TypeOf((*MockAccessResponder)(nil).ToMap)) }
[ "func", "(", "mr", "*", "MockAccessResponderMockRecorder", ")", "ToMap", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAccessResponder", ")", "(", "nil", ")", ".", "ToMap", ")", ")", "\n", "}" ]
// ToMap indicates an expected call of ToMap
[ "ToMap", "indicates", "an", "expected", "call", "of", "ToMap" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_response.go#L133-L135
151,920
ory/fosite
internal/revoke_handler.go
NewMockRevocationHandler
func NewMockRevocationHandler(ctrl *gomock.Controller) *MockRevocationHandler { mock := &MockRevocationHandler{ctrl: ctrl} mock.recorder = &MockRevocationHandlerMockRecorder{mock} return mock }
go
func NewMockRevocationHandler(ctrl *gomock.Controller) *MockRevocationHandler { mock := &MockRevocationHandler{ctrl: ctrl} mock.recorder = &MockRevocationHandlerMockRecorder{mock} return mock }
[ "func", "NewMockRevocationHandler", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockRevocationHandler", "{", "mock", ":=", "&", "MockRevocationHandler", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockRevocationHandlerMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockRevocationHandler creates a new mock instance
[ "NewMockRevocationHandler", "creates", "a", "new", "mock", "instance" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/revoke_handler.go#L28-L32
151,921
ory/fosite
internal/revoke_handler.go
RevokeToken
func (m *MockRevocationHandler) RevokeToken(arg0 context.Context, arg1 string, arg2 fosite.TokenType, arg3 fosite.Client) error { ret := m.ctrl.Call(m, "RevokeToken", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockRevocationHandler) RevokeToken(arg0 context.Context, arg1 string, arg2 fosite.TokenType, arg3 fosite.Client) error { ret := m.ctrl.Call(m, "RevokeToken", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockRevocationHandler", ")", "RevokeToken", "(", "arg0", "context", ".", "Context", ",", "arg1", "string", ",", "arg2", "fosite", ".", "TokenType", ",", "arg3", "fosite", ".", "Client", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// RevokeToken mocks base method
[ "RevokeToken", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/revoke_handler.go#L40-L44
151,922
ory/fosite
internal/revoke_handler.go
RevokeToken
func (mr *MockRevocationHandlerMockRecorder) RevokeToken(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeToken", reflect.TypeOf((*MockRevocationHandler)(nil).RevokeToken), arg0, arg1, arg2, arg3) }
go
func (mr *MockRevocationHandlerMockRecorder) RevokeToken(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeToken", reflect.TypeOf((*MockRevocationHandler)(nil).RevokeToken), arg0, arg1, arg2, arg3) }
[ "func", "(", "mr", "*", "MockRevocationHandlerMockRecorder", ")", "RevokeToken", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockRevocationHandler", ")", "(", "nil", ")", ".", "RevokeToken", ")", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ")", "\n", "}" ]
// RevokeToken indicates an expected call of RevokeToken
[ "RevokeToken", "indicates", "an", "expected", "call", "of", "RevokeToken" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/revoke_handler.go#L47-L49
151,923
ory/fosite
fosite.go
Append
func (a *AuthorizeEndpointHandlers) Append(h AuthorizeEndpointHandler) { for _, this := range *a { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *a = append(*a, h) }
go
func (a *AuthorizeEndpointHandlers) Append(h AuthorizeEndpointHandler) { for _, this := range *a { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *a = append(*a, h) }
[ "func", "(", "a", "*", "AuthorizeEndpointHandlers", ")", "Append", "(", "h", "AuthorizeEndpointHandler", ")", "{", "for", "_", ",", "this", ":=", "range", "*", "a", "{", "if", "reflect", ".", "TypeOf", "(", "this", ")", "==", "reflect", ".", "TypeOf", "(", "h", ")", "{", "return", "\n", "}", "\n", "}", "\n\n", "*", "a", "=", "append", "(", "*", "a", ",", "h", ")", "\n", "}" ]
// Append adds an AuthorizeEndpointHandler to this list. Ignores duplicates based on reflect.TypeOf.
[ "Append", "adds", "an", "AuthorizeEndpointHandler", "to", "this", "list", ".", "Ignores", "duplicates", "based", "on", "reflect", ".", "TypeOf", "." ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/fosite.go#L33-L41
151,924
ory/fosite
fosite.go
Append
func (t *TokenEndpointHandlers) Append(h TokenEndpointHandler) { for _, this := range *t { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *t = append(*t, h) }
go
func (t *TokenEndpointHandlers) Append(h TokenEndpointHandler) { for _, this := range *t { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *t = append(*t, h) }
[ "func", "(", "t", "*", "TokenEndpointHandlers", ")", "Append", "(", "h", "TokenEndpointHandler", ")", "{", "for", "_", ",", "this", ":=", "range", "*", "t", "{", "if", "reflect", ".", "TypeOf", "(", "this", ")", "==", "reflect", ".", "TypeOf", "(", "h", ")", "{", "return", "\n", "}", "\n", "}", "\n\n", "*", "t", "=", "append", "(", "*", "t", ",", "h", ")", "\n", "}" ]
// Append adds an TokenEndpointHandler to this list. Ignores duplicates based on reflect.TypeOf.
[ "Append", "adds", "an", "TokenEndpointHandler", "to", "this", "list", ".", "Ignores", "duplicates", "based", "on", "reflect", ".", "TypeOf", "." ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/fosite.go#L47-L55
151,925
ory/fosite
fosite.go
Append
func (t *TokenIntrospectionHandlers) Append(h TokenIntrospector) { for _, this := range *t { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *t = append(*t, h) }
go
func (t *TokenIntrospectionHandlers) Append(h TokenIntrospector) { for _, this := range *t { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *t = append(*t, h) }
[ "func", "(", "t", "*", "TokenIntrospectionHandlers", ")", "Append", "(", "h", "TokenIntrospector", ")", "{", "for", "_", ",", "this", ":=", "range", "*", "t", "{", "if", "reflect", ".", "TypeOf", "(", "this", ")", "==", "reflect", ".", "TypeOf", "(", "h", ")", "{", "return", "\n", "}", "\n", "}", "\n\n", "*", "t", "=", "append", "(", "*", "t", ",", "h", ")", "\n", "}" ]
// Add adds an AccessTokenValidator to this list. Ignores duplicates based on reflect.TypeOf.
[ "Add", "adds", "an", "AccessTokenValidator", "to", "this", "list", ".", "Ignores", "duplicates", "based", "on", "reflect", ".", "TypeOf", "." ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/fosite.go#L61-L69
151,926
ory/fosite
fosite.go
Append
func (t *RevocationHandlers) Append(h RevocationHandler) { for _, this := range *t { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *t = append(*t, h) }
go
func (t *RevocationHandlers) Append(h RevocationHandler) { for _, this := range *t { if reflect.TypeOf(this) == reflect.TypeOf(h) { return } } *t = append(*t, h) }
[ "func", "(", "t", "*", "RevocationHandlers", ")", "Append", "(", "h", "RevocationHandler", ")", "{", "for", "_", ",", "this", ":=", "range", "*", "t", "{", "if", "reflect", ".", "TypeOf", "(", "this", ")", "==", "reflect", ".", "TypeOf", "(", "h", ")", "{", "return", "\n", "}", "\n", "}", "\n\n", "*", "t", "=", "append", "(", "*", "t", ",", "h", ")", "\n", "}" ]
// Append adds an RevocationHandler to this list. Ignores duplicates based on reflect.TypeOf.
[ "Append", "adds", "an", "RevocationHandler", "to", "this", "list", ".", "Ignores", "duplicates", "based", "on", "reflect", ".", "TypeOf", "." ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/fosite.go#L75-L83
151,927
ory/fosite
internal/id_token_strategy.go
NewMockOpenIDConnectTokenStrategy
func NewMockOpenIDConnectTokenStrategy(ctrl *gomock.Controller) *MockOpenIDConnectTokenStrategy { mock := &MockOpenIDConnectTokenStrategy{ctrl: ctrl} mock.recorder = &MockOpenIDConnectTokenStrategyMockRecorder{mock} return mock }
go
func NewMockOpenIDConnectTokenStrategy(ctrl *gomock.Controller) *MockOpenIDConnectTokenStrategy { mock := &MockOpenIDConnectTokenStrategy{ctrl: ctrl} mock.recorder = &MockOpenIDConnectTokenStrategyMockRecorder{mock} return mock }
[ "func", "NewMockOpenIDConnectTokenStrategy", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockOpenIDConnectTokenStrategy", "{", "mock", ":=", "&", "MockOpenIDConnectTokenStrategy", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockOpenIDConnectTokenStrategyMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockOpenIDConnectTokenStrategy creates a new mock instance
[ "NewMockOpenIDConnectTokenStrategy", "creates", "a", "new", "mock", "instance" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/id_token_strategy.go#L28-L32
151,928
ory/fosite
internal/id_token_strategy.go
GenerateIDToken
func (m *MockOpenIDConnectTokenStrategy) GenerateIDToken(arg0 context.Context, arg1 fosite.Requester) (string, error) { ret := m.ctrl.Call(m, "GenerateIDToken", arg0, arg1) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockOpenIDConnectTokenStrategy) GenerateIDToken(arg0 context.Context, arg1 fosite.Requester) (string, error) { ret := m.ctrl.Call(m, "GenerateIDToken", arg0, arg1) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockOpenIDConnectTokenStrategy", ")", "GenerateIDToken", "(", "arg0", "context", ".", "Context", ",", "arg1", "fosite", ".", "Requester", ")", "(", "string", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "string", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// GenerateIDToken mocks base method
[ "GenerateIDToken", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/id_token_strategy.go#L40-L45
151,929
ory/fosite
internal/id_token_strategy.go
GenerateIDToken
func (mr *MockOpenIDConnectTokenStrategyMockRecorder) GenerateIDToken(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateIDToken", reflect.TypeOf((*MockOpenIDConnectTokenStrategy)(nil).GenerateIDToken), arg0, arg1) }
go
func (mr *MockOpenIDConnectTokenStrategyMockRecorder) GenerateIDToken(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GenerateIDToken", reflect.TypeOf((*MockOpenIDConnectTokenStrategy)(nil).GenerateIDToken), arg0, arg1) }
[ "func", "(", "mr", "*", "MockOpenIDConnectTokenStrategyMockRecorder", ")", "GenerateIDToken", "(", "arg0", ",", "arg1", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockOpenIDConnectTokenStrategy", ")", "(", "nil", ")", ".", "GenerateIDToken", ")", ",", "arg0", ",", "arg1", ")", "\n", "}" ]
// GenerateIDToken indicates an expected call of GenerateIDToken
[ "GenerateIDToken", "indicates", "an", "expected", "call", "of", "GenerateIDToken" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/id_token_strategy.go#L48-L50
151,930
ory/fosite
internal/transactional.go
NewMockTransactional
func NewMockTransactional(ctrl *gomock.Controller) *MockTransactional { mock := &MockTransactional{ctrl: ctrl} mock.recorder = &MockTransactionalMockRecorder{mock} return mock }
go
func NewMockTransactional(ctrl *gomock.Controller) *MockTransactional { mock := &MockTransactional{ctrl: ctrl} mock.recorder = &MockTransactionalMockRecorder{mock} return mock }
[ "func", "NewMockTransactional", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockTransactional", "{", "mock", ":=", "&", "MockTransactional", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockTransactionalMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockTransactional creates a new mock instance
[ "NewMockTransactional", "creates", "a", "new", "mock", "instance" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/transactional.go#L26-L30
151,931
ory/fosite
internal/transactional.go
BeginTX
func (m *MockTransactional) BeginTX(arg0 context.Context) (context.Context, error) { ret := m.ctrl.Call(m, "BeginTX", arg0) ret0, _ := ret[0].(context.Context) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockTransactional) BeginTX(arg0 context.Context) (context.Context, error) { ret := m.ctrl.Call(m, "BeginTX", arg0) ret0, _ := ret[0].(context.Context) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockTransactional", ")", "BeginTX", "(", "arg0", "context", ".", "Context", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "context", ".", "Context", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// BeginTX mocks base method
[ "BeginTX", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/transactional.go#L38-L43
151,932
ory/fosite
internal/transactional.go
Rollback
func (m *MockTransactional) Rollback(arg0 context.Context) error { ret := m.ctrl.Call(m, "Rollback", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockTransactional) Rollback(arg0 context.Context) error { ret := m.ctrl.Call(m, "Rollback", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockTransactional", ")", "Rollback", "(", "arg0", "context", ".", "Context", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// Rollback mocks base method
[ "Rollback", "mocks", "base", "method" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/transactional.go#L63-L67
151,933
ory/fosite
internal/transactional.go
Rollback
func (mr *MockTransactionalMockRecorder) Rollback(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Rollback", reflect.TypeOf((*MockTransactional)(nil).Rollback), arg0) }
go
func (mr *MockTransactionalMockRecorder) Rollback(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Rollback", reflect.TypeOf((*MockTransactional)(nil).Rollback), arg0) }
[ "func", "(", "mr", "*", "MockTransactionalMockRecorder", ")", "Rollback", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockTransactional", ")", "(", "nil", ")", ".", "Rollback", ")", ",", "arg0", ")", "\n", "}" ]
// Rollback indicates an expected call of Rollback
[ "Rollback", "indicates", "an", "expected", "call", "of", "Rollback" ]
27bbe0033273157ea449310c064675127e2550e6
https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/transactional.go#L70-L72
151,934
cskr/pubsub
pubsub.go
New
func New(capacity int) *PubSub { ps := &PubSub{make(chan cmd), capacity} go ps.start() return ps }
go
func New(capacity int) *PubSub { ps := &PubSub{make(chan cmd), capacity} go ps.start() return ps }
[ "func", "New", "(", "capacity", "int", ")", "*", "PubSub", "{", "ps", ":=", "&", "PubSub", "{", "make", "(", "chan", "cmd", ")", ",", "capacity", "}", "\n", "go", "ps", ".", "start", "(", ")", "\n", "return", "ps", "\n", "}" ]
// New creates a new PubSub and starts a goroutine for handling operations. // The capacity of the channels created by Sub and SubOnce will be as specified.
[ "New", "creates", "a", "new", "PubSub", "and", "starts", "a", "goroutine", "for", "handling", "operations", ".", "The", "capacity", "of", "the", "channels", "created", "by", "Sub", "and", "SubOnce", "will", "be", "as", "specified", "." ]
65166f5ae403cbf6dcdced31e1f8f8ad95485cb3
https://github.com/cskr/pubsub/blob/65166f5ae403cbf6dcdced31e1f8f8ad95485cb3/pubsub.go#L42-L46
151,935
cskr/pubsub
pubsub.go
AddSub
func (ps *PubSub) AddSub(ch chan interface{}, topics ...string) { ps.cmdChan <- cmd{op: sub, topics: topics, ch: ch} }
go
func (ps *PubSub) AddSub(ch chan interface{}, topics ...string) { ps.cmdChan <- cmd{op: sub, topics: topics, ch: ch} }
[ "func", "(", "ps", "*", "PubSub", ")", "AddSub", "(", "ch", "chan", "interface", "{", "}", ",", "topics", "...", "string", ")", "{", "ps", ".", "cmdChan", "<-", "cmd", "{", "op", ":", "sub", ",", "topics", ":", "topics", ",", "ch", ":", "ch", "}", "\n", "}" ]
// AddSub adds subscriptions to an existing channel.
[ "AddSub", "adds", "subscriptions", "to", "an", "existing", "channel", "." ]
65166f5ae403cbf6dcdced31e1f8f8ad95485cb3
https://github.com/cskr/pubsub/blob/65166f5ae403cbf6dcdced31e1f8f8ad95485cb3/pubsub.go#L73-L75
151,936
cskr/pubsub
pubsub.go
AddSubOnceEach
func (ps *PubSub) AddSubOnceEach(ch chan interface{}, topics ...string) { ps.cmdChan <- cmd{op: subOnceEach, topics: topics, ch: ch} }
go
func (ps *PubSub) AddSubOnceEach(ch chan interface{}, topics ...string) { ps.cmdChan <- cmd{op: subOnceEach, topics: topics, ch: ch} }
[ "func", "(", "ps", "*", "PubSub", ")", "AddSubOnceEach", "(", "ch", "chan", "interface", "{", "}", ",", "topics", "...", "string", ")", "{", "ps", ".", "cmdChan", "<-", "cmd", "{", "op", ":", "subOnceEach", ",", "topics", ":", "topics", ",", "ch", ":", "ch", "}", "\n", "}" ]
// AddSubOnceEach adds subscriptions to an existing channel with SubOnceEach // behavior.
[ "AddSubOnceEach", "adds", "subscriptions", "to", "an", "existing", "channel", "with", "SubOnceEach", "behavior", "." ]
65166f5ae403cbf6dcdced31e1f8f8ad95485cb3
https://github.com/cskr/pubsub/blob/65166f5ae403cbf6dcdced31e1f8f8ad95485cb3/pubsub.go#L79-L81
151,937
cskr/pubsub
pubsub.go
Pub
func (ps *PubSub) Pub(msg interface{}, topics ...string) { ps.cmdChan <- cmd{op: pub, topics: topics, msg: msg} }
go
func (ps *PubSub) Pub(msg interface{}, topics ...string) { ps.cmdChan <- cmd{op: pub, topics: topics, msg: msg} }
[ "func", "(", "ps", "*", "PubSub", ")", "Pub", "(", "msg", "interface", "{", "}", ",", "topics", "...", "string", ")", "{", "ps", ".", "cmdChan", "<-", "cmd", "{", "op", ":", "pub", ",", "topics", ":", "topics", ",", "msg", ":", "msg", "}", "\n", "}" ]
// Pub publishes the given message to all subscribers of // the specified topics.
[ "Pub", "publishes", "the", "given", "message", "to", "all", "subscribers", "of", "the", "specified", "topics", "." ]
65166f5ae403cbf6dcdced31e1f8f8ad95485cb3
https://github.com/cskr/pubsub/blob/65166f5ae403cbf6dcdced31e1f8f8ad95485cb3/pubsub.go#L85-L87
151,938
cskr/pubsub
pubsub.go
TryPub
func (ps *PubSub) TryPub(msg interface{}, topics ...string) { ps.cmdChan <- cmd{op: tryPub, topics: topics, msg: msg} }
go
func (ps *PubSub) TryPub(msg interface{}, topics ...string) { ps.cmdChan <- cmd{op: tryPub, topics: topics, msg: msg} }
[ "func", "(", "ps", "*", "PubSub", ")", "TryPub", "(", "msg", "interface", "{", "}", ",", "topics", "...", "string", ")", "{", "ps", ".", "cmdChan", "<-", "cmd", "{", "op", ":", "tryPub", ",", "topics", ":", "topics", ",", "msg", ":", "msg", "}", "\n", "}" ]
// TryPub publishes the given message to all subscribers of // the specified topics if the topic has buffer space.
[ "TryPub", "publishes", "the", "given", "message", "to", "all", "subscribers", "of", "the", "specified", "topics", "if", "the", "topic", "has", "buffer", "space", "." ]
65166f5ae403cbf6dcdced31e1f8f8ad95485cb3
https://github.com/cskr/pubsub/blob/65166f5ae403cbf6dcdced31e1f8f8ad95485cb3/pubsub.go#L91-L93
151,939
cskr/pubsub
pubsub.go
Unsub
func (ps *PubSub) Unsub(ch chan interface{}, topics ...string) { if len(topics) == 0 { ps.cmdChan <- cmd{op: unsubAll, ch: ch} return } ps.cmdChan <- cmd{op: unsub, topics: topics, ch: ch} }
go
func (ps *PubSub) Unsub(ch chan interface{}, topics ...string) { if len(topics) == 0 { ps.cmdChan <- cmd{op: unsubAll, ch: ch} return } ps.cmdChan <- cmd{op: unsub, topics: topics, ch: ch} }
[ "func", "(", "ps", "*", "PubSub", ")", "Unsub", "(", "ch", "chan", "interface", "{", "}", ",", "topics", "...", "string", ")", "{", "if", "len", "(", "topics", ")", "==", "0", "{", "ps", ".", "cmdChan", "<-", "cmd", "{", "op", ":", "unsubAll", ",", "ch", ":", "ch", "}", "\n", "return", "\n", "}", "\n\n", "ps", ".", "cmdChan", "<-", "cmd", "{", "op", ":", "unsub", ",", "topics", ":", "topics", ",", "ch", ":", "ch", "}", "\n", "}" ]
// Unsub unsubscribes the given channel from the specified // topics. If no topic is specified, it is unsubscribed // from all topics. // // Unsub must be called from a goroutine that is different from the subscriber. // The subscriber must consume messages from the channel until it reaches the // end. Not doing so can result in a deadlock.
[ "Unsub", "unsubscribes", "the", "given", "channel", "from", "the", "specified", "topics", ".", "If", "no", "topic", "is", "specified", "it", "is", "unsubscribed", "from", "all", "topics", ".", "Unsub", "must", "be", "called", "from", "a", "goroutine", "that", "is", "different", "from", "the", "subscriber", ".", "The", "subscriber", "must", "consume", "messages", "from", "the", "channel", "until", "it", "reaches", "the", "end", ".", "Not", "doing", "so", "can", "result", "in", "a", "deadlock", "." ]
65166f5ae403cbf6dcdced31e1f8f8ad95485cb3
https://github.com/cskr/pubsub/blob/65166f5ae403cbf6dcdced31e1f8f8ad95485cb3/pubsub.go#L102-L109
151,940
cskr/pubsub
pubsub.go
Close
func (ps *PubSub) Close(topics ...string) { ps.cmdChan <- cmd{op: closeTopic, topics: topics} }
go
func (ps *PubSub) Close(topics ...string) { ps.cmdChan <- cmd{op: closeTopic, topics: topics} }
[ "func", "(", "ps", "*", "PubSub", ")", "Close", "(", "topics", "...", "string", ")", "{", "ps", ".", "cmdChan", "<-", "cmd", "{", "op", ":", "closeTopic", ",", "topics", ":", "topics", "}", "\n", "}" ]
// Close closes all channels currently subscribed to the specified topics. // If a channel is subscribed to multiple topics, some of which is // not specified, it is not closed.
[ "Close", "closes", "all", "channels", "currently", "subscribed", "to", "the", "specified", "topics", ".", "If", "a", "channel", "is", "subscribed", "to", "multiple", "topics", "some", "of", "which", "is", "not", "specified", "it", "is", "not", "closed", "." ]
65166f5ae403cbf6dcdced31e1f8f8ad95485cb3
https://github.com/cskr/pubsub/blob/65166f5ae403cbf6dcdced31e1f8f8ad95485cb3/pubsub.go#L114-L116
151,941
gosuri/uiprogress
progress.go
New
func New() *Progress { lw := uilive.New() lw.Out = Out return &Progress{ Width: Width, Out: Out, Bars: make([]*Bar, 0), RefreshInterval: RefreshInterval, tdone: make(chan bool), lw: uilive.New(), mtx: &sync.RWMutex{}, } }
go
func New() *Progress { lw := uilive.New() lw.Out = Out return &Progress{ Width: Width, Out: Out, Bars: make([]*Bar, 0), RefreshInterval: RefreshInterval, tdone: make(chan bool), lw: uilive.New(), mtx: &sync.RWMutex{}, } }
[ "func", "New", "(", ")", "*", "Progress", "{", "lw", ":=", "uilive", ".", "New", "(", ")", "\n", "lw", ".", "Out", "=", "Out", "\n\n", "return", "&", "Progress", "{", "Width", ":", "Width", ",", "Out", ":", "Out", ",", "Bars", ":", "make", "(", "[", "]", "*", "Bar", ",", "0", ")", ",", "RefreshInterval", ":", "RefreshInterval", ",", "tdone", ":", "make", "(", "chan", "bool", ")", ",", "lw", ":", "uilive", ".", "New", "(", ")", ",", "mtx", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "}", "\n", "}" ]
// New returns a new progress bar with defaults
[ "New", "returns", "a", "new", "progress", "bar", "with", "defaults" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/progress.go#L43-L57
151,942
gosuri/uiprogress
progress.go
AddBar
func (p *Progress) AddBar(total int) *Bar { p.mtx.Lock() defer p.mtx.Unlock() bar := NewBar(total) bar.Width = p.Width p.Bars = append(p.Bars, bar) return bar }
go
func (p *Progress) AddBar(total int) *Bar { p.mtx.Lock() defer p.mtx.Unlock() bar := NewBar(total) bar.Width = p.Width p.Bars = append(p.Bars, bar) return bar }
[ "func", "(", "p", "*", "Progress", ")", "AddBar", "(", "total", "int", ")", "*", "Bar", "{", "p", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "bar", ":=", "NewBar", "(", "total", ")", "\n", "bar", ".", "Width", "=", "p", ".", "Width", "\n", "p", ".", "Bars", "=", "append", "(", "p", ".", "Bars", ",", "bar", ")", "\n", "return", "bar", "\n", "}" ]
// AddBar creates a new progress bar and adds to the container
[ "AddBar", "creates", "a", "new", "progress", "bar", "and", "adds", "to", "the", "container" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/progress.go#L94-L102
151,943
gosuri/uiprogress
progress.go
Listen
func (p *Progress) Listen() { for { p.mtx.Lock() interval := p.RefreshInterval p.mtx.Unlock() select { case <-time.After(interval): p.print() case <-p.tdone: p.print() close(p.tdone) return } } }
go
func (p *Progress) Listen() { for { p.mtx.Lock() interval := p.RefreshInterval p.mtx.Unlock() select { case <-time.After(interval): p.print() case <-p.tdone: p.print() close(p.tdone) return } } }
[ "func", "(", "p", "*", "Progress", ")", "Listen", "(", ")", "{", "for", "{", "p", ".", "mtx", ".", "Lock", "(", ")", "\n", "interval", ":=", "p", ".", "RefreshInterval", "\n", "p", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "select", "{", "case", "<-", "time", ".", "After", "(", "interval", ")", ":", "p", ".", "print", "(", ")", "\n", "case", "<-", "p", ".", "tdone", ":", "p", ".", "print", "(", ")", "\n", "close", "(", "p", ".", "tdone", ")", "\n", "return", "\n", "}", "\n", "}", "\n", "}" ]
// Listen listens for updates and renders the progress bars
[ "Listen", "listens", "for", "updates", "and", "renders", "the", "progress", "bars" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/progress.go#L105-L121
151,944
gosuri/uiprogress
bar.go
NewBar
func NewBar(total int) *Bar { return &Bar{ Total: total, Width: Width, LeftEnd: LeftEnd, RightEnd: RightEnd, Head: Head, Fill: Fill, Empty: Empty, mtx: &sync.RWMutex{}, } }
go
func NewBar(total int) *Bar { return &Bar{ Total: total, Width: Width, LeftEnd: LeftEnd, RightEnd: RightEnd, Head: Head, Fill: Fill, Empty: Empty, mtx: &sync.RWMutex{}, } }
[ "func", "NewBar", "(", "total", "int", ")", "*", "Bar", "{", "return", "&", "Bar", "{", "Total", ":", "total", ",", "Width", ":", "Width", ",", "LeftEnd", ":", "LeftEnd", ",", "RightEnd", ":", "RightEnd", ",", "Head", ":", "Head", ",", "Fill", ":", "Fill", ",", "Empty", ":", "Empty", ",", "mtx", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "}", "\n", "}" ]
// NewBar returns a new progress bar
[ "NewBar", "returns", "a", "new", "progress", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L76-L88
151,945
gosuri/uiprogress
bar.go
Set
func (b *Bar) Set(n int) error { b.mtx.Lock() defer b.mtx.Unlock() if n > b.Total { return ErrMaxCurrentReached } b.current = n return nil }
go
func (b *Bar) Set(n int) error { b.mtx.Lock() defer b.mtx.Unlock() if n > b.Total { return ErrMaxCurrentReached } b.current = n return nil }
[ "func", "(", "b", "*", "Bar", ")", "Set", "(", "n", "int", ")", "error", "{", "b", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "n", ">", "b", ".", "Total", "{", "return", "ErrMaxCurrentReached", "\n", "}", "\n", "b", ".", "current", "=", "n", "\n", "return", "nil", "\n", "}" ]
// Set the current count of the bar. It returns ErrMaxCurrentReached when trying n exceeds the total value. This is atomic operation and concurancy safe.
[ "Set", "the", "current", "count", "of", "the", "bar", ".", "It", "returns", "ErrMaxCurrentReached", "when", "trying", "n", "exceeds", "the", "total", "value", ".", "This", "is", "atomic", "operation", "and", "concurancy", "safe", "." ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L91-L100
151,946
gosuri/uiprogress
bar.go
Incr
func (b *Bar) Incr() bool { b.mtx.Lock() defer b.mtx.Unlock() n := b.current + 1 if n > b.Total { return false } var t time.Time if b.TimeStarted == t { b.TimeStarted = time.Now() } b.timeElapsed = time.Since(b.TimeStarted) b.current = n return true }
go
func (b *Bar) Incr() bool { b.mtx.Lock() defer b.mtx.Unlock() n := b.current + 1 if n > b.Total { return false } var t time.Time if b.TimeStarted == t { b.TimeStarted = time.Now() } b.timeElapsed = time.Since(b.TimeStarted) b.current = n return true }
[ "func", "(", "b", "*", "Bar", ")", "Incr", "(", ")", "bool", "{", "b", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "n", ":=", "b", ".", "current", "+", "1", "\n", "if", "n", ">", "b", ".", "Total", "{", "return", "false", "\n", "}", "\n", "var", "t", "time", ".", "Time", "\n", "if", "b", ".", "TimeStarted", "==", "t", "{", "b", ".", "TimeStarted", "=", "time", ".", "Now", "(", ")", "\n", "}", "\n", "b", ".", "timeElapsed", "=", "time", ".", "Since", "(", "b", ".", "TimeStarted", ")", "\n", "b", ".", "current", "=", "n", "\n", "return", "true", "\n", "}" ]
// Incr increments the current value by 1, time elapsed to current time and returns true. It returns false if the cursor has reached or exceeds total value.
[ "Incr", "increments", "the", "current", "value", "by", "1", "time", "elapsed", "to", "current", "time", "and", "returns", "true", ".", "It", "returns", "false", "if", "the", "cursor", "has", "reached", "or", "exceeds", "total", "value", "." ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L103-L118
151,947
gosuri/uiprogress
bar.go
Current
func (b *Bar) Current() int { b.mtx.RLock() defer b.mtx.RUnlock() return b.current }
go
func (b *Bar) Current() int { b.mtx.RLock() defer b.mtx.RUnlock() return b.current }
[ "func", "(", "b", "*", "Bar", ")", "Current", "(", ")", "int", "{", "b", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "b", ".", "current", "\n", "}" ]
// Current returns the current progress of the bar
[ "Current", "returns", "the", "current", "progress", "of", "the", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L121-L125
151,948
gosuri/uiprogress
bar.go
AppendFunc
func (b *Bar) AppendFunc(f DecoratorFunc) *Bar { b.mtx.Lock() defer b.mtx.Unlock() b.appendFuncs = append(b.appendFuncs, f) return b }
go
func (b *Bar) AppendFunc(f DecoratorFunc) *Bar { b.mtx.Lock() defer b.mtx.Unlock() b.appendFuncs = append(b.appendFuncs, f) return b }
[ "func", "(", "b", "*", "Bar", ")", "AppendFunc", "(", "f", "DecoratorFunc", ")", "*", "Bar", "{", "b", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "Unlock", "(", ")", "\n", "b", ".", "appendFuncs", "=", "append", "(", "b", ".", "appendFuncs", ",", "f", ")", "\n", "return", "b", "\n", "}" ]
// AppendFunc runs the decorator function and renders the output on the right of the progress bar
[ "AppendFunc", "runs", "the", "decorator", "function", "and", "renders", "the", "output", "on", "the", "right", "of", "the", "progress", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L128-L133
151,949
gosuri/uiprogress
bar.go
AppendCompleted
func (b *Bar) AppendCompleted() *Bar { b.AppendFunc(func(b *Bar) string { return b.CompletedPercentString() }) return b }
go
func (b *Bar) AppendCompleted() *Bar { b.AppendFunc(func(b *Bar) string { return b.CompletedPercentString() }) return b }
[ "func", "(", "b", "*", "Bar", ")", "AppendCompleted", "(", ")", "*", "Bar", "{", "b", ".", "AppendFunc", "(", "func", "(", "b", "*", "Bar", ")", "string", "{", "return", "b", ".", "CompletedPercentString", "(", ")", "\n", "}", ")", "\n", "return", "b", "\n", "}" ]
// AppendCompleted appends the completion percent to the progress bar
[ "AppendCompleted", "appends", "the", "completion", "percent", "to", "the", "progress", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L136-L141
151,950
gosuri/uiprogress
bar.go
AppendElapsed
func (b *Bar) AppendElapsed() *Bar { b.AppendFunc(func(b *Bar) string { return strutil.PadLeft(b.TimeElapsedString(), 5, ' ') }) return b }
go
func (b *Bar) AppendElapsed() *Bar { b.AppendFunc(func(b *Bar) string { return strutil.PadLeft(b.TimeElapsedString(), 5, ' ') }) return b }
[ "func", "(", "b", "*", "Bar", ")", "AppendElapsed", "(", ")", "*", "Bar", "{", "b", ".", "AppendFunc", "(", "func", "(", "b", "*", "Bar", ")", "string", "{", "return", "strutil", ".", "PadLeft", "(", "b", ".", "TimeElapsedString", "(", ")", ",", "5", ",", "' '", ")", "\n", "}", ")", "\n", "return", "b", "\n", "}" ]
// AppendElapsed appends the time elapsed the be progress bar
[ "AppendElapsed", "appends", "the", "time", "elapsed", "the", "be", "progress", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L144-L149
151,951
gosuri/uiprogress
bar.go
PrependFunc
func (b *Bar) PrependFunc(f DecoratorFunc) *Bar { b.mtx.Lock() defer b.mtx.Unlock() b.prependFuncs = append(b.prependFuncs, f) return b }
go
func (b *Bar) PrependFunc(f DecoratorFunc) *Bar { b.mtx.Lock() defer b.mtx.Unlock() b.prependFuncs = append(b.prependFuncs, f) return b }
[ "func", "(", "b", "*", "Bar", ")", "PrependFunc", "(", "f", "DecoratorFunc", ")", "*", "Bar", "{", "b", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "Unlock", "(", ")", "\n", "b", ".", "prependFuncs", "=", "append", "(", "b", ".", "prependFuncs", ",", "f", ")", "\n", "return", "b", "\n", "}" ]
// PrependFunc runs decorator function and render the output left the progress bar
[ "PrependFunc", "runs", "decorator", "function", "and", "render", "the", "output", "left", "the", "progress", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L152-L157
151,952
gosuri/uiprogress
bar.go
PrependCompleted
func (b *Bar) PrependCompleted() *Bar { b.PrependFunc(func(b *Bar) string { return b.CompletedPercentString() }) return b }
go
func (b *Bar) PrependCompleted() *Bar { b.PrependFunc(func(b *Bar) string { return b.CompletedPercentString() }) return b }
[ "func", "(", "b", "*", "Bar", ")", "PrependCompleted", "(", ")", "*", "Bar", "{", "b", ".", "PrependFunc", "(", "func", "(", "b", "*", "Bar", ")", "string", "{", "return", "b", ".", "CompletedPercentString", "(", ")", "\n", "}", ")", "\n", "return", "b", "\n", "}" ]
// PrependCompleted prepends the precent completed to the progress bar
[ "PrependCompleted", "prepends", "the", "precent", "completed", "to", "the", "progress", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L160-L165
151,953
gosuri/uiprogress
bar.go
PrependElapsed
func (b *Bar) PrependElapsed() *Bar { b.PrependFunc(func(b *Bar) string { return strutil.PadLeft(b.TimeElapsedString(), 5, ' ') }) return b }
go
func (b *Bar) PrependElapsed() *Bar { b.PrependFunc(func(b *Bar) string { return strutil.PadLeft(b.TimeElapsedString(), 5, ' ') }) return b }
[ "func", "(", "b", "*", "Bar", ")", "PrependElapsed", "(", ")", "*", "Bar", "{", "b", ".", "PrependFunc", "(", "func", "(", "b", "*", "Bar", ")", "string", "{", "return", "strutil", ".", "PadLeft", "(", "b", ".", "TimeElapsedString", "(", ")", ",", "5", ",", "' '", ")", "\n", "}", ")", "\n", "return", "b", "\n", "}" ]
// PrependElapsed prepends the time elapsed to the begining of the bar
[ "PrependElapsed", "prepends", "the", "time", "elapsed", "to", "the", "begining", "of", "the", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L168-L173
151,954
gosuri/uiprogress
bar.go
Bytes
func (b *Bar) Bytes() []byte { completedWidth := int(float64(b.Width) * (b.CompletedPercent() / 100.00)) // add fill and empty bits var buf bytes.Buffer for i := 0; i < completedWidth; i++ { buf.WriteByte(b.Fill) } for i := 0; i < b.Width-completedWidth; i++ { buf.WriteByte(b.Empty) } // set head bit pb := buf.Bytes() if completedWidth > 0 && completedWidth < b.Width { pb[completedWidth-1] = b.Head } // set left and right ends bits pb[0], pb[len(pb)-1] = b.LeftEnd, b.RightEnd // render append functions to the right of the bar for _, f := range b.appendFuncs { pb = append(pb, ' ') pb = append(pb, []byte(f(b))...) } // render prepend functions to the left of the bar for _, f := range b.prependFuncs { args := []byte(f(b)) args = append(args, ' ') pb = append(args, pb...) } return pb }
go
func (b *Bar) Bytes() []byte { completedWidth := int(float64(b.Width) * (b.CompletedPercent() / 100.00)) // add fill and empty bits var buf bytes.Buffer for i := 0; i < completedWidth; i++ { buf.WriteByte(b.Fill) } for i := 0; i < b.Width-completedWidth; i++ { buf.WriteByte(b.Empty) } // set head bit pb := buf.Bytes() if completedWidth > 0 && completedWidth < b.Width { pb[completedWidth-1] = b.Head } // set left and right ends bits pb[0], pb[len(pb)-1] = b.LeftEnd, b.RightEnd // render append functions to the right of the bar for _, f := range b.appendFuncs { pb = append(pb, ' ') pb = append(pb, []byte(f(b))...) } // render prepend functions to the left of the bar for _, f := range b.prependFuncs { args := []byte(f(b)) args = append(args, ' ') pb = append(args, pb...) } return pb }
[ "func", "(", "b", "*", "Bar", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "completedWidth", ":=", "int", "(", "float64", "(", "b", ".", "Width", ")", "*", "(", "b", ".", "CompletedPercent", "(", ")", "/", "100.00", ")", ")", "\n\n", "// add fill and empty bits", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "i", ":=", "0", ";", "i", "<", "completedWidth", ";", "i", "++", "{", "buf", ".", "WriteByte", "(", "b", ".", "Fill", ")", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "b", ".", "Width", "-", "completedWidth", ";", "i", "++", "{", "buf", ".", "WriteByte", "(", "b", ".", "Empty", ")", "\n", "}", "\n\n", "// set head bit", "pb", ":=", "buf", ".", "Bytes", "(", ")", "\n", "if", "completedWidth", ">", "0", "&&", "completedWidth", "<", "b", ".", "Width", "{", "pb", "[", "completedWidth", "-", "1", "]", "=", "b", ".", "Head", "\n", "}", "\n\n", "// set left and right ends bits", "pb", "[", "0", "]", ",", "pb", "[", "len", "(", "pb", ")", "-", "1", "]", "=", "b", ".", "LeftEnd", ",", "b", ".", "RightEnd", "\n\n", "// render append functions to the right of the bar", "for", "_", ",", "f", ":=", "range", "b", ".", "appendFuncs", "{", "pb", "=", "append", "(", "pb", ",", "' '", ")", "\n", "pb", "=", "append", "(", "pb", ",", "[", "]", "byte", "(", "f", "(", "b", ")", ")", "...", ")", "\n", "}", "\n\n", "// render prepend functions to the left of the bar", "for", "_", ",", "f", ":=", "range", "b", ".", "prependFuncs", "{", "args", ":=", "[", "]", "byte", "(", "f", "(", "b", ")", ")", "\n", "args", "=", "append", "(", "args", ",", "' '", ")", "\n", "pb", "=", "append", "(", "args", ",", "pb", "...", ")", "\n", "}", "\n", "return", "pb", "\n", "}" ]
// Bytes returns the byte presentation of the progress bar
[ "Bytes", "returns", "the", "byte", "presentation", "of", "the", "progress", "bar" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L176-L210
151,955
gosuri/uiprogress
bar.go
CompletedPercent
func (b *Bar) CompletedPercent() float64 { return (float64(b.Current()) / float64(b.Total)) * 100.00 }
go
func (b *Bar) CompletedPercent() float64 { return (float64(b.Current()) / float64(b.Total)) * 100.00 }
[ "func", "(", "b", "*", "Bar", ")", "CompletedPercent", "(", ")", "float64", "{", "return", "(", "float64", "(", "b", ".", "Current", "(", ")", ")", "/", "float64", "(", "b", ".", "Total", ")", ")", "*", "100.00", "\n", "}" ]
// CompletedPercent return the percent completed
[ "CompletedPercent", "return", "the", "percent", "completed" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L218-L220
151,956
gosuri/uiprogress
bar.go
TimeElapsed
func (b *Bar) TimeElapsed() time.Duration { b.mtx.RLock() defer b.mtx.RUnlock() return b.timeElapsed }
go
func (b *Bar) TimeElapsed() time.Duration { b.mtx.RLock() defer b.mtx.RUnlock() return b.timeElapsed }
[ "func", "(", "b", "*", "Bar", ")", "TimeElapsed", "(", ")", "time", ".", "Duration", "{", "b", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "b", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "b", ".", "timeElapsed", "\n", "}" ]
// TimeElapsed returns the time elapsed
[ "TimeElapsed", "returns", "the", "time", "elapsed" ]
d0567a9d84a1c40dd7568115ea66f4887bf57b33
https://github.com/gosuri/uiprogress/blob/d0567a9d84a1c40dd7568115ea66f4887bf57b33/bar.go#L228-L232
151,957
goreleaser/nfpm
glob/glob.go
longestCommonPrefix
func longestCommonPrefix(strs []string) string { if len(strs) == 0 { return "" } lcp := strs[0] for _, str := range strs { lcp = strlcp(lcp, str) } return lcp }
go
func longestCommonPrefix(strs []string) string { if len(strs) == 0 { return "" } lcp := strs[0] for _, str := range strs { lcp = strlcp(lcp, str) } return lcp }
[ "func", "longestCommonPrefix", "(", "strs", "[", "]", "string", ")", "string", "{", "if", "len", "(", "strs", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "lcp", ":=", "strs", "[", "0", "]", "\n", "for", "_", ",", "str", ":=", "range", "strs", "{", "lcp", "=", "strlcp", "(", "lcp", ",", "str", ")", "\n", "}", "\n", "return", "lcp", "\n", "}" ]
// longestCommonPrefix returns the longest prefix of all strings the argument // slice. If the slice is empty the empty string is returned
[ "longestCommonPrefix", "returns", "the", "longest", "prefix", "of", "all", "strings", "the", "argument", "slice", ".", "If", "the", "slice", "is", "empty", "the", "empty", "string", "is", "returned" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/glob/glob.go#L15-L24
151,958
goreleaser/nfpm
deb/deb.go
Package
func (*Deb) Package(info nfpm.Info, deb io.Writer) (err error) { arch, ok := archToDebian[info.Arch] if ok { info.Arch = arch } dataTarGz, md5sums, instSize, err := createDataTarGz(info) if err != nil { return err } controlTarGz, err := createControl(instSize, md5sums, info) if err != nil { return err } var w = ar.NewWriter(deb) if err := w.WriteGlobalHeader(); err != nil { return errors.Wrap(err, "cannot write ar header to deb file") } if err := addArFile(w, "debian-binary", []byte("2.0\n")); err != nil { return errors.Wrap(err, "cannot pack debian-binary") } if err := addArFile(w, "control.tar.gz", controlTarGz); err != nil { return errors.Wrap(err, "cannot add control.tar.gz to deb") } if err := addArFile(w, "data.tar.gz", dataTarGz); err != nil { return errors.Wrap(err, "cannot add data.tar.gz to deb") } return nil }
go
func (*Deb) Package(info nfpm.Info, deb io.Writer) (err error) { arch, ok := archToDebian[info.Arch] if ok { info.Arch = arch } dataTarGz, md5sums, instSize, err := createDataTarGz(info) if err != nil { return err } controlTarGz, err := createControl(instSize, md5sums, info) if err != nil { return err } var w = ar.NewWriter(deb) if err := w.WriteGlobalHeader(); err != nil { return errors.Wrap(err, "cannot write ar header to deb file") } if err := addArFile(w, "debian-binary", []byte("2.0\n")); err != nil { return errors.Wrap(err, "cannot pack debian-binary") } if err := addArFile(w, "control.tar.gz", controlTarGz); err != nil { return errors.Wrap(err, "cannot add control.tar.gz to deb") } if err := addArFile(w, "data.tar.gz", dataTarGz); err != nil { return errors.Wrap(err, "cannot add data.tar.gz to deb") } return nil }
[ "func", "(", "*", "Deb", ")", "Package", "(", "info", "nfpm", ".", "Info", ",", "deb", "io", ".", "Writer", ")", "(", "err", "error", ")", "{", "arch", ",", "ok", ":=", "archToDebian", "[", "info", ".", "Arch", "]", "\n", "if", "ok", "{", "info", ".", "Arch", "=", "arch", "\n", "}", "\n", "dataTarGz", ",", "md5sums", ",", "instSize", ",", "err", ":=", "createDataTarGz", "(", "info", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "controlTarGz", ",", "err", ":=", "createControl", "(", "instSize", ",", "md5sums", ",", "info", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "w", "=", "ar", ".", "NewWriter", "(", "deb", ")", "\n", "if", "err", ":=", "w", ".", "WriteGlobalHeader", "(", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "addArFile", "(", "w", ",", "\"", "\"", ",", "[", "]", "byte", "(", "\"", "\\n", "\"", ")", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "addArFile", "(", "w", ",", "\"", "\"", ",", "controlTarGz", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "addArFile", "(", "w", ",", "\"", "\"", ",", "dataTarGz", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Package writes a new deb package to the given writer using the given info
[ "Package", "writes", "a", "new", "deb", "package", "to", "the", "given", "writer", "using", "the", "given", "info" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/deb/deb.go#L47-L74
151,959
goreleaser/nfpm
deb/deb.go
createTree
func createTree(tarw *tar.Writer, dst string, created map[string]bool) error { for _, path := range pathsToCreate(dst) { if created[path] { // skipping dir that was previously created inside the archive // (eg: usr/) continue } if err := tarw.WriteHeader(&tar.Header{ Name: filepath.ToSlash(path + "/"), Mode: 0755, Typeflag: tar.TypeDir, Format: tar.FormatGNU, ModTime: time.Now(), }); err != nil { return errors.Wrap(err, "failed to create folder") } created[path] = true } return nil }
go
func createTree(tarw *tar.Writer, dst string, created map[string]bool) error { for _, path := range pathsToCreate(dst) { if created[path] { // skipping dir that was previously created inside the archive // (eg: usr/) continue } if err := tarw.WriteHeader(&tar.Header{ Name: filepath.ToSlash(path + "/"), Mode: 0755, Typeflag: tar.TypeDir, Format: tar.FormatGNU, ModTime: time.Now(), }); err != nil { return errors.Wrap(err, "failed to create folder") } created[path] = true } return nil }
[ "func", "createTree", "(", "tarw", "*", "tar", ".", "Writer", ",", "dst", "string", ",", "created", "map", "[", "string", "]", "bool", ")", "error", "{", "for", "_", ",", "path", ":=", "range", "pathsToCreate", "(", "dst", ")", "{", "if", "created", "[", "path", "]", "{", "// skipping dir that was previously created inside the archive", "// (eg: usr/)", "continue", "\n", "}", "\n", "if", "err", ":=", "tarw", ".", "WriteHeader", "(", "&", "tar", ".", "Header", "{", "Name", ":", "filepath", ".", "ToSlash", "(", "path", "+", "\"", "\"", ")", ",", "Mode", ":", "0755", ",", "Typeflag", ":", "tar", ".", "TypeDir", ",", "Format", ":", "tar", ".", "FormatGNU", ",", "ModTime", ":", "time", ".", "Now", "(", ")", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "created", "[", "path", "]", "=", "true", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// this is needed because the data.tar.gz file should have the empty folders // as well, so we walk through the dst and create all subfolders.
[ "this", "is", "needed", "because", "the", "data", ".", "tar", ".", "gz", "file", "should", "have", "the", "empty", "folders", "as", "well", "so", "we", "walk", "through", "the", "dst", "and", "create", "all", "subfolders", "." ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/deb/deb.go#L285-L304
151,960
goreleaser/nfpm
rpm/rpm.go
Package
func (*RPM) Package(info nfpm.Info, w io.Writer) error { arch, ok := archToRPM[info.Arch] if ok { info.Arch = arch } info.Version = strings.Replace(info.Version, "-", "_", -1) _, err := exec.LookPath("rpmbuild") if err != nil { return fmt.Errorf("rpmbuild not present in $PATH") } temps, err := setupTempFiles(info) if err != nil { return err } if err = createTarGz(info, temps.Folder, temps.Source); err != nil { return err } if err = createSpec(info, temps.Spec); err != nil { return errors.Wrap(err, "failed to create rpm spec file") } var args = []string{ "--verbose", "--define", fmt.Sprintf("_topdir %s", temps.Root), "--define", fmt.Sprintf("_tmppath %s/tmp", temps.Root), "--target", fmt.Sprintf("%s-unknown-%s", info.Arch, info.Platform), "-ba", "SPECS/" + info.Name + ".spec", } cmd := exec.Command("rpmbuild", args...) //nolint:gosec cmd.Dir = temps.Root out, err := cmd.CombinedOutput() if err != nil { var msg = "rpmbuild failed" if string(out) != "" { msg += ": " + string(out) } return errors.Wrap(err, msg) } rpm, err := os.Open(temps.RPM) if err != nil { return errors.Wrap(err, "failed open rpm file") } _, err = io.Copy(w, rpm) return errors.Wrap(err, "failed to copy rpm file to writer") }
go
func (*RPM) Package(info nfpm.Info, w io.Writer) error { arch, ok := archToRPM[info.Arch] if ok { info.Arch = arch } info.Version = strings.Replace(info.Version, "-", "_", -1) _, err := exec.LookPath("rpmbuild") if err != nil { return fmt.Errorf("rpmbuild not present in $PATH") } temps, err := setupTempFiles(info) if err != nil { return err } if err = createTarGz(info, temps.Folder, temps.Source); err != nil { return err } if err = createSpec(info, temps.Spec); err != nil { return errors.Wrap(err, "failed to create rpm spec file") } var args = []string{ "--verbose", "--define", fmt.Sprintf("_topdir %s", temps.Root), "--define", fmt.Sprintf("_tmppath %s/tmp", temps.Root), "--target", fmt.Sprintf("%s-unknown-%s", info.Arch, info.Platform), "-ba", "SPECS/" + info.Name + ".spec", } cmd := exec.Command("rpmbuild", args...) //nolint:gosec cmd.Dir = temps.Root out, err := cmd.CombinedOutput() if err != nil { var msg = "rpmbuild failed" if string(out) != "" { msg += ": " + string(out) } return errors.Wrap(err, msg) } rpm, err := os.Open(temps.RPM) if err != nil { return errors.Wrap(err, "failed open rpm file") } _, err = io.Copy(w, rpm) return errors.Wrap(err, "failed to copy rpm file to writer") }
[ "func", "(", "*", "RPM", ")", "Package", "(", "info", "nfpm", ".", "Info", ",", "w", "io", ".", "Writer", ")", "error", "{", "arch", ",", "ok", ":=", "archToRPM", "[", "info", ".", "Arch", "]", "\n", "if", "ok", "{", "info", ".", "Arch", "=", "arch", "\n", "}", "\n", "info", ".", "Version", "=", "strings", ".", "Replace", "(", "info", ".", "Version", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "_", ",", "err", ":=", "exec", ".", "LookPath", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "temps", ",", "err", ":=", "setupTempFiles", "(", "info", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", "=", "createTarGz", "(", "info", ",", "temps", ".", "Folder", ",", "temps", ".", "Source", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", "=", "createSpec", "(", "info", ",", "temps", ".", "Spec", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "var", "args", "=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "temps", ".", "Root", ")", ",", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "temps", ".", "Root", ")", ",", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "info", ".", "Arch", ",", "info", ".", "Platform", ")", ",", "\"", "\"", ",", "\"", "\"", "+", "info", ".", "Name", "+", "\"", "\"", ",", "}", "\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "args", "...", ")", "//nolint:gosec", "\n", "cmd", ".", "Dir", "=", "temps", ".", "Root", "\n", "out", ",", "err", ":=", "cmd", ".", "CombinedOutput", "(", ")", "\n", "if", "err", "!=", "nil", "{", "var", "msg", "=", "\"", "\"", "\n", "if", "string", "(", "out", ")", "!=", "\"", "\"", "{", "msg", "+=", "\"", "\"", "+", "string", "(", "out", ")", "\n", "}", "\n", "return", "errors", ".", "Wrap", "(", "err", ",", "msg", ")", "\n", "}", "\n\n", "rpm", ",", "err", ":=", "os", ".", "Open", "(", "temps", ".", "RPM", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "w", ",", "rpm", ")", "\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}" ]
// Package writes a new RPM package to the given writer using the given info
[ "Package", "writes", "a", "new", "RPM", "package", "to", "the", "given", "writer", "using", "the", "given", "info" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/rpm/rpm.go#L43-L89
151,961
goreleaser/nfpm
nfpm.go
Register
func Register(format string, p Packager) { lock.Lock() packagers[format] = p lock.Unlock() }
go
func Register(format string, p Packager) { lock.Lock() packagers[format] = p lock.Unlock() }
[ "func", "Register", "(", "format", "string", ",", "p", "Packager", ")", "{", "lock", ".", "Lock", "(", ")", "\n", "packagers", "[", "format", "]", "=", "p", "\n", "lock", ".", "Unlock", "(", ")", "\n", "}" ]
// Register a new packager for the given format
[ "Register", "a", "new", "packager", "for", "the", "given", "format" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L24-L28
151,962
goreleaser/nfpm
nfpm.go
Get
func Get(format string) (Packager, error) { p, ok := packagers[format] if !ok { return nil, fmt.Errorf("no packager registered for the format %s", format) } return p, nil }
go
func Get(format string) (Packager, error) { p, ok := packagers[format] if !ok { return nil, fmt.Errorf("no packager registered for the format %s", format) } return p, nil }
[ "func", "Get", "(", "format", "string", ")", "(", "Packager", ",", "error", ")", "{", "p", ",", "ok", ":=", "packagers", "[", "format", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "format", ")", "\n", "}", "\n", "return", "p", ",", "nil", "\n", "}" ]
// Get a packager for the given format
[ "Get", "a", "packager", "for", "the", "given", "format" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L31-L37
151,963
goreleaser/nfpm
nfpm.go
Parse
func Parse(in io.Reader) (config Config, err error) { dec := yaml.NewDecoder(in) dec.SetStrict(true) if err = dec.Decode(&config); err != nil { return } config.Info.Version = os.ExpandEnv(config.Info.Version) err = config.Validate() return }
go
func Parse(in io.Reader) (config Config, err error) { dec := yaml.NewDecoder(in) dec.SetStrict(true) if err = dec.Decode(&config); err != nil { return } config.Info.Version = os.ExpandEnv(config.Info.Version) err = config.Validate() return }
[ "func", "Parse", "(", "in", "io", ".", "Reader", ")", "(", "config", "Config", ",", "err", "error", ")", "{", "dec", ":=", "yaml", ".", "NewDecoder", "(", "in", ")", "\n", "dec", ".", "SetStrict", "(", "true", ")", "\n", "if", "err", "=", "dec", ".", "Decode", "(", "&", "config", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "config", ".", "Info", ".", "Version", "=", "os", ".", "ExpandEnv", "(", "config", ".", "Info", ".", "Version", ")", "\n", "err", "=", "config", ".", "Validate", "(", ")", "\n", "return", "\n", "}" ]
// Parse decodes YAML data from an io.Reader into a configuration struct
[ "Parse", "decodes", "YAML", "data", "from", "an", "io", ".", "Reader", "into", "a", "configuration", "struct" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L40-L50
151,964
goreleaser/nfpm
nfpm.go
ParseFile
func ParseFile(path string) (config Config, err error) { var file *os.File file, err = os.Open(path) //nolint:gosec if err != nil { return } defer file.Close() // nolint: errcheck return Parse(file) }
go
func ParseFile(path string) (config Config, err error) { var file *os.File file, err = os.Open(path) //nolint:gosec if err != nil { return } defer file.Close() // nolint: errcheck return Parse(file) }
[ "func", "ParseFile", "(", "path", "string", ")", "(", "config", "Config", ",", "err", "error", ")", "{", "var", "file", "*", "os", ".", "File", "\n", "file", ",", "err", "=", "os", ".", "Open", "(", "path", ")", "//nolint:gosec", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "// nolint: errcheck", "\n", "return", "Parse", "(", "file", ")", "\n", "}" ]
// ParseFile decodes YAML data from a file path into a configuration struct
[ "ParseFile", "decodes", "YAML", "data", "from", "a", "file", "path", "into", "a", "configuration", "struct" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L53-L61
151,965
goreleaser/nfpm
nfpm.go
Get
func (c *Config) Get(format string) (info Info, err error) { // make a deep copy of info if err = mergo.Merge(&info, c.Info); err != nil { return } override, ok := c.Overrides[format] if !ok { // no overrides return } err = mergo.Merge(&info.Overridables, override, mergo.WithOverride) if err != nil { return } return }
go
func (c *Config) Get(format string) (info Info, err error) { // make a deep copy of info if err = mergo.Merge(&info, c.Info); err != nil { return } override, ok := c.Overrides[format] if !ok { // no overrides return } err = mergo.Merge(&info.Overridables, override, mergo.WithOverride) if err != nil { return } return }
[ "func", "(", "c", "*", "Config", ")", "Get", "(", "format", "string", ")", "(", "info", "Info", ",", "err", "error", ")", "{", "// make a deep copy of info", "if", "err", "=", "mergo", ".", "Merge", "(", "&", "info", ",", "c", ".", "Info", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "override", ",", "ok", ":=", "c", ".", "Overrides", "[", "format", "]", "\n", "if", "!", "ok", "{", "// no overrides", "return", "\n", "}", "\n", "err", "=", "mergo", ".", "Merge", "(", "&", "info", ".", "Overridables", ",", "override", ",", "mergo", ".", "WithOverride", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "return", "\n", "}" ]
// Get returns the Info struct for the given packager format. Overrides // for the given format are merged into the final struct
[ "Get", "returns", "the", "Info", "struct", "for", "the", "given", "packager", "format", ".", "Overrides", "for", "the", "given", "format", "are", "merged", "into", "the", "final", "struct" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L76-L91
151,966
goreleaser/nfpm
nfpm.go
Validate
func (c *Config) Validate() error { for format := range c.Overrides { if _, err := Get(format); err != nil { return err } } return nil }
go
func (c *Config) Validate() error { for format := range c.Overrides { if _, err := Get(format); err != nil { return err } } return nil }
[ "func", "(", "c", "*", "Config", ")", "Validate", "(", ")", "error", "{", "for", "format", ":=", "range", "c", ".", "Overrides", "{", "if", "_", ",", "err", ":=", "Get", "(", "format", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate ensures that the config is well typed
[ "Validate", "ensures", "that", "the", "config", "is", "well", "typed" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L94-L101
151,967
goreleaser/nfpm
nfpm.go
Validate
func Validate(info Info) error { if info.Name == "" { return fmt.Errorf("package name cannot be empty") } if info.Arch == "" { return fmt.Errorf("package arch must be provided") } if info.Version == "" { return fmt.Errorf("package version must be provided") } if len(info.Files)+len(info.ConfigFiles) == 0 { return fmt.Errorf("no files were provided") } return nil }
go
func Validate(info Info) error { if info.Name == "" { return fmt.Errorf("package name cannot be empty") } if info.Arch == "" { return fmt.Errorf("package arch must be provided") } if info.Version == "" { return fmt.Errorf("package version must be provided") } if len(info.Files)+len(info.ConfigFiles) == 0 { return fmt.Errorf("no files were provided") } return nil }
[ "func", "Validate", "(", "info", "Info", ")", "error", "{", "if", "info", ".", "Name", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "info", ".", "Arch", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "info", ".", "Version", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "info", ".", "Files", ")", "+", "len", "(", "info", ".", "ConfigFiles", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate the given Info and returns an error if it is invalid.
[ "Validate", "the", "given", "Info", "and", "returns", "an", "error", "if", "it", "is", "invalid", "." ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L143-L157
151,968
goreleaser/nfpm
nfpm.go
WithDefaults
func WithDefaults(info Info) Info { if info.Bindir == "" { info.Bindir = "/usr/local/bin" } if info.Platform == "" { info.Platform = "linux" } if info.Description == "" { info.Description = "no description given" } info.Version = strings.TrimPrefix(info.Version, "v") return info }
go
func WithDefaults(info Info) Info { if info.Bindir == "" { info.Bindir = "/usr/local/bin" } if info.Platform == "" { info.Platform = "linux" } if info.Description == "" { info.Description = "no description given" } info.Version = strings.TrimPrefix(info.Version, "v") return info }
[ "func", "WithDefaults", "(", "info", "Info", ")", "Info", "{", "if", "info", ".", "Bindir", "==", "\"", "\"", "{", "info", ".", "Bindir", "=", "\"", "\"", "\n", "}", "\n", "if", "info", ".", "Platform", "==", "\"", "\"", "{", "info", ".", "Platform", "=", "\"", "\"", "\n", "}", "\n", "if", "info", ".", "Description", "==", "\"", "\"", "{", "info", ".", "Description", "=", "\"", "\"", "\n", "}", "\n", "info", ".", "Version", "=", "strings", ".", "TrimPrefix", "(", "info", ".", "Version", ",", "\"", "\"", ")", "\n", "return", "info", "\n", "}" ]
// WithDefaults set some sane defaults into the given Info
[ "WithDefaults", "set", "some", "sane", "defaults", "into", "the", "given", "Info" ]
21aa86065385f2c769cb56f151344d46e8c6c5da
https://github.com/goreleaser/nfpm/blob/21aa86065385f2c769cb56f151344d46e8c6c5da/nfpm.go#L160-L172
151,969
tsuna/gohbase
region/client.go
QueueRPC
func (c *client) QueueRPC(rpc hrpc.Call) { if b, ok := rpc.(hrpc.Batchable); ok && c.rpcQueueSize > 1 && !b.SkipBatch() { // queue up the rpc select { case <-rpc.Context().Done(): // rpc timed out before being processed case <-c.done: returnResult(rpc, nil, ErrClientClosed) case c.rpcs <- rpc: } } else { if err := c.trySend(rpc); err != nil { returnResult(rpc, nil, err) } } }
go
func (c *client) QueueRPC(rpc hrpc.Call) { if b, ok := rpc.(hrpc.Batchable); ok && c.rpcQueueSize > 1 && !b.SkipBatch() { // queue up the rpc select { case <-rpc.Context().Done(): // rpc timed out before being processed case <-c.done: returnResult(rpc, nil, ErrClientClosed) case c.rpcs <- rpc: } } else { if err := c.trySend(rpc); err != nil { returnResult(rpc, nil, err) } } }
[ "func", "(", "c", "*", "client", ")", "QueueRPC", "(", "rpc", "hrpc", ".", "Call", ")", "{", "if", "b", ",", "ok", ":=", "rpc", ".", "(", "hrpc", ".", "Batchable", ")", ";", "ok", "&&", "c", ".", "rpcQueueSize", ">", "1", "&&", "!", "b", ".", "SkipBatch", "(", ")", "{", "// queue up the rpc", "select", "{", "case", "<-", "rpc", ".", "Context", "(", ")", ".", "Done", "(", ")", ":", "// rpc timed out before being processed", "case", "<-", "c", ".", "done", ":", "returnResult", "(", "rpc", ",", "nil", ",", "ErrClientClosed", ")", "\n", "case", "c", ".", "rpcs", "<-", "rpc", ":", "}", "\n", "}", "else", "{", "if", "err", ":=", "c", ".", "trySend", "(", "rpc", ")", ";", "err", "!=", "nil", "{", "returnResult", "(", "rpc", ",", "nil", ",", "err", ")", "\n", "}", "\n", "}", "\n", "}" ]
// QueueRPC will add an rpc call to the queue for processing by the writer goroutine
[ "QueueRPC", "will", "add", "an", "rpc", "call", "to", "the", "queue", "for", "processing", "by", "the", "writer", "goroutine" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/client.go#L180-L195
151,970
tsuna/gohbase
region/client.go
write
func (c *client) write(buf []byte) error { _, err := c.conn.Write(buf) return err }
go
func (c *client) write(buf []byte) error { _, err := c.conn.Write(buf) return err }
[ "func", "(", "c", "*", "client", ")", "write", "(", "buf", "[", "]", "byte", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "conn", ".", "Write", "(", "buf", ")", "\n", "return", "err", "\n", "}" ]
// write sends the given buffer to the RegionServer.
[ "write", "sends", "the", "given", "buffer", "to", "the", "RegionServer", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/client.go#L519-L522
151,971
tsuna/gohbase
region/client.go
readFully
func (c *client) readFully(buf []byte) error { _, err := io.ReadFull(c.conn, buf) return err }
go
func (c *client) readFully(buf []byte) error { _, err := io.ReadFull(c.conn, buf) return err }
[ "func", "(", "c", "*", "client", ")", "readFully", "(", "buf", "[", "]", "byte", ")", "error", "{", "_", ",", "err", ":=", "io", ".", "ReadFull", "(", "c", ".", "conn", ",", "buf", ")", "\n", "return", "err", "\n", "}" ]
// Tries to read enough data to fully fill up the given buffer.
[ "Tries", "to", "read", "enough", "data", "to", "fully", "fill", "up", "the", "given", "buffer", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/client.go#L525-L528
151,972
tsuna/gohbase
region/client.go
sendHello
func (c *client) sendHello(ctype ClientType) error { connHeader := &pb.ConnectionHeader{ UserInfo: &pb.UserInformation{ EffectiveUser: proto.String(c.effectiveUser), }, ServiceName: proto.String(string(ctype)), CellBlockCodecClass: proto.String("org.apache.hadoop.hbase.codec.KeyValueCodec"), } data, err := proto.Marshal(connHeader) if err != nil { return fmt.Errorf("failed to marshal connection header: %s", err) } const header = "HBas\x00\x50" // \x50 = Simple Auth. buf := make([]byte, 0, len(header)+4+len(data)) buf = append(buf, header...) buf = buf[:len(header)+4] binary.BigEndian.PutUint32(buf[6:], uint32(len(data))) buf = append(buf, data...) return c.write(buf) }
go
func (c *client) sendHello(ctype ClientType) error { connHeader := &pb.ConnectionHeader{ UserInfo: &pb.UserInformation{ EffectiveUser: proto.String(c.effectiveUser), }, ServiceName: proto.String(string(ctype)), CellBlockCodecClass: proto.String("org.apache.hadoop.hbase.codec.KeyValueCodec"), } data, err := proto.Marshal(connHeader) if err != nil { return fmt.Errorf("failed to marshal connection header: %s", err) } const header = "HBas\x00\x50" // \x50 = Simple Auth. buf := make([]byte, 0, len(header)+4+len(data)) buf = append(buf, header...) buf = buf[:len(header)+4] binary.BigEndian.PutUint32(buf[6:], uint32(len(data))) buf = append(buf, data...) return c.write(buf) }
[ "func", "(", "c", "*", "client", ")", "sendHello", "(", "ctype", "ClientType", ")", "error", "{", "connHeader", ":=", "&", "pb", ".", "ConnectionHeader", "{", "UserInfo", ":", "&", "pb", ".", "UserInformation", "{", "EffectiveUser", ":", "proto", ".", "String", "(", "c", ".", "effectiveUser", ")", ",", "}", ",", "ServiceName", ":", "proto", ".", "String", "(", "string", "(", "ctype", ")", ")", ",", "CellBlockCodecClass", ":", "proto", ".", "String", "(", "\"", "\"", ")", ",", "}", "\n", "data", ",", "err", ":=", "proto", ".", "Marshal", "(", "connHeader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "const", "header", "=", "\"", "\\x00", "\\x50", "\"", "// \\x50 = Simple Auth.", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "len", "(", "header", ")", "+", "4", "+", "len", "(", "data", ")", ")", "\n", "buf", "=", "append", "(", "buf", ",", "header", "...", ")", "\n", "buf", "=", "buf", "[", ":", "len", "(", "header", ")", "+", "4", "]", "\n", "binary", ".", "BigEndian", ".", "PutUint32", "(", "buf", "[", "6", ":", "]", ",", "uint32", "(", "len", "(", "data", ")", ")", ")", "\n", "buf", "=", "append", "(", "buf", ",", "data", "...", ")", "\n", "return", "c", ".", "write", "(", "buf", ")", "\n", "}" ]
// sendHello sends the "hello" message needed when opening a new connection.
[ "sendHello", "sends", "the", "hello", "message", "needed", "when", "opening", "a", "new", "connection", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/client.go#L531-L551
151,973
tsuna/gohbase
region/multi.go
ToProto
func (m *multi) ToProto() proto.Message { // aggregate calls per region actionsPerReg := map[hrpc.RegionInfo][]*pb.Action{} for i, c := range m.calls { select { case <-c.Context().Done(): // context has expired, don't bother sending it m.calls[i] = nil continue default: } msg := c.ToProto() a := &pb.Action{ Index: proto.Uint32(uint32(i) + 1), // +1 because 0 index means there's no index } switch r := msg.(type) { case *pb.GetRequest: a.Get = r.Get case *pb.MutateRequest: a.Mutation = r.Mutation default: panic(fmt.Sprintf("unsupported call type for Multi: %T", c)) } actionsPerReg[c.Region()] = append(actionsPerReg[c.Region()], a) } // construct the multi proto ra := make([]*pb.RegionAction, len(actionsPerReg)) m.regions = make([]hrpc.RegionInfo, len(actionsPerReg)) i := 0 for r, as := range actionsPerReg { ra[i] = &pb.RegionAction{ Region: &pb.RegionSpecifier{ Type: pb.RegionSpecifier_REGION_NAME.Enum(), Value: r.Name(), }, Action: as, } // Track the order of RegionActions, // so that we can handle whole region exceptions. m.regions[i] = r i++ } return &pb.MultiRequest{RegionAction: ra} }
go
func (m *multi) ToProto() proto.Message { // aggregate calls per region actionsPerReg := map[hrpc.RegionInfo][]*pb.Action{} for i, c := range m.calls { select { case <-c.Context().Done(): // context has expired, don't bother sending it m.calls[i] = nil continue default: } msg := c.ToProto() a := &pb.Action{ Index: proto.Uint32(uint32(i) + 1), // +1 because 0 index means there's no index } switch r := msg.(type) { case *pb.GetRequest: a.Get = r.Get case *pb.MutateRequest: a.Mutation = r.Mutation default: panic(fmt.Sprintf("unsupported call type for Multi: %T", c)) } actionsPerReg[c.Region()] = append(actionsPerReg[c.Region()], a) } // construct the multi proto ra := make([]*pb.RegionAction, len(actionsPerReg)) m.regions = make([]hrpc.RegionInfo, len(actionsPerReg)) i := 0 for r, as := range actionsPerReg { ra[i] = &pb.RegionAction{ Region: &pb.RegionSpecifier{ Type: pb.RegionSpecifier_REGION_NAME.Enum(), Value: r.Name(), }, Action: as, } // Track the order of RegionActions, // so that we can handle whole region exceptions. m.regions[i] = r i++ } return &pb.MultiRequest{RegionAction: ra} }
[ "func", "(", "m", "*", "multi", ")", "ToProto", "(", ")", "proto", ".", "Message", "{", "// aggregate calls per region", "actionsPerReg", ":=", "map", "[", "hrpc", ".", "RegionInfo", "]", "[", "]", "*", "pb", ".", "Action", "{", "}", "\n\n", "for", "i", ",", "c", ":=", "range", "m", ".", "calls", "{", "select", "{", "case", "<-", "c", ".", "Context", "(", ")", ".", "Done", "(", ")", ":", "// context has expired, don't bother sending it", "m", ".", "calls", "[", "i", "]", "=", "nil", "\n", "continue", "\n", "default", ":", "}", "\n\n", "msg", ":=", "c", ".", "ToProto", "(", ")", "\n\n", "a", ":=", "&", "pb", ".", "Action", "{", "Index", ":", "proto", ".", "Uint32", "(", "uint32", "(", "i", ")", "+", "1", ")", ",", "// +1 because 0 index means there's no index", "}", "\n\n", "switch", "r", ":=", "msg", ".", "(", "type", ")", "{", "case", "*", "pb", ".", "GetRequest", ":", "a", ".", "Get", "=", "r", ".", "Get", "\n", "case", "*", "pb", ".", "MutateRequest", ":", "a", ".", "Mutation", "=", "r", ".", "Mutation", "\n", "default", ":", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ")", ")", "\n", "}", "\n\n", "actionsPerReg", "[", "c", ".", "Region", "(", ")", "]", "=", "append", "(", "actionsPerReg", "[", "c", ".", "Region", "(", ")", "]", ",", "a", ")", "\n", "}", "\n\n", "// construct the multi proto", "ra", ":=", "make", "(", "[", "]", "*", "pb", ".", "RegionAction", ",", "len", "(", "actionsPerReg", ")", ")", "\n", "m", ".", "regions", "=", "make", "(", "[", "]", "hrpc", ".", "RegionInfo", ",", "len", "(", "actionsPerReg", ")", ")", "\n\n", "i", ":=", "0", "\n", "for", "r", ",", "as", ":=", "range", "actionsPerReg", "{", "ra", "[", "i", "]", "=", "&", "pb", ".", "RegionAction", "{", "Region", ":", "&", "pb", ".", "RegionSpecifier", "{", "Type", ":", "pb", ".", "RegionSpecifier_REGION_NAME", ".", "Enum", "(", ")", ",", "Value", ":", "r", ".", "Name", "(", ")", ",", "}", ",", "Action", ":", "as", ",", "}", "\n", "// Track the order of RegionActions,", "// so that we can handle whole region exceptions.", "m", ".", "regions", "[", "i", "]", "=", "r", "\n", "i", "++", "\n", "}", "\n", "return", "&", "pb", ".", "MultiRequest", "{", "RegionAction", ":", "ra", "}", "\n", "}" ]
// ToProto converts all request in multi batch to a protobuf message.
[ "ToProto", "converts", "all", "request", "in", "multi", "batch", "to", "a", "protobuf", "message", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/multi.go#L51-L101
151,974
tsuna/gohbase
region/multi.go
DeserializeCellBlocks
func (m *multi) DeserializeCellBlocks(msg proto.Message, b []byte) (uint32, error) { mr := msg.(*pb.MultiResponse) var nread uint32 for _, rar := range mr.GetRegionActionResult() { if e := rar.GetException(); e != nil { if l := len(rar.GetResultOrException()); l != 0 { return 0, fmt.Errorf( "got exception for region, but still have %d result(s) returned from it", l) } continue } for _, roe := range rar.GetResultOrException() { e := roe.GetException() r := roe.GetResult() i := roe.GetIndex() if i == 0 { return 0, errors.New("no index for result in multi response") } else if r == nil && e == nil { return 0, errors.New("no result or exception for action in multi response") } else if r != nil && e != nil { return 0, errors.New("got result and exception for action in multi response") } else if e != nil { continue } c := m.get(i) // TODO: maybe return error if it's out-of-bounds d := c.(canDeserializeCellBlocks) // let it panic, because then it's our bug response := c.NewResponse() switch rsp := response.(type) { case *pb.GetResponse: rsp.Result = r case *pb.MutateResponse: rsp.Result = r default: panic(fmt.Sprintf("unsupported response type for Multi: %T", response)) } // TODO: don't bother deserializing if the call's context has already expired n, err := d.DeserializeCellBlocks(response, b[nread:]) if err != nil { return 0, fmt.Errorf( "error deserializing cellblocks for %q call as part of MultiResponse: %v", c.Name(), err) } nread += n } } return nread, nil }
go
func (m *multi) DeserializeCellBlocks(msg proto.Message, b []byte) (uint32, error) { mr := msg.(*pb.MultiResponse) var nread uint32 for _, rar := range mr.GetRegionActionResult() { if e := rar.GetException(); e != nil { if l := len(rar.GetResultOrException()); l != 0 { return 0, fmt.Errorf( "got exception for region, but still have %d result(s) returned from it", l) } continue } for _, roe := range rar.GetResultOrException() { e := roe.GetException() r := roe.GetResult() i := roe.GetIndex() if i == 0 { return 0, errors.New("no index for result in multi response") } else if r == nil && e == nil { return 0, errors.New("no result or exception for action in multi response") } else if r != nil && e != nil { return 0, errors.New("got result and exception for action in multi response") } else if e != nil { continue } c := m.get(i) // TODO: maybe return error if it's out-of-bounds d := c.(canDeserializeCellBlocks) // let it panic, because then it's our bug response := c.NewResponse() switch rsp := response.(type) { case *pb.GetResponse: rsp.Result = r case *pb.MutateResponse: rsp.Result = r default: panic(fmt.Sprintf("unsupported response type for Multi: %T", response)) } // TODO: don't bother deserializing if the call's context has already expired n, err := d.DeserializeCellBlocks(response, b[nread:]) if err != nil { return 0, fmt.Errorf( "error deserializing cellblocks for %q call as part of MultiResponse: %v", c.Name(), err) } nread += n } } return nread, nil }
[ "func", "(", "m", "*", "multi", ")", "DeserializeCellBlocks", "(", "msg", "proto", ".", "Message", ",", "b", "[", "]", "byte", ")", "(", "uint32", ",", "error", ")", "{", "mr", ":=", "msg", ".", "(", "*", "pb", ".", "MultiResponse", ")", "\n\n", "var", "nread", "uint32", "\n", "for", "_", ",", "rar", ":=", "range", "mr", ".", "GetRegionActionResult", "(", ")", "{", "if", "e", ":=", "rar", ".", "GetException", "(", ")", ";", "e", "!=", "nil", "{", "if", "l", ":=", "len", "(", "rar", ".", "GetResultOrException", "(", ")", ")", ";", "l", "!=", "0", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "l", ")", "\n", "}", "\n", "continue", "\n", "}", "\n\n", "for", "_", ",", "roe", ":=", "range", "rar", ".", "GetResultOrException", "(", ")", "{", "e", ":=", "roe", ".", "GetException", "(", ")", "\n", "r", ":=", "roe", ".", "GetResult", "(", ")", "\n", "i", ":=", "roe", ".", "GetIndex", "(", ")", "\n\n", "if", "i", "==", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "else", "if", "r", "==", "nil", "&&", "e", "==", "nil", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "else", "if", "r", "!=", "nil", "&&", "e", "!=", "nil", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "else", "if", "e", "!=", "nil", "{", "continue", "\n", "}", "\n\n", "c", ":=", "m", ".", "get", "(", "i", ")", "// TODO: maybe return error if it's out-of-bounds", "\n", "d", ":=", "c", ".", "(", "canDeserializeCellBlocks", ")", "// let it panic, because then it's our bug", "\n\n", "response", ":=", "c", ".", "NewResponse", "(", ")", "\n", "switch", "rsp", ":=", "response", ".", "(", "type", ")", "{", "case", "*", "pb", ".", "GetResponse", ":", "rsp", ".", "Result", "=", "r", "\n", "case", "*", "pb", ".", "MutateResponse", ":", "rsp", ".", "Result", "=", "r", "\n", "default", ":", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "response", ")", ")", "\n", "}", "\n\n", "// TODO: don't bother deserializing if the call's context has already expired", "n", ",", "err", ":=", "d", ".", "DeserializeCellBlocks", "(", "response", ",", "b", "[", "nread", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "c", ".", "Name", "(", ")", ",", "err", ")", "\n", "}", "\n", "nread", "+=", "n", "\n", "}", "\n", "}", "\n", "return", "nread", ",", "nil", "\n", "}" ]
// DeserializeCellBlocks deserializes action results from cell blocks.
[ "DeserializeCellBlocks", "deserializes", "action", "results", "from", "cell", "blocks", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/multi.go#L109-L161
151,975
tsuna/gohbase
region/multi.go
add
func (m *multi) add(call hrpc.Call) bool { m.calls = append(m.calls, call) return len(m.calls) == m.size }
go
func (m *multi) add(call hrpc.Call) bool { m.calls = append(m.calls, call) return len(m.calls) == m.size }
[ "func", "(", "m", "*", "multi", ")", "add", "(", "call", "hrpc", ".", "Call", ")", "bool", "{", "m", ".", "calls", "=", "append", "(", "m", ".", "calls", ",", "call", ")", "\n", "return", "len", "(", "m", ".", "calls", ")", "==", "m", ".", "size", "\n", "}" ]
// add adds the call and returns wether the batch is full.
[ "add", "adds", "the", "call", "and", "returns", "wether", "the", "batch", "is", "full", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/multi.go#L230-L233
151,976
tsuna/gohbase
region/multi.go
get
func (m *multi) get(i uint32) hrpc.Call { if i == 0 { panic("index cannot be 0") } return m.calls[i-1] }
go
func (m *multi) get(i uint32) hrpc.Call { if i == 0 { panic("index cannot be 0") } return m.calls[i-1] }
[ "func", "(", "m", "*", "multi", ")", "get", "(", "i", "uint32", ")", "hrpc", ".", "Call", "{", "if", "i", "==", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "m", ".", "calls", "[", "i", "-", "1", "]", "\n", "}" ]
// get retruns an rpc at index. Indicies start from 1 since 0 means that // region server didn't set an index for the action result.
[ "get", "retruns", "an", "rpc", "at", "index", ".", "Indicies", "start", "from", "1", "since", "0", "means", "that", "region", "server", "didn", "t", "set", "an", "index", "for", "the", "action", "result", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/multi.go#L242-L247
151,977
tsuna/gohbase
region/info.go
NewInfo
func NewInfo(id uint64, namespace, table, name, startKey, stopKey []byte) hrpc.RegionInfo { ctx, cancel := context.WithCancel(context.Background()) return &info{ id: id, ctx: ctx, cancel: cancel, namespace: namespace, table: table, name: name, startKey: startKey, stopKey: stopKey, } }
go
func NewInfo(id uint64, namespace, table, name, startKey, stopKey []byte) hrpc.RegionInfo { ctx, cancel := context.WithCancel(context.Background()) return &info{ id: id, ctx: ctx, cancel: cancel, namespace: namespace, table: table, name: name, startKey: startKey, stopKey: stopKey, } }
[ "func", "NewInfo", "(", "id", "uint64", ",", "namespace", ",", "table", ",", "name", ",", "startKey", ",", "stopKey", "[", "]", "byte", ")", "hrpc", ".", "RegionInfo", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "return", "&", "info", "{", "id", ":", "id", ",", "ctx", ":", "ctx", ",", "cancel", ":", "cancel", ",", "namespace", ":", "namespace", ",", "table", ":", "table", ",", "name", ":", "name", ",", "startKey", ":", "startKey", ",", "stopKey", ":", "stopKey", ",", "}", "\n", "}" ]
// NewInfo creates a new region info
[ "NewInfo", "creates", "a", "new", "region", "info" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L58-L70
151,978
tsuna/gohbase
region/info.go
infoFromCell
func infoFromCell(cell *hrpc.Cell) (hrpc.RegionInfo, error) { value := cell.Value if len(value) == 0 { return nil, fmt.Errorf("empty value in %q", cell) } else if value[0] != 'P' { return nil, fmt.Errorf("unsupported region info version %d in %q", value[0], cell) } const pbufMagic = 1346524486 // 4 bytes: "PBUF" magic := binary.BigEndian.Uint32(value[:4]) if magic != pbufMagic { return nil, fmt.Errorf("invalid magic number in %q", cell) } var regInfo pb.RegionInfo err := proto.UnmarshalMerge(value[4:], &regInfo) if err != nil { return nil, fmt.Errorf("failed to decode %q: %s", cell, err) } if regInfo.GetOffline() { return nil, OfflineRegionError{n: string(cell.Row)} } var namespace []byte if !bytes.Equal(regInfo.TableName.Namespace, defaultNamespace) { // if default namespace, pretend there's no namespace namespace = regInfo.TableName.Namespace } return NewInfo( regInfo.GetRegionId(), namespace, regInfo.TableName.Qualifier, cell.Row, regInfo.StartKey, regInfo.EndKey, ), nil }
go
func infoFromCell(cell *hrpc.Cell) (hrpc.RegionInfo, error) { value := cell.Value if len(value) == 0 { return nil, fmt.Errorf("empty value in %q", cell) } else if value[0] != 'P' { return nil, fmt.Errorf("unsupported region info version %d in %q", value[0], cell) } const pbufMagic = 1346524486 // 4 bytes: "PBUF" magic := binary.BigEndian.Uint32(value[:4]) if magic != pbufMagic { return nil, fmt.Errorf("invalid magic number in %q", cell) } var regInfo pb.RegionInfo err := proto.UnmarshalMerge(value[4:], &regInfo) if err != nil { return nil, fmt.Errorf("failed to decode %q: %s", cell, err) } if regInfo.GetOffline() { return nil, OfflineRegionError{n: string(cell.Row)} } var namespace []byte if !bytes.Equal(regInfo.TableName.Namespace, defaultNamespace) { // if default namespace, pretend there's no namespace namespace = regInfo.TableName.Namespace } return NewInfo( regInfo.GetRegionId(), namespace, regInfo.TableName.Qualifier, cell.Row, regInfo.StartKey, regInfo.EndKey, ), nil }
[ "func", "infoFromCell", "(", "cell", "*", "hrpc", ".", "Cell", ")", "(", "hrpc", ".", "RegionInfo", ",", "error", ")", "{", "value", ":=", "cell", ".", "Value", "\n", "if", "len", "(", "value", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cell", ")", "\n", "}", "else", "if", "value", "[", "0", "]", "!=", "'P'", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", "[", "0", "]", ",", "cell", ")", "\n", "}", "\n", "const", "pbufMagic", "=", "1346524486", "// 4 bytes: \"PBUF\"", "\n", "magic", ":=", "binary", ".", "BigEndian", ".", "Uint32", "(", "value", "[", ":", "4", "]", ")", "\n", "if", "magic", "!=", "pbufMagic", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cell", ")", "\n", "}", "\n", "var", "regInfo", "pb", ".", "RegionInfo", "\n", "err", ":=", "proto", ".", "UnmarshalMerge", "(", "value", "[", "4", ":", "]", ",", "&", "regInfo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cell", ",", "err", ")", "\n", "}", "\n", "if", "regInfo", ".", "GetOffline", "(", ")", "{", "return", "nil", ",", "OfflineRegionError", "{", "n", ":", "string", "(", "cell", ".", "Row", ")", "}", "\n", "}", "\n", "var", "namespace", "[", "]", "byte", "\n", "if", "!", "bytes", ".", "Equal", "(", "regInfo", ".", "TableName", ".", "Namespace", ",", "defaultNamespace", ")", "{", "// if default namespace, pretend there's no namespace", "namespace", "=", "regInfo", ".", "TableName", ".", "Namespace", "\n", "}", "\n\n", "return", "NewInfo", "(", "regInfo", ".", "GetRegionId", "(", ")", ",", "namespace", ",", "regInfo", ".", "TableName", ".", "Qualifier", ",", "cell", ".", "Row", ",", "regInfo", ".", "StartKey", ",", "regInfo", ".", "EndKey", ",", ")", ",", "nil", "\n", "}" ]
// infoFromCell parses a KeyValue from the meta table and creates the // corresponding Info object.
[ "infoFromCell", "parses", "a", "KeyValue", "from", "the", "meta", "table", "and", "creates", "the", "corresponding", "Info", "object", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L74-L108
151,979
tsuna/gohbase
region/info.go
IsUnavailable
func (i *info) IsUnavailable() bool { i.m.RLock() res := i.available != nil i.m.RUnlock() return res }
go
func (i *info) IsUnavailable() bool { i.m.RLock() res := i.available != nil i.m.RUnlock() return res }
[ "func", "(", "i", "*", "info", ")", "IsUnavailable", "(", ")", "bool", "{", "i", ".", "m", ".", "RLock", "(", ")", "\n", "res", ":=", "i", ".", "available", "!=", "nil", "\n", "i", ".", "m", ".", "RUnlock", "(", ")", "\n", "return", "res", "\n", "}" ]
// IsUnavailable returns true if this region has been marked as unavailable.
[ "IsUnavailable", "returns", "true", "if", "this", "region", "has", "been", "marked", "as", "unavailable", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L150-L155
151,980
tsuna/gohbase
region/info.go
AvailabilityChan
func (i *info) AvailabilityChan() <-chan struct{} { i.m.RLock() ch := i.available i.m.RUnlock() return ch }
go
func (i *info) AvailabilityChan() <-chan struct{} { i.m.RLock() ch := i.available i.m.RUnlock() return ch }
[ "func", "(", "i", "*", "info", ")", "AvailabilityChan", "(", ")", "<-", "chan", "struct", "{", "}", "{", "i", ".", "m", ".", "RLock", "(", ")", "\n", "ch", ":=", "i", ".", "available", "\n", "i", ".", "m", ".", "RUnlock", "(", ")", "\n", "return", "ch", "\n", "}" ]
// AvailabilityChan returns a channel that can be used to wait on for // notification that a connection to this region has been reestablished. // If this region is not marked as unavailable, nil will be returned.
[ "AvailabilityChan", "returns", "a", "channel", "that", "can", "be", "used", "to", "wait", "on", "for", "notification", "that", "a", "connection", "to", "this", "region", "has", "been", "reestablished", ".", "If", "this", "region", "is", "not", "marked", "as", "unavailable", "nil", "will", "be", "returned", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L160-L165
151,981
tsuna/gohbase
region/info.go
MarkUnavailable
func (i *info) MarkUnavailable() bool { created := false i.m.Lock() if i.available == nil { i.available = make(chan struct{}) created = true } i.m.Unlock() return created }
go
func (i *info) MarkUnavailable() bool { created := false i.m.Lock() if i.available == nil { i.available = make(chan struct{}) created = true } i.m.Unlock() return created }
[ "func", "(", "i", "*", "info", ")", "MarkUnavailable", "(", ")", "bool", "{", "created", ":=", "false", "\n", "i", ".", "m", ".", "Lock", "(", ")", "\n", "if", "i", ".", "available", "==", "nil", "{", "i", ".", "available", "=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "created", "=", "true", "\n", "}", "\n", "i", ".", "m", ".", "Unlock", "(", ")", "\n", "return", "created", "\n", "}" ]
// MarkUnavailable will mark this region as unavailable, by creating the struct // returned by AvailabilityChan. If this region was marked as available // before this, true will be returned.
[ "MarkUnavailable", "will", "mark", "this", "region", "as", "unavailable", "by", "creating", "the", "struct", "returned", "by", "AvailabilityChan", ".", "If", "this", "region", "was", "marked", "as", "available", "before", "this", "true", "will", "be", "returned", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L170-L179
151,982
tsuna/gohbase
region/info.go
MarkAvailable
func (i *info) MarkAvailable() { i.m.Lock() ch := i.available i.available = nil close(ch) i.m.Unlock() }
go
func (i *info) MarkAvailable() { i.m.Lock() ch := i.available i.available = nil close(ch) i.m.Unlock() }
[ "func", "(", "i", "*", "info", ")", "MarkAvailable", "(", ")", "{", "i", ".", "m", ".", "Lock", "(", ")", "\n", "ch", ":=", "i", ".", "available", "\n", "i", ".", "available", "=", "nil", "\n", "close", "(", "ch", ")", "\n", "i", ".", "m", ".", "Unlock", "(", ")", "\n", "}" ]
// MarkAvailable will mark this region as available again, by closing the struct // returned by AvailabilityChan
[ "MarkAvailable", "will", "mark", "this", "region", "as", "available", "again", "by", "closing", "the", "struct", "returned", "by", "AvailabilityChan" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L183-L189
151,983
tsuna/gohbase
region/info.go
Client
func (i *info) Client() hrpc.RegionClient { i.m.RLock() c := i.client i.m.RUnlock() return c }
go
func (i *info) Client() hrpc.RegionClient { i.m.RLock() c := i.client i.m.RUnlock() return c }
[ "func", "(", "i", "*", "info", ")", "Client", "(", ")", "hrpc", ".", "RegionClient", "{", "i", ".", "m", ".", "RLock", "(", ")", "\n", "c", ":=", "i", ".", "client", "\n", "i", ".", "m", ".", "RUnlock", "(", ")", "\n", "return", "c", "\n", "}" ]
// Client returns region client
[ "Client", "returns", "region", "client" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L239-L244
151,984
tsuna/gohbase
region/info.go
SetClient
func (i *info) SetClient(c hrpc.RegionClient) { i.m.Lock() i.client = c i.m.Unlock() }
go
func (i *info) SetClient(c hrpc.RegionClient) { i.m.Lock() i.client = c i.m.Unlock() }
[ "func", "(", "i", "*", "info", ")", "SetClient", "(", "c", "hrpc", ".", "RegionClient", ")", "{", "i", ".", "m", ".", "Lock", "(", ")", "\n", "i", ".", "client", "=", "c", "\n", "i", ".", "m", ".", "Unlock", "(", ")", "\n", "}" ]
// SetClient sets region client
[ "SetClient", "sets", "region", "client" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/region/info.go#L247-L251
151,985
tsuna/gohbase
hrpc/procedure.go
NewGetProcedureState
func NewGetProcedureState(ctx context.Context, procID uint64) *GetProcedureState { return &GetProcedureState{ base: base{ ctx: ctx, resultch: make(chan RPCResult, 1), }, procID: procID, } }
go
func NewGetProcedureState(ctx context.Context, procID uint64) *GetProcedureState { return &GetProcedureState{ base: base{ ctx: ctx, resultch: make(chan RPCResult, 1), }, procID: procID, } }
[ "func", "NewGetProcedureState", "(", "ctx", "context", ".", "Context", ",", "procID", "uint64", ")", "*", "GetProcedureState", "{", "return", "&", "GetProcedureState", "{", "base", ":", "base", "{", "ctx", ":", "ctx", ",", "resultch", ":", "make", "(", "chan", "RPCResult", ",", "1", ")", ",", "}", ",", "procID", ":", "procID", ",", "}", "\n", "}" ]
// NewGetProcedureState creates a new GetProcedureState request. For use by the admin client.
[ "NewGetProcedureState", "creates", "a", "new", "GetProcedureState", "request", ".", "For", "use", "by", "the", "admin", "client", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/procedure.go#L23-L31
151,986
tsuna/gohbase
client.go
ZookeeperTimeout
func ZookeeperTimeout(to time.Duration) Option { return func(c *client) { c.zkTimeout = to } }
go
func ZookeeperTimeout(to time.Duration) Option { return func(c *client) { c.zkTimeout = to } }
[ "func", "ZookeeperTimeout", "(", "to", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "client", ")", "{", "c", ".", "zkTimeout", "=", "to", "\n", "}", "\n", "}" ]
// ZookeeperTimeout will return an option that will set the zookeeper session timeout.
[ "ZookeeperTimeout", "will", "return", "an", "option", "that", "will", "set", "the", "zookeeper", "session", "timeout", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/client.go#L165-L169
151,987
tsuna/gohbase
client.go
RegionLookupTimeout
func RegionLookupTimeout(to time.Duration) Option { return func(c *client) { c.regionLookupTimeout = to } }
go
func RegionLookupTimeout(to time.Duration) Option { return func(c *client) { c.regionLookupTimeout = to } }
[ "func", "RegionLookupTimeout", "(", "to", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "client", ")", "{", "c", ".", "regionLookupTimeout", "=", "to", "\n", "}", "\n", "}" ]
// RegionLookupTimeout will return an option that sets the region lookup timeout
[ "RegionLookupTimeout", "will", "return", "an", "option", "that", "sets", "the", "region", "lookup", "timeout" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/client.go#L172-L176
151,988
tsuna/gohbase
client.go
RegionReadTimeout
func RegionReadTimeout(to time.Duration) Option { return func(c *client) { c.regionReadTimeout = to } }
go
func RegionReadTimeout(to time.Duration) Option { return func(c *client) { c.regionReadTimeout = to } }
[ "func", "RegionReadTimeout", "(", "to", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "client", ")", "{", "c", ".", "regionReadTimeout", "=", "to", "\n", "}", "\n", "}" ]
// RegionReadTimeout will return an option that sets the region read timeout
[ "RegionReadTimeout", "will", "return", "an", "option", "that", "sets", "the", "region", "read", "timeout" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/client.go#L179-L183
151,989
tsuna/gohbase
client.go
FlushInterval
func FlushInterval(interval time.Duration) Option { return func(c *client) { c.flushInterval = interval } }
go
func FlushInterval(interval time.Duration) Option { return func(c *client) { c.flushInterval = interval } }
[ "func", "FlushInterval", "(", "interval", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "client", ")", "{", "c", ".", "flushInterval", "=", "interval", "\n", "}", "\n", "}" ]
// FlushInterval will return an option that will set the timeout for flushing // the RPC queues used in a given client
[ "FlushInterval", "will", "return", "an", "option", "that", "will", "set", "the", "timeout", "for", "flushing", "the", "RPC", "queues", "used", "in", "a", "given", "client" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/client.go#L194-L198
151,990
tsuna/gohbase
client.go
Close
func (c *client) Close() { c.closeOnce.Do(func() { close(c.done) if c.clientType == adminClient { if ac := c.adminRegionInfo.Client(); ac != nil { ac.Close() } } c.clients.closeAll() }) }
go
func (c *client) Close() { c.closeOnce.Do(func() { close(c.done) if c.clientType == adminClient { if ac := c.adminRegionInfo.Client(); ac != nil { ac.Close() } } c.clients.closeAll() }) }
[ "func", "(", "c", "*", "client", ")", "Close", "(", ")", "{", "c", ".", "closeOnce", ".", "Do", "(", "func", "(", ")", "{", "close", "(", "c", ".", "done", ")", "\n", "if", "c", ".", "clientType", "==", "adminClient", "{", "if", "ac", ":=", "c", ".", "adminRegionInfo", ".", "Client", "(", ")", ";", "ac", "!=", "nil", "{", "ac", ".", "Close", "(", ")", "\n", "}", "\n", "}", "\n", "c", ".", "clients", ".", "closeAll", "(", ")", "\n", "}", ")", "\n", "}" ]
// Close closes connections to hbase master and regionservers
[ "Close", "closes", "connections", "to", "hbase", "master", "and", "regionservers" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/client.go#L201-L211
151,991
tsuna/gohbase
hrpc/disable.go
NewDisableTable
func NewDisableTable(ctx context.Context, table []byte) *DisableTable { return &DisableTable{ base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, } }
go
func NewDisableTable(ctx context.Context, table []byte) *DisableTable { return &DisableTable{ base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, } }
[ "func", "NewDisableTable", "(", "ctx", "context", ".", "Context", ",", "table", "[", "]", "byte", ")", "*", "DisableTable", "{", "return", "&", "DisableTable", "{", "base", "{", "table", ":", "table", ",", "ctx", ":", "ctx", ",", "resultch", ":", "make", "(", "chan", "RPCResult", ",", "1", ")", ",", "}", ",", "}", "\n", "}" ]
// NewDisableTable creates a new DisableTable request that will disable the // given table in HBase. For use by the admin client.
[ "NewDisableTable", "creates", "a", "new", "DisableTable", "request", "that", "will", "disable", "the", "given", "table", "in", "HBase", ".", "For", "use", "by", "the", "admin", "client", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/disable.go#L22-L30
151,992
tsuna/gohbase
hrpc/create.go
NewCreateTable
func NewCreateTable(ctx context.Context, table []byte, families map[string]map[string]string, options ...func(*CreateTable)) *CreateTable { ct := &CreateTable{ base: base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, families: make(map[string]map[string]string, len(families)), } for _, option := range options { option(ct) } for family, attrs := range families { ct.families[family] = make(map[string]string, len(defaultAttributes)) for k, dv := range defaultAttributes { if v, ok := attrs[k]; ok { ct.families[family][k] = v } else { ct.families[family][k] = dv } } } return ct }
go
func NewCreateTable(ctx context.Context, table []byte, families map[string]map[string]string, options ...func(*CreateTable)) *CreateTable { ct := &CreateTable{ base: base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, families: make(map[string]map[string]string, len(families)), } for _, option := range options { option(ct) } for family, attrs := range families { ct.families[family] = make(map[string]string, len(defaultAttributes)) for k, dv := range defaultAttributes { if v, ok := attrs[k]; ok { ct.families[family][k] = v } else { ct.families[family][k] = dv } } } return ct }
[ "func", "NewCreateTable", "(", "ctx", "context", ".", "Context", ",", "table", "[", "]", "byte", ",", "families", "map", "[", "string", "]", "map", "[", "string", "]", "string", ",", "options", "...", "func", "(", "*", "CreateTable", ")", ")", "*", "CreateTable", "{", "ct", ":=", "&", "CreateTable", "{", "base", ":", "base", "{", "table", ":", "table", ",", "ctx", ":", "ctx", ",", "resultch", ":", "make", "(", "chan", "RPCResult", ",", "1", ")", ",", "}", ",", "families", ":", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", "string", ",", "len", "(", "families", ")", ")", ",", "}", "\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "ct", ")", "\n", "}", "\n", "for", "family", ",", "attrs", ":=", "range", "families", "{", "ct", ".", "families", "[", "family", "]", "=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "defaultAttributes", ")", ")", "\n", "for", "k", ",", "dv", ":=", "range", "defaultAttributes", "{", "if", "v", ",", "ok", ":=", "attrs", "[", "k", "]", ";", "ok", "{", "ct", ".", "families", "[", "family", "]", "[", "k", "]", "=", "v", "\n", "}", "else", "{", "ct", ".", "families", "[", "family", "]", "[", "k", "]", "=", "dv", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "ct", "\n", "}" ]
// NewCreateTable creates a new CreateTable request that will create the given // table in HBase. 'families' is a map of column family name to its attributes. // For use by the admin client.
[ "NewCreateTable", "creates", "a", "new", "CreateTable", "request", "that", "will", "create", "the", "given", "table", "in", "HBase", ".", "families", "is", "a", "map", "of", "column", "family", "name", "to", "its", "attributes", ".", "For", "use", "by", "the", "admin", "client", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/create.go#L40-L65
151,993
tsuna/gohbase
hrpc/delete.go
NewDeleteTable
func NewDeleteTable(ctx context.Context, table []byte) *DeleteTable { return &DeleteTable{ base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, } }
go
func NewDeleteTable(ctx context.Context, table []byte) *DeleteTable { return &DeleteTable{ base{ table: table, ctx: ctx, resultch: make(chan RPCResult, 1), }, } }
[ "func", "NewDeleteTable", "(", "ctx", "context", ".", "Context", ",", "table", "[", "]", "byte", ")", "*", "DeleteTable", "{", "return", "&", "DeleteTable", "{", "base", "{", "table", ":", "table", ",", "ctx", ":", "ctx", ",", "resultch", ":", "make", "(", "chan", "RPCResult", ",", "1", ")", ",", "}", ",", "}", "\n", "}" ]
// NewDeleteTable creates a new DeleteTable request that will delete the // given table in HBase. For use by the admin client.
[ "NewDeleteTable", "creates", "a", "new", "DeleteTable", "request", "that", "will", "delete", "the", "given", "table", "in", "HBase", ".", "For", "use", "by", "the", "admin", "client", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/delete.go#L22-L30
151,994
tsuna/gohbase
hrpc/call.go
cellFromCellBlock
func cellFromCellBlock(b []byte) (*pb.Cell, uint32, error) { if len(b) < 4 { return nil, 0, fmt.Errorf( "buffer is too small: expected %d, got %d", 4, len(b)) } kvLen := binary.BigEndian.Uint32(b[0:4]) if len(b) < int(kvLen)+4 { return nil, 0, fmt.Errorf( "buffer is too small: expected %d, got %d", int(kvLen)+4, len(b)) } rowKeyLen := binary.BigEndian.Uint32(b[4:8]) valueLen := binary.BigEndian.Uint32(b[8:12]) keyLen := binary.BigEndian.Uint16(b[12:14]) b = b[14:] key := b[:keyLen] b = b[keyLen:] familyLen := uint8(b[0]) b = b[1:] family := b[:familyLen] b = b[familyLen:] qualifierLen := rowKeyLen - uint32(keyLen) - uint32(familyLen) - 2 - 1 - 8 - 1 if 4 /*rowKeyLen*/ +4 /*valueLen*/ +2 /*keyLen*/ + uint32(keyLen)+1 /*familyLen*/ +uint32(familyLen)+qualifierLen+ 8 /*timestamp*/ +1 /*cellType*/ +valueLen != kvLen { return nil, 0, fmt.Errorf("HBase has lied about KeyValue length: expected %d, got %d", kvLen, 4+4+2+uint32(keyLen)+1+uint32(familyLen)+qualifierLen+8+1+valueLen) } qualifier := b[:qualifierLen] b = b[qualifierLen:] timestamp := binary.BigEndian.Uint64(b[:8]) b = b[8:] cellType := uint8(b[0]) b = b[1:] value := b[:valueLen] return &pb.Cell{ Row: key, Family: family, Qualifier: qualifier, Timestamp: &timestamp, Value: value, CellType: pb.CellType(cellType).Enum(), }, kvLen + 4, nil }
go
func cellFromCellBlock(b []byte) (*pb.Cell, uint32, error) { if len(b) < 4 { return nil, 0, fmt.Errorf( "buffer is too small: expected %d, got %d", 4, len(b)) } kvLen := binary.BigEndian.Uint32(b[0:4]) if len(b) < int(kvLen)+4 { return nil, 0, fmt.Errorf( "buffer is too small: expected %d, got %d", int(kvLen)+4, len(b)) } rowKeyLen := binary.BigEndian.Uint32(b[4:8]) valueLen := binary.BigEndian.Uint32(b[8:12]) keyLen := binary.BigEndian.Uint16(b[12:14]) b = b[14:] key := b[:keyLen] b = b[keyLen:] familyLen := uint8(b[0]) b = b[1:] family := b[:familyLen] b = b[familyLen:] qualifierLen := rowKeyLen - uint32(keyLen) - uint32(familyLen) - 2 - 1 - 8 - 1 if 4 /*rowKeyLen*/ +4 /*valueLen*/ +2 /*keyLen*/ + uint32(keyLen)+1 /*familyLen*/ +uint32(familyLen)+qualifierLen+ 8 /*timestamp*/ +1 /*cellType*/ +valueLen != kvLen { return nil, 0, fmt.Errorf("HBase has lied about KeyValue length: expected %d, got %d", kvLen, 4+4+2+uint32(keyLen)+1+uint32(familyLen)+qualifierLen+8+1+valueLen) } qualifier := b[:qualifierLen] b = b[qualifierLen:] timestamp := binary.BigEndian.Uint64(b[:8]) b = b[8:] cellType := uint8(b[0]) b = b[1:] value := b[:valueLen] return &pb.Cell{ Row: key, Family: family, Qualifier: qualifier, Timestamp: &timestamp, Value: value, CellType: pb.CellType(cellType).Enum(), }, kvLen + 4, nil }
[ "func", "cellFromCellBlock", "(", "b", "[", "]", "byte", ")", "(", "*", "pb", ".", "Cell", ",", "uint32", ",", "error", ")", "{", "if", "len", "(", "b", ")", "<", "4", "{", "return", "nil", ",", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "4", ",", "len", "(", "b", ")", ")", "\n", "}", "\n\n", "kvLen", ":=", "binary", ".", "BigEndian", ".", "Uint32", "(", "b", "[", "0", ":", "4", "]", ")", "\n", "if", "len", "(", "b", ")", "<", "int", "(", "kvLen", ")", "+", "4", "{", "return", "nil", ",", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "int", "(", "kvLen", ")", "+", "4", ",", "len", "(", "b", ")", ")", "\n", "}", "\n\n", "rowKeyLen", ":=", "binary", ".", "BigEndian", ".", "Uint32", "(", "b", "[", "4", ":", "8", "]", ")", "\n", "valueLen", ":=", "binary", ".", "BigEndian", ".", "Uint32", "(", "b", "[", "8", ":", "12", "]", ")", "\n", "keyLen", ":=", "binary", ".", "BigEndian", ".", "Uint16", "(", "b", "[", "12", ":", "14", "]", ")", "\n", "b", "=", "b", "[", "14", ":", "]", "\n\n", "key", ":=", "b", "[", ":", "keyLen", "]", "\n", "b", "=", "b", "[", "keyLen", ":", "]", "\n\n", "familyLen", ":=", "uint8", "(", "b", "[", "0", "]", ")", "\n", "b", "=", "b", "[", "1", ":", "]", "\n\n", "family", ":=", "b", "[", ":", "familyLen", "]", "\n", "b", "=", "b", "[", "familyLen", ":", "]", "\n\n", "qualifierLen", ":=", "rowKeyLen", "-", "uint32", "(", "keyLen", ")", "-", "uint32", "(", "familyLen", ")", "-", "2", "-", "1", "-", "8", "-", "1", "\n", "if", "4", "/*rowKeyLen*/", "+", "4", "/*valueLen*/", "+", "2", "/*keyLen*/", "+", "uint32", "(", "keyLen", ")", "+", "1", "/*familyLen*/", "+", "uint32", "(", "familyLen", ")", "+", "qualifierLen", "+", "8", "/*timestamp*/", "+", "1", "/*cellType*/", "+", "valueLen", "!=", "kvLen", "{", "return", "nil", ",", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "kvLen", ",", "4", "+", "4", "+", "2", "+", "uint32", "(", "keyLen", ")", "+", "1", "+", "uint32", "(", "familyLen", ")", "+", "qualifierLen", "+", "8", "+", "1", "+", "valueLen", ")", "\n", "}", "\n", "qualifier", ":=", "b", "[", ":", "qualifierLen", "]", "\n", "b", "=", "b", "[", "qualifierLen", ":", "]", "\n\n", "timestamp", ":=", "binary", ".", "BigEndian", ".", "Uint64", "(", "b", "[", ":", "8", "]", ")", "\n", "b", "=", "b", "[", "8", ":", "]", "\n\n", "cellType", ":=", "uint8", "(", "b", "[", "0", "]", ")", "\n", "b", "=", "b", "[", "1", ":", "]", "\n\n", "value", ":=", "b", "[", ":", "valueLen", "]", "\n\n", "return", "&", "pb", ".", "Cell", "{", "Row", ":", "key", ",", "Family", ":", "family", ",", "Qualifier", ":", "qualifier", ",", "Timestamp", ":", "&", "timestamp", ",", "Value", ":", "value", ",", "CellType", ":", "pb", ".", "CellType", "(", "cellType", ")", ".", "Enum", "(", ")", ",", "}", ",", "kvLen", "+", "4", ",", "nil", "\n", "}" ]
// cellFromCellBlock deserializes a cell from a reader
[ "cellFromCellBlock", "deserializes", "a", "cell", "from", "a", "reader" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/call.go#L176-L228
151,995
tsuna/gohbase
hrpc/call.go
ToLocalResult
func ToLocalResult(pbr *pb.Result) *Result { if pbr == nil { return &Result{} } return &Result{ // Should all be O(1) operations. Cells: toLocalCells(pbr), Stale: extractBool(pbr.Stale), Partial: extractBool(pbr.Partial), Exists: pbr.Exists, } }
go
func ToLocalResult(pbr *pb.Result) *Result { if pbr == nil { return &Result{} } return &Result{ // Should all be O(1) operations. Cells: toLocalCells(pbr), Stale: extractBool(pbr.Stale), Partial: extractBool(pbr.Partial), Exists: pbr.Exists, } }
[ "func", "ToLocalResult", "(", "pbr", "*", "pb", ".", "Result", ")", "*", "Result", "{", "if", "pbr", "==", "nil", "{", "return", "&", "Result", "{", "}", "\n", "}", "\n", "return", "&", "Result", "{", "// Should all be O(1) operations.", "Cells", ":", "toLocalCells", "(", "pbr", ")", ",", "Stale", ":", "extractBool", "(", "pbr", ".", "Stale", ")", ",", "Partial", ":", "extractBool", "(", "pbr", ".", "Partial", ")", ",", "Exists", ":", "pbr", ".", "Exists", ",", "}", "\n", "}" ]
// ToLocalResult takes a protobuf Result type and converts it to our own // Result type in constant time.
[ "ToLocalResult", "takes", "a", "protobuf", "Result", "type", "and", "converts", "it", "to", "our", "own", "Result", "type", "in", "constant", "time", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/hrpc/call.go#L259-L270
151,996
tsuna/gohbase
caches.go
put
func (krc *keyRegionCache) put(reg hrpc.RegionInfo) (overlaps []hrpc.RegionInfo, replaced bool) { krc.m.Lock() krc.regions.Put(reg.Name(), func(v interface{}, exists bool) (interface{}, bool) { if exists { // region is already in cache, // note: regions with the same name have the same age overlaps = []hrpc.RegionInfo{v.(hrpc.RegionInfo)} return nil, false } // find all entries that are overlapping with the range of the new region. overlaps = krc.getOverlaps(reg) for _, o := range overlaps { if o.ID() > reg.ID() { // overlapping region is younger, // don't replace any regions // TODO: figure out if there can a case where we might // have both older and younger overlapping regions, for // now we only replace if all overlaps are older return nil, false } } // all overlaps are older, put the new region replaced = true return reg, true }) if !replaced { krc.m.Unlock() log.WithFields(log.Fields{ "region": reg, "overlaps": overlaps, "replaced": replaced, }).Debug("region is already in cache") return } // delete overlapping regions // TODO: in case overlaps are always either younger or older, // we can just greedily remove them in Put function for _, o := range overlaps { krc.regions.Delete(o.Name()) // let region establishers know that they can give up o.MarkDead() } krc.m.Unlock() log.WithFields(log.Fields{ "region": reg, "overlaps": overlaps, "replaced": replaced, }).Info("added new region") return }
go
func (krc *keyRegionCache) put(reg hrpc.RegionInfo) (overlaps []hrpc.RegionInfo, replaced bool) { krc.m.Lock() krc.regions.Put(reg.Name(), func(v interface{}, exists bool) (interface{}, bool) { if exists { // region is already in cache, // note: regions with the same name have the same age overlaps = []hrpc.RegionInfo{v.(hrpc.RegionInfo)} return nil, false } // find all entries that are overlapping with the range of the new region. overlaps = krc.getOverlaps(reg) for _, o := range overlaps { if o.ID() > reg.ID() { // overlapping region is younger, // don't replace any regions // TODO: figure out if there can a case where we might // have both older and younger overlapping regions, for // now we only replace if all overlaps are older return nil, false } } // all overlaps are older, put the new region replaced = true return reg, true }) if !replaced { krc.m.Unlock() log.WithFields(log.Fields{ "region": reg, "overlaps": overlaps, "replaced": replaced, }).Debug("region is already in cache") return } // delete overlapping regions // TODO: in case overlaps are always either younger or older, // we can just greedily remove them in Put function for _, o := range overlaps { krc.regions.Delete(o.Name()) // let region establishers know that they can give up o.MarkDead() } krc.m.Unlock() log.WithFields(log.Fields{ "region": reg, "overlaps": overlaps, "replaced": replaced, }).Info("added new region") return }
[ "func", "(", "krc", "*", "keyRegionCache", ")", "put", "(", "reg", "hrpc", ".", "RegionInfo", ")", "(", "overlaps", "[", "]", "hrpc", ".", "RegionInfo", ",", "replaced", "bool", ")", "{", "krc", ".", "m", ".", "Lock", "(", ")", "\n", "krc", ".", "regions", ".", "Put", "(", "reg", ".", "Name", "(", ")", ",", "func", "(", "v", "interface", "{", "}", ",", "exists", "bool", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "if", "exists", "{", "// region is already in cache,", "// note: regions with the same name have the same age", "overlaps", "=", "[", "]", "hrpc", ".", "RegionInfo", "{", "v", ".", "(", "hrpc", ".", "RegionInfo", ")", "}", "\n", "return", "nil", ",", "false", "\n", "}", "\n", "// find all entries that are overlapping with the range of the new region.", "overlaps", "=", "krc", ".", "getOverlaps", "(", "reg", ")", "\n", "for", "_", ",", "o", ":=", "range", "overlaps", "{", "if", "o", ".", "ID", "(", ")", ">", "reg", ".", "ID", "(", ")", "{", "// overlapping region is younger,", "// don't replace any regions", "// TODO: figure out if there can a case where we might", "// have both older and younger overlapping regions, for", "// now we only replace if all overlaps are older", "return", "nil", ",", "false", "\n", "}", "\n", "}", "\n", "// all overlaps are older, put the new region", "replaced", "=", "true", "\n", "return", "reg", ",", "true", "\n", "}", ")", "\n", "if", "!", "replaced", "{", "krc", ".", "m", ".", "Unlock", "(", ")", "\n\n", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "reg", ",", "\"", "\"", ":", "overlaps", ",", "\"", "\"", ":", "replaced", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "// delete overlapping regions", "// TODO: in case overlaps are always either younger or older,", "// we can just greedily remove them in Put function", "for", "_", ",", "o", ":=", "range", "overlaps", "{", "krc", ".", "regions", ".", "Delete", "(", "o", ".", "Name", "(", ")", ")", "\n", "// let region establishers know that they can give up", "o", ".", "MarkDead", "(", ")", "\n", "}", "\n", "krc", ".", "m", ".", "Unlock", "(", ")", "\n\n", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "reg", ",", "\"", "\"", ":", "overlaps", ",", "\"", "\"", ":", "replaced", ",", "}", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "\n", "}" ]
// put looks up if there's already region with this name in regions cache // and if there's, returns it in overlaps and doesn't modify the cache. // Otherwise, it puts the region and removes all overlaps in case all of // them are older. Returns a slice of overlapping regions and whether // passed region was put in the cache.
[ "put", "looks", "up", "if", "there", "s", "already", "region", "with", "this", "name", "in", "regions", "cache", "and", "if", "there", "s", "returns", "it", "in", "overlaps", "and", "doesn", "t", "modify", "the", "cache", ".", "Otherwise", "it", "puts", "the", "region", "and", "removes", "all", "overlaps", "in", "case", "all", "of", "them", "are", "older", ".", "Returns", "a", "slice", "of", "overlapping", "regions", "and", "whether", "passed", "region", "was", "put", "in", "the", "cache", "." ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/caches.go#L211-L262
151,997
tsuna/gohbase
scanner.go
coalesce
func (s *scanner) coalesce(result, partial *pb.Result) (*pb.Result, bool) { if result == nil { return partial, true } if !result.GetPartial() { // results is not partial, shouldn't coalesce return result, false } if len(partial.Cell) > 0 && !bytes.Equal(result.Cell[0].Row, partial.Cell[0].Row) { // new row result.Partial = proto.Bool(false) return result, false } // same row, add the partial result.Cell = append(result.Cell, partial.Cell...) if partial.GetStale() { result.Stale = proto.Bool(partial.GetStale()) } return result, true }
go
func (s *scanner) coalesce(result, partial *pb.Result) (*pb.Result, bool) { if result == nil { return partial, true } if !result.GetPartial() { // results is not partial, shouldn't coalesce return result, false } if len(partial.Cell) > 0 && !bytes.Equal(result.Cell[0].Row, partial.Cell[0].Row) { // new row result.Partial = proto.Bool(false) return result, false } // same row, add the partial result.Cell = append(result.Cell, partial.Cell...) if partial.GetStale() { result.Stale = proto.Bool(partial.GetStale()) } return result, true }
[ "func", "(", "s", "*", "scanner", ")", "coalesce", "(", "result", ",", "partial", "*", "pb", ".", "Result", ")", "(", "*", "pb", ".", "Result", ",", "bool", ")", "{", "if", "result", "==", "nil", "{", "return", "partial", ",", "true", "\n", "}", "\n", "if", "!", "result", ".", "GetPartial", "(", ")", "{", "// results is not partial, shouldn't coalesce", "return", "result", ",", "false", "\n", "}", "\n\n", "if", "len", "(", "partial", ".", "Cell", ")", ">", "0", "&&", "!", "bytes", ".", "Equal", "(", "result", ".", "Cell", "[", "0", "]", ".", "Row", ",", "partial", ".", "Cell", "[", "0", "]", ".", "Row", ")", "{", "// new row", "result", ".", "Partial", "=", "proto", ".", "Bool", "(", "false", ")", "\n", "return", "result", ",", "false", "\n", "}", "\n\n", "// same row, add the partial", "result", ".", "Cell", "=", "append", "(", "result", ".", "Cell", ",", "partial", ".", "Cell", "...", ")", "\n", "if", "partial", ".", "GetStale", "(", ")", "{", "result", ".", "Stale", "=", "proto", ".", "Bool", "(", "partial", ".", "GetStale", "(", ")", ")", "\n", "}", "\n", "return", "result", ",", "true", "\n", "}" ]
// coalesce combines result with partial if they belong to the same row // and returns the coalesced result and whether coalescing happened
[ "coalesce", "combines", "result", "with", "partial", "if", "they", "belong", "to", "the", "same", "row", "and", "returns", "the", "coalesced", "result", "and", "whether", "coalescing", "happened" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/scanner.go#L118-L139
151,998
tsuna/gohbase
scanner.go
update
func (s *scanner) update(resp *pb.ScanResponse, region hrpc.RegionInfo) { if resp.GetMoreResultsInRegion() { if resp.ScannerId != nil { s.scannerID = resp.GetScannerId() } } else { // we are done with this region, prepare scan for next region s.scannerID = noScannerID // Normal Scan if !s.rpc.Reversed() { s.startRow = region.StopKey() return } // Reversed Scan // return if we are at the end if len(region.StartKey()) == 0 { s.startRow = region.StartKey() return } // create the nearest value lower than the current region startKey rsk := region.StartKey() // if last element is 0x0, just shorten the slice if rsk[len(rsk)-1] == 0x0 { s.startRow = rsk[:len(rsk)-1] return } // otherwise lower the last element byte value by 1 and pad with 0xffs tmp := make([]byte, len(rsk), len(rsk)+len(rowPadding)) copy(tmp, rsk) tmp[len(tmp)-1] = tmp[len(tmp)-1] - 1 s.startRow = append(tmp, rowPadding...) } }
go
func (s *scanner) update(resp *pb.ScanResponse, region hrpc.RegionInfo) { if resp.GetMoreResultsInRegion() { if resp.ScannerId != nil { s.scannerID = resp.GetScannerId() } } else { // we are done with this region, prepare scan for next region s.scannerID = noScannerID // Normal Scan if !s.rpc.Reversed() { s.startRow = region.StopKey() return } // Reversed Scan // return if we are at the end if len(region.StartKey()) == 0 { s.startRow = region.StartKey() return } // create the nearest value lower than the current region startKey rsk := region.StartKey() // if last element is 0x0, just shorten the slice if rsk[len(rsk)-1] == 0x0 { s.startRow = rsk[:len(rsk)-1] return } // otherwise lower the last element byte value by 1 and pad with 0xffs tmp := make([]byte, len(rsk), len(rsk)+len(rowPadding)) copy(tmp, rsk) tmp[len(tmp)-1] = tmp[len(tmp)-1] - 1 s.startRow = append(tmp, rowPadding...) } }
[ "func", "(", "s", "*", "scanner", ")", "update", "(", "resp", "*", "pb", ".", "ScanResponse", ",", "region", "hrpc", ".", "RegionInfo", ")", "{", "if", "resp", ".", "GetMoreResultsInRegion", "(", ")", "{", "if", "resp", ".", "ScannerId", "!=", "nil", "{", "s", ".", "scannerID", "=", "resp", ".", "GetScannerId", "(", ")", "\n", "}", "\n", "}", "else", "{", "// we are done with this region, prepare scan for next region", "s", ".", "scannerID", "=", "noScannerID", "\n\n", "// Normal Scan", "if", "!", "s", ".", "rpc", ".", "Reversed", "(", ")", "{", "s", ".", "startRow", "=", "region", ".", "StopKey", "(", ")", "\n", "return", "\n", "}", "\n\n", "// Reversed Scan", "// return if we are at the end", "if", "len", "(", "region", ".", "StartKey", "(", ")", ")", "==", "0", "{", "s", ".", "startRow", "=", "region", ".", "StartKey", "(", ")", "\n", "return", "\n", "}", "\n\n", "// create the nearest value lower than the current region startKey", "rsk", ":=", "region", ".", "StartKey", "(", ")", "\n", "// if last element is 0x0, just shorten the slice", "if", "rsk", "[", "len", "(", "rsk", ")", "-", "1", "]", "==", "0x0", "{", "s", ".", "startRow", "=", "rsk", "[", ":", "len", "(", "rsk", ")", "-", "1", "]", "\n", "return", "\n", "}", "\n\n", "// otherwise lower the last element byte value by 1 and pad with 0xffs", "tmp", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "rsk", ")", ",", "len", "(", "rsk", ")", "+", "len", "(", "rowPadding", ")", ")", "\n", "copy", "(", "tmp", ",", "rsk", ")", "\n", "tmp", "[", "len", "(", "tmp", ")", "-", "1", "]", "=", "tmp", "[", "len", "(", "tmp", ")", "-", "1", "]", "-", "1", "\n", "s", ".", "startRow", "=", "append", "(", "tmp", ",", "rowPadding", "...", ")", "\n", "}", "\n", "}" ]
// update updates the scanner for the next scan request
[ "update", "updates", "the", "scanner", "for", "the", "next", "scan", "request" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/scanner.go#L243-L279
151,999
tsuna/gohbase
scanner.go
shouldClose
func (s *scanner) shouldClose(resp *pb.ScanResponse, region hrpc.RegionInfo) bool { if resp.MoreResults != nil && !*resp.MoreResults { // the filter for the whole scan has been exhausted, close the scanner return true } if s.scannerID != noScannerID { // not done with this region yet return false } // Check to see if this region is the last we should scan because: // (1) it's the last region if len(region.StopKey()) == 0 && !s.rpc.Reversed() { return true } if s.rpc.Reversed() && len(region.StartKey()) == 0 { return true } // (3) because its stop_key is greater than or equal to the stop_key of this scanner, // provided that (2) we're not trying to scan until the end of the table. if !s.rpc.Reversed() { return len(s.rpc.StopRow()) != 0 && // (2) bytes.Compare(s.rpc.StopRow(), region.StopKey()) <= 0 // (3) } // Reversed Scanner return len(s.rpc.StopRow()) != 0 && // (2) bytes.Compare(s.rpc.StopRow(), region.StartKey()) >= 0 // (3) }
go
func (s *scanner) shouldClose(resp *pb.ScanResponse, region hrpc.RegionInfo) bool { if resp.MoreResults != nil && !*resp.MoreResults { // the filter for the whole scan has been exhausted, close the scanner return true } if s.scannerID != noScannerID { // not done with this region yet return false } // Check to see if this region is the last we should scan because: // (1) it's the last region if len(region.StopKey()) == 0 && !s.rpc.Reversed() { return true } if s.rpc.Reversed() && len(region.StartKey()) == 0 { return true } // (3) because its stop_key is greater than or equal to the stop_key of this scanner, // provided that (2) we're not trying to scan until the end of the table. if !s.rpc.Reversed() { return len(s.rpc.StopRow()) != 0 && // (2) bytes.Compare(s.rpc.StopRow(), region.StopKey()) <= 0 // (3) } // Reversed Scanner return len(s.rpc.StopRow()) != 0 && // (2) bytes.Compare(s.rpc.StopRow(), region.StartKey()) >= 0 // (3) }
[ "func", "(", "s", "*", "scanner", ")", "shouldClose", "(", "resp", "*", "pb", ".", "ScanResponse", ",", "region", "hrpc", ".", "RegionInfo", ")", "bool", "{", "if", "resp", ".", "MoreResults", "!=", "nil", "&&", "!", "*", "resp", ".", "MoreResults", "{", "// the filter for the whole scan has been exhausted, close the scanner", "return", "true", "\n", "}", "\n\n", "if", "s", ".", "scannerID", "!=", "noScannerID", "{", "// not done with this region yet", "return", "false", "\n", "}", "\n\n", "// Check to see if this region is the last we should scan because:", "// (1) it's the last region", "if", "len", "(", "region", ".", "StopKey", "(", ")", ")", "==", "0", "&&", "!", "s", ".", "rpc", ".", "Reversed", "(", ")", "{", "return", "true", "\n", "}", "\n", "if", "s", ".", "rpc", ".", "Reversed", "(", ")", "&&", "len", "(", "region", ".", "StartKey", "(", ")", ")", "==", "0", "{", "return", "true", "\n", "}", "\n", "// (3) because its stop_key is greater than or equal to the stop_key of this scanner,", "// provided that (2) we're not trying to scan until the end of the table.", "if", "!", "s", ".", "rpc", ".", "Reversed", "(", ")", "{", "return", "len", "(", "s", ".", "rpc", ".", "StopRow", "(", ")", ")", "!=", "0", "&&", "// (2)", "bytes", ".", "Compare", "(", "s", ".", "rpc", ".", "StopRow", "(", ")", ",", "region", ".", "StopKey", "(", ")", ")", "<=", "0", "// (3)", "\n", "}", "\n\n", "// Reversed Scanner", "return", "len", "(", "s", ".", "rpc", ".", "StopRow", "(", ")", ")", "!=", "0", "&&", "// (2)", "bytes", ".", "Compare", "(", "s", ".", "rpc", ".", "StopRow", "(", ")", ",", "region", ".", "StartKey", "(", ")", ")", ">=", "0", "// (3)", "\n", "}" ]
// shouldClose check if this scanner should be closed and should stop fetching new results
[ "shouldClose", "check", "if", "this", "scanner", "should", "be", "closed", "and", "should", "stop", "fetching", "new", "results" ]
24ffed0537aae38093b39c12781e4c09f8cb0029
https://github.com/tsuna/gohbase/blob/24ffed0537aae38093b39c12781e4c09f8cb0029/scanner.go#L282-L311