id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,100 | heroku/heroku-go | v3/heroku.go | TeamAppCollaboratorList | func (s *Service) TeamAppCollaboratorList(ctx context.Context, teamAppIdentity string, lr *ListRange) (TeamAppCollaboratorListResult, error) {
var teamAppCollaborator TeamAppCollaboratorListResult
return teamAppCollaborator, s.Get(ctx, &teamAppCollaborator, fmt.Sprintf("/teams/apps/%v/collaborators", teamAppIdentity)... | go | func (s *Service) TeamAppCollaboratorList(ctx context.Context, teamAppIdentity string, lr *ListRange) (TeamAppCollaboratorListResult, error) {
var teamAppCollaborator TeamAppCollaboratorListResult
return teamAppCollaborator, s.Get(ctx, &teamAppCollaborator, fmt.Sprintf("/teams/apps/%v/collaborators", teamAppIdentity)... | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamAppCollaboratorList",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamAppIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"TeamAppCollaboratorListResult",
",",
"error",
")",
"{",
"var",
"teamAppCollaborator... | // List collaborators on a team app. | [
"List",
"collaborators",
"on",
"a",
"team",
"app",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4287-L4290 |
20,101 | heroku/heroku-go | v3/heroku.go | TeamAppPermissionList | func (s *Service) TeamAppPermissionList(ctx context.Context, lr *ListRange) (TeamAppPermissionListResult, error) {
var teamAppPermission TeamAppPermissionListResult
return teamAppPermission, s.Get(ctx, &teamAppPermission, fmt.Sprintf("/teams/permissions"), nil, lr)
} | go | func (s *Service) TeamAppPermissionList(ctx context.Context, lr *ListRange) (TeamAppPermissionListResult, error) {
var teamAppPermission TeamAppPermissionListResult
return teamAppPermission, s.Get(ctx, &teamAppPermission, fmt.Sprintf("/teams/permissions"), nil, lr)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamAppPermissionList",
"(",
"ctx",
"context",
".",
"Context",
",",
"lr",
"*",
"ListRange",
")",
"(",
"TeamAppPermissionListResult",
",",
"error",
")",
"{",
"var",
"teamAppPermission",
"TeamAppPermissionListResult",
"\n",
... | // Lists permissions available to teams. | [
"Lists",
"permissions",
"available",
"to",
"teams",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4301-L4304 |
20,102 | heroku/heroku-go | v3/heroku.go | TeamFeatureInfo | func (s *Service) TeamFeatureInfo(ctx context.Context, teamIdentity string, teamFeatureIdentity string) (*TeamFeature, error) {
var teamFeature TeamFeature
return &teamFeature, s.Get(ctx, &teamFeature, fmt.Sprintf("/teams/%v/features/%v", teamIdentity, teamFeatureIdentity), nil, nil)
} | go | func (s *Service) TeamFeatureInfo(ctx context.Context, teamIdentity string, teamFeatureIdentity string) (*TeamFeature, error) {
var teamFeature TeamFeature
return &teamFeature, s.Get(ctx, &teamFeature, fmt.Sprintf("/teams/%v/features/%v", teamIdentity, teamFeatureIdentity), nil, nil)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamFeatureInfo",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"teamFeatureIdentity",
"string",
")",
"(",
"*",
"TeamFeature",
",",
"error",
")",
"{",
"var",
"teamFeature",
"TeamFeature",
"... | // Info for an existing team feature. | [
"Info",
"for",
"an",
"existing",
"team",
"feature",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4321-L4324 |
20,103 | heroku/heroku-go | v3/heroku.go | TeamFeatureList | func (s *Service) TeamFeatureList(ctx context.Context, teamIdentity string, lr *ListRange) (TeamFeatureListResult, error) {
var teamFeature TeamFeatureListResult
return teamFeature, s.Get(ctx, &teamFeature, fmt.Sprintf("/teams/%v/features", teamIdentity), nil, lr)
} | go | func (s *Service) TeamFeatureList(ctx context.Context, teamIdentity string, lr *ListRange) (TeamFeatureListResult, error) {
var teamFeature TeamFeatureListResult
return teamFeature, s.Get(ctx, &teamFeature, fmt.Sprintf("/teams/%v/features", teamIdentity), nil, lr)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamFeatureList",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"TeamFeatureListResult",
",",
"error",
")",
"{",
"var",
"teamFeature",
"TeamFeatureListResult... | // List existing team features. | [
"List",
"existing",
"team",
"features",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4329-L4332 |
20,104 | heroku/heroku-go | v3/heroku.go | TeamInvitationCreate | func (s *Service) TeamInvitationCreate(ctx context.Context, teamIdentity string, o TeamInvitationCreateOpts) (*TeamInvitation, error) {
var teamInvitation TeamInvitation
return &teamInvitation, s.Put(ctx, &teamInvitation, fmt.Sprintf("/teams/%v/invitations", teamIdentity), o)
} | go | func (s *Service) TeamInvitationCreate(ctx context.Context, teamIdentity string, o TeamInvitationCreateOpts) (*TeamInvitation, error) {
var teamInvitation TeamInvitation
return &teamInvitation, s.Put(ctx, &teamInvitation, fmt.Sprintf("/teams/%v/invitations", teamIdentity), o)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamInvitationCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"o",
"TeamInvitationCreateOpts",
")",
"(",
"*",
"TeamInvitation",
",",
"error",
")",
"{",
"var",
"teamInvitation",
"TeamIn... | // Create Team Invitation | [
"Create",
"Team",
"Invitation"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4369-L4372 |
20,105 | heroku/heroku-go | v3/heroku.go | TeamInvitationRevoke | func (s *Service) TeamInvitationRevoke(ctx context.Context, teamIdentity string, teamInvitationIdentity string) (*TeamInvitation, error) {
var teamInvitation TeamInvitation
return &teamInvitation, s.Delete(ctx, &teamInvitation, fmt.Sprintf("/teams/%v/invitations/%v", teamIdentity, teamInvitationIdentity))
} | go | func (s *Service) TeamInvitationRevoke(ctx context.Context, teamIdentity string, teamInvitationIdentity string) (*TeamInvitation, error) {
var teamInvitation TeamInvitation
return &teamInvitation, s.Delete(ctx, &teamInvitation, fmt.Sprintf("/teams/%v/invitations/%v", teamIdentity, teamInvitationIdentity))
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamInvitationRevoke",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"teamInvitationIdentity",
"string",
")",
"(",
"*",
"TeamInvitation",
",",
"error",
")",
"{",
"var",
"teamInvitation",
"Tea... | // Revoke a team invitation. | [
"Revoke",
"a",
"team",
"invitation",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4375-L4378 |
20,106 | heroku/heroku-go | v3/heroku.go | TeamInvitationAccept | func (s *Service) TeamInvitationAccept(ctx context.Context, teamInvitationToken string) (*TeamInvitationAcceptResult, error) {
var teamInvitation TeamInvitationAcceptResult
return &teamInvitation, s.Post(ctx, &teamInvitation, fmt.Sprintf("/teams/invitations/%v/accept", teamInvitationToken), nil)
} | go | func (s *Service) TeamInvitationAccept(ctx context.Context, teamInvitationToken string) (*TeamInvitationAcceptResult, error) {
var teamInvitation TeamInvitationAcceptResult
return &teamInvitation, s.Post(ctx, &teamInvitation, fmt.Sprintf("/teams/invitations/%v/accept", teamInvitationToken), nil)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamInvitationAccept",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamInvitationToken",
"string",
")",
"(",
"*",
"TeamInvitationAcceptResult",
",",
"error",
")",
"{",
"var",
"teamInvitation",
"TeamInvitationAcceptResult",
... | // Accept Team Invitation | [
"Accept",
"Team",
"Invitation"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4403-L4406 |
20,107 | heroku/heroku-go | v3/heroku.go | TeamMemberCreateOrUpdate | func (s *Service) TeamMemberCreateOrUpdate(ctx context.Context, teamIdentity string, o TeamMemberCreateOrUpdateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Put(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | go | func (s *Service) TeamMemberCreateOrUpdate(ctx context.Context, teamIdentity string, o TeamMemberCreateOrUpdateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Put(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamMemberCreateOrUpdate",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"o",
"TeamMemberCreateOrUpdateOpts",
")",
"(",
"*",
"TeamMember",
",",
"error",
")",
"{",
"var",
"teamMember",
"TeamMe... | // Create a new team member, or update their role. | [
"Create",
"a",
"new",
"team",
"member",
"or",
"update",
"their",
"role",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4466-L4469 |
20,108 | heroku/heroku-go | v3/heroku.go | TeamMemberCreate | func (s *Service) TeamMemberCreate(ctx context.Context, teamIdentity string, o TeamMemberCreateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Post(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | go | func (s *Service) TeamMemberCreate(ctx context.Context, teamIdentity string, o TeamMemberCreateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Post(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamMemberCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"o",
"TeamMemberCreateOpts",
")",
"(",
"*",
"TeamMember",
",",
"error",
")",
"{",
"var",
"teamMember",
"TeamMember",
"\n",
... | // Create a new team member. | [
"Create",
"a",
"new",
"team",
"member",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4478-L4481 |
20,109 | heroku/heroku-go | v3/heroku.go | TeamMemberUpdate | func (s *Service) TeamMemberUpdate(ctx context.Context, teamIdentity string, o TeamMemberUpdateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Patch(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | go | func (s *Service) TeamMemberUpdate(ctx context.Context, teamIdentity string, o TeamMemberUpdateOpts) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Patch(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamMemberUpdate",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"o",
"TeamMemberUpdateOpts",
")",
"(",
"*",
"TeamMember",
",",
"error",
")",
"{",
"var",
"teamMember",
"TeamMember",
"\n",
... | // Update a team member. | [
"Update",
"a",
"team",
"member",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4490-L4493 |
20,110 | heroku/heroku-go | v3/heroku.go | TeamMemberDelete | func (s *Service) TeamMemberDelete(ctx context.Context, teamIdentity string, teamMemberIdentity string) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Delete(ctx, &teamMember, fmt.Sprintf("/teams/%v/members/%v", teamIdentity, teamMemberIdentity))
} | go | func (s *Service) TeamMemberDelete(ctx context.Context, teamIdentity string, teamMemberIdentity string) (*TeamMember, error) {
var teamMember TeamMember
return &teamMember, s.Delete(ctx, &teamMember, fmt.Sprintf("/teams/%v/members/%v", teamIdentity, teamMemberIdentity))
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamMemberDelete",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"teamMemberIdentity",
"string",
")",
"(",
"*",
"TeamMember",
",",
"error",
")",
"{",
"var",
"teamMember",
"TeamMember",
"\n"... | // Remove a member from the team. | [
"Remove",
"a",
"member",
"from",
"the",
"team",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4496-L4499 |
20,111 | heroku/heroku-go | v3/heroku.go | TeamMemberList | func (s *Service) TeamMemberList(ctx context.Context, teamIdentity string, lr *ListRange) (TeamMemberListResult, error) {
var teamMember TeamMemberListResult
return teamMember, s.Get(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), nil, lr)
} | go | func (s *Service) TeamMemberList(ctx context.Context, teamIdentity string, lr *ListRange) (TeamMemberListResult, error) {
var teamMember TeamMemberListResult
return teamMember, s.Get(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), nil, lr)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamMemberList",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"TeamMemberListResult",
",",
"error",
")",
"{",
"var",
"teamMember",
"TeamMemberListResult",
... | // List members of the team. | [
"List",
"members",
"of",
"the",
"team",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4504-L4507 |
20,112 | heroku/heroku-go | v3/heroku.go | TeamMemberListByMember | func (s *Service) TeamMemberListByMember(ctx context.Context, teamIdentity string, teamMemberIdentity string, lr *ListRange) (TeamMemberListByMemberResult, error) {
var teamMember TeamMemberListByMemberResult
return teamMember, s.Get(ctx, &teamMember, fmt.Sprintf("/teams/%v/members/%v/apps", teamIdentity, teamMemberI... | go | func (s *Service) TeamMemberListByMember(ctx context.Context, teamIdentity string, teamMemberIdentity string, lr *ListRange) (TeamMemberListByMemberResult, error) {
var teamMember TeamMemberListByMemberResult
return teamMember, s.Get(ctx, &teamMember, fmt.Sprintf("/teams/%v/members/%v/apps", teamIdentity, teamMemberI... | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamMemberListByMember",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"teamMemberIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"TeamMemberListByMemberResult",
",",
"error",
")",
... | // List the apps of a team member. | [
"List",
"the",
"apps",
"of",
"a",
"team",
"member",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4551-L4554 |
20,113 | heroku/heroku-go | v3/heroku.go | TeamPreferencesList | func (s *Service) TeamPreferencesList(ctx context.Context, teamPreferencesIdentity string) (*TeamPreferences, error) {
var teamPreferences TeamPreferences
return &teamPreferences, s.Get(ctx, &teamPreferences, fmt.Sprintf("/teams/%v/preferences", teamPreferencesIdentity), nil, nil)
} | go | func (s *Service) TeamPreferencesList(ctx context.Context, teamPreferencesIdentity string) (*TeamPreferences, error) {
var teamPreferences TeamPreferences
return &teamPreferences, s.Get(ctx, &teamPreferences, fmt.Sprintf("/teams/%v/preferences", teamPreferencesIdentity), nil, nil)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamPreferencesList",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamPreferencesIdentity",
"string",
")",
"(",
"*",
"TeamPreferences",
",",
"error",
")",
"{",
"var",
"teamPreferences",
"TeamPreferences",
"\n",
"return",
... | // Retrieve Team Preferences | [
"Retrieve",
"Team",
"Preferences"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4563-L4566 |
20,114 | heroku/heroku-go | v3/heroku.go | TeamPreferencesUpdate | func (s *Service) TeamPreferencesUpdate(ctx context.Context, teamPreferencesIdentity string, o TeamPreferencesUpdateOpts) (*TeamPreferences, error) {
var teamPreferences TeamPreferences
return &teamPreferences, s.Patch(ctx, &teamPreferences, fmt.Sprintf("/teams/%v/preferences", teamPreferencesIdentity), o)
} | go | func (s *Service) TeamPreferencesUpdate(ctx context.Context, teamPreferencesIdentity string, o TeamPreferencesUpdateOpts) (*TeamPreferences, error) {
var teamPreferences TeamPreferences
return &teamPreferences, s.Patch(ctx, &teamPreferences, fmt.Sprintf("/teams/%v/preferences", teamPreferencesIdentity), o)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"TeamPreferencesUpdate",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamPreferencesIdentity",
"string",
",",
"o",
"TeamPreferencesUpdateOpts",
")",
"(",
"*",
"TeamPreferences",
",",
"error",
")",
"{",
"var",
"teamPreferen... | // Update Team Preferences | [
"Update",
"Team",
"Preferences"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4573-L4576 |
20,115 | heroku/heroku-go | v3/heroku.go | UserPreferencesList | func (s *Service) UserPreferencesList(ctx context.Context, userPreferencesIdentity string) (*UserPreferences, error) {
var userPreferences UserPreferences
return &userPreferences, s.Get(ctx, &userPreferences, fmt.Sprintf("/users/%v/preferences", userPreferencesIdentity), nil, nil)
} | go | func (s *Service) UserPreferencesList(ctx context.Context, userPreferencesIdentity string) (*UserPreferences, error) {
var userPreferences UserPreferences
return &userPreferences, s.Get(ctx, &userPreferences, fmt.Sprintf("/users/%v/preferences", userPreferencesIdentity), nil, nil)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"UserPreferencesList",
"(",
"ctx",
"context",
".",
"Context",
",",
"userPreferencesIdentity",
"string",
")",
"(",
"*",
"UserPreferences",
",",
"error",
")",
"{",
"var",
"userPreferences",
"UserPreferences",
"\n",
"return",
... | // Retrieve User Preferences | [
"Retrieve",
"User",
"Preferences"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4754-L4757 |
20,116 | heroku/heroku-go | v3/heroku.go | UserPreferencesUpdate | func (s *Service) UserPreferencesUpdate(ctx context.Context, userPreferencesIdentity string, o UserPreferencesUpdateOpts) (*UserPreferences, error) {
var userPreferences UserPreferences
return &userPreferences, s.Patch(ctx, &userPreferences, fmt.Sprintf("/users/%v/preferences", userPreferencesIdentity), o)
} | go | func (s *Service) UserPreferencesUpdate(ctx context.Context, userPreferencesIdentity string, o UserPreferencesUpdateOpts) (*UserPreferences, error) {
var userPreferences UserPreferences
return &userPreferences, s.Patch(ctx, &userPreferences, fmt.Sprintf("/users/%v/preferences", userPreferencesIdentity), o)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"UserPreferencesUpdate",
"(",
"ctx",
"context",
".",
"Context",
",",
"userPreferencesIdentity",
"string",
",",
"o",
"UserPreferencesUpdateOpts",
")",
"(",
"*",
"UserPreferences",
",",
"error",
")",
"{",
"var",
"userPreferen... | // Update User Preferences | [
"Update",
"User",
"Preferences"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4775-L4778 |
20,117 | heroku/heroku-go | v3/heroku.go | VPNConnectionCreate | func (s *Service) VPNConnectionCreate(ctx context.Context, spaceIdentity string, o VPNConnectionCreateOpts) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Post(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections", spaceIdentity), o)
} | go | func (s *Service) VPNConnectionCreate(ctx context.Context, spaceIdentity string, o VPNConnectionCreateOpts) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Post(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections", spaceIdentity), o)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"VPNConnectionCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"spaceIdentity",
"string",
",",
"o",
"VPNConnectionCreateOpts",
")",
"(",
"*",
"VPNConnection",
",",
"error",
")",
"{",
"var",
"vpnConnection",
"VPNConnec... | // Create a new VPN connection in a private space. | [
"Create",
"a",
"new",
"VPN",
"connection",
"in",
"a",
"private",
"space",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4808-L4811 |
20,118 | heroku/heroku-go | v3/heroku.go | VPNConnectionDestroy | func (s *Service) VPNConnectionDestroy(ctx context.Context, spaceIdentity string, vpnConnectionIdentity string) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Delete(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections/%v", spaceIdentity, vpnConnectionIdentity))
} | go | func (s *Service) VPNConnectionDestroy(ctx context.Context, spaceIdentity string, vpnConnectionIdentity string) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Delete(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections/%v", spaceIdentity, vpnConnectionIdentity))
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"VPNConnectionDestroy",
"(",
"ctx",
"context",
".",
"Context",
",",
"spaceIdentity",
"string",
",",
"vpnConnectionIdentity",
"string",
")",
"(",
"*",
"VPNConnection",
",",
"error",
")",
"{",
"var",
"vpnConnection",
"VPNCo... | // Destroy existing VPN Connection | [
"Destroy",
"existing",
"VPN",
"Connection"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4814-L4817 |
20,119 | heroku/heroku-go | v3/heroku.go | VPNConnectionList | func (s *Service) VPNConnectionList(ctx context.Context, spaceIdentity string, lr *ListRange) (VPNConnectionListResult, error) {
var vpnConnection VPNConnectionListResult
return vpnConnection, s.Get(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections", spaceIdentity), nil, lr)
} | go | func (s *Service) VPNConnectionList(ctx context.Context, spaceIdentity string, lr *ListRange) (VPNConnectionListResult, error) {
var vpnConnection VPNConnectionListResult
return vpnConnection, s.Get(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections", spaceIdentity), nil, lr)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"VPNConnectionList",
"(",
"ctx",
"context",
".",
"Context",
",",
"spaceIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"VPNConnectionListResult",
",",
"error",
")",
"{",
"var",
"vpnConnection",
"VPNConnectionL... | // List VPN connections for a space. | [
"List",
"VPN",
"connections",
"for",
"a",
"space",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4822-L4825 |
20,120 | heroku/heroku-go | v3/heroku.go | VPNConnectionInfo | func (s *Service) VPNConnectionInfo(ctx context.Context, spaceIdentity string, vpnConnectionIdentity string) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Get(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections/%v", spaceIdentity, vpnConnectionIdentity), nil, nil)
} | go | func (s *Service) VPNConnectionInfo(ctx context.Context, spaceIdentity string, vpnConnectionIdentity string) (*VPNConnection, error) {
var vpnConnection VPNConnection
return &vpnConnection, s.Get(ctx, &vpnConnection, fmt.Sprintf("/spaces/%v/vpn-connections/%v", spaceIdentity, vpnConnectionIdentity), nil, nil)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"VPNConnectionInfo",
"(",
"ctx",
"context",
".",
"Context",
",",
"spaceIdentity",
"string",
",",
"vpnConnectionIdentity",
"string",
")",
"(",
"*",
"VPNConnection",
",",
"error",
")",
"{",
"var",
"vpnConnection",
"VPNConne... | // Info for an existing vpn-connection. | [
"Info",
"for",
"an",
"existing",
"vpn",
"-",
"connection",
"."
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4828-L4831 |
20,121 | heroku/heroku-go | v3/heroku.go | WhitelistedAddOnServiceListByOrganization | func (s *Service) WhitelistedAddOnServiceListByOrganization(ctx context.Context, organizationIdentity string, lr *ListRange) (WhitelistedAddOnServiceListByOrganizationResult, error) {
var whitelistedAddOnService WhitelistedAddOnServiceListByOrganizationResult
return whitelistedAddOnService, s.Get(ctx, &whitelistedAdd... | go | func (s *Service) WhitelistedAddOnServiceListByOrganization(ctx context.Context, organizationIdentity string, lr *ListRange) (WhitelistedAddOnServiceListByOrganizationResult, error) {
var whitelistedAddOnService WhitelistedAddOnServiceListByOrganizationResult
return whitelistedAddOnService, s.Get(ctx, &whitelistedAdd... | [
"func",
"(",
"s",
"*",
"Service",
")",
"WhitelistedAddOnServiceListByOrganization",
"(",
"ctx",
"context",
".",
"Context",
",",
"organizationIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"WhitelistedAddOnServiceListByOrganizationResult",
",",
"error",
")... | // List all whitelisted Add-on Services for an Organization | [
"List",
"all",
"whitelisted",
"Add",
"-",
"on",
"Services",
"for",
"an",
"Organization"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4850-L4853 |
20,122 | heroku/heroku-go | v3/heroku.go | WhitelistedAddOnServiceListByTeam | func (s *Service) WhitelistedAddOnServiceListByTeam(ctx context.Context, teamIdentity string, lr *ListRange) (WhitelistedAddOnServiceListByTeamResult, error) {
var whitelistedAddOnService WhitelistedAddOnServiceListByTeamResult
return whitelistedAddOnService, s.Get(ctx, &whitelistedAddOnService, fmt.Sprintf("/teams/%... | go | func (s *Service) WhitelistedAddOnServiceListByTeam(ctx context.Context, teamIdentity string, lr *ListRange) (WhitelistedAddOnServiceListByTeamResult, error) {
var whitelistedAddOnService WhitelistedAddOnServiceListByTeamResult
return whitelistedAddOnService, s.Get(ctx, &whitelistedAddOnService, fmt.Sprintf("/teams/%... | [
"func",
"(",
"s",
"*",
"Service",
")",
"WhitelistedAddOnServiceListByTeam",
"(",
"ctx",
"context",
".",
"Context",
",",
"teamIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"WhitelistedAddOnServiceListByTeamResult",
",",
"error",
")",
"{",
"var",
"wh... | // List all whitelisted Add-on Services for a Team | [
"List",
"all",
"whitelisted",
"Add",
"-",
"on",
"Services",
"for",
"a",
"Team"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/heroku.go#L4875-L4878 |
20,123 | heroku/heroku-go | v3/transport.go | CancelRequest | func (t *Transport) CancelRequest(req *http.Request) {
type canceler interface {
CancelRequest(*http.Request)
}
tr, ok := t.Transport.(canceler)
if !ok {
log.Printf("heroku: Client Transport of type %T doesn't support CancelRequest; Timeout not supported\n", t.Transport)
return
}
tr.CancelRequest(req)
} | go | func (t *Transport) CancelRequest(req *http.Request) {
type canceler interface {
CancelRequest(*http.Request)
}
tr, ok := t.Transport.(canceler)
if !ok {
log.Printf("heroku: Client Transport of type %T doesn't support CancelRequest; Timeout not supported\n", t.Transport)
return
}
tr.CancelRequest(req)
} | [
"func",
"(",
"t",
"*",
"Transport",
")",
"CancelRequest",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"type",
"canceler",
"interface",
"{",
"CancelRequest",
"(",
"*",
"http",
".",
"Request",
")",
"\n",
"}",
"\n",
"tr",
",",
"ok",
":=",
"t",
... | // Forward CancelRequest to underlying Transport | [
"Forward",
"CancelRequest",
"to",
"underlying",
"Transport"
] | ad17585a922f269c393cbccf2e0cf81eb8d2e431 | https://github.com/heroku/heroku-go/blob/ad17585a922f269c393cbccf2e0cf81eb8d2e431/v3/transport.go#L49-L59 |
20,124 | jtolds/gls | context.go | NewContextManager | func NewContextManager() *ContextManager {
mgr := &ContextManager{values: make(map[uint]Values)}
mgrRegistryMtx.Lock()
defer mgrRegistryMtx.Unlock()
mgrRegistry[mgr] = true
return mgr
} | go | func NewContextManager() *ContextManager {
mgr := &ContextManager{values: make(map[uint]Values)}
mgrRegistryMtx.Lock()
defer mgrRegistryMtx.Unlock()
mgrRegistry[mgr] = true
return mgr
} | [
"func",
"NewContextManager",
"(",
")",
"*",
"ContextManager",
"{",
"mgr",
":=",
"&",
"ContextManager",
"{",
"values",
":",
"make",
"(",
"map",
"[",
"uint",
"]",
"Values",
")",
"}",
"\n",
"mgrRegistryMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mgrRegistr... | // NewContextManager returns a brand new ContextManager. It also registers the
// new ContextManager in the ContextManager registry which is used by the Go
// method. ContextManagers are typically defined globally at package scope. | [
"NewContextManager",
"returns",
"a",
"brand",
"new",
"ContextManager",
".",
"It",
"also",
"registers",
"the",
"new",
"ContextManager",
"in",
"the",
"ContextManager",
"registry",
"which",
"is",
"used",
"by",
"the",
"Go",
"method",
".",
"ContextManagers",
"are",
"... | b4936e06046bbecbb94cae9c18127ebe510a2cb9 | https://github.com/jtolds/gls/blob/b4936e06046bbecbb94cae9c18127ebe510a2cb9/context.go#L30-L36 |
20,125 | jtolds/gls | context.go | Unregister | func (m *ContextManager) Unregister() {
mgrRegistryMtx.Lock()
defer mgrRegistryMtx.Unlock()
delete(mgrRegistry, m)
} | go | func (m *ContextManager) Unregister() {
mgrRegistryMtx.Lock()
defer mgrRegistryMtx.Unlock()
delete(mgrRegistry, m)
} | [
"func",
"(",
"m",
"*",
"ContextManager",
")",
"Unregister",
"(",
")",
"{",
"mgrRegistryMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mgrRegistryMtx",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"mgrRegistry",
",",
"m",
")",
"\n",
"}"
] | // Unregister removes a ContextManager from the global registry, used by the
// Go method. Only intended for use when you're completely done with a
// ContextManager. Use of Unregister at all is rare. | [
"Unregister",
"removes",
"a",
"ContextManager",
"from",
"the",
"global",
"registry",
"used",
"by",
"the",
"Go",
"method",
".",
"Only",
"intended",
"for",
"use",
"when",
"you",
"re",
"completely",
"done",
"with",
"a",
"ContextManager",
".",
"Use",
"of",
"Unre... | b4936e06046bbecbb94cae9c18127ebe510a2cb9 | https://github.com/jtolds/gls/blob/b4936e06046bbecbb94cae9c18127ebe510a2cb9/context.go#L41-L45 |
20,126 | jtolds/gls | context.go | GetValue | func (m *ContextManager) GetValue(key interface{}) (
value interface{}, ok bool) {
gid, ok := GetGoroutineId()
if !ok {
return nil, false
}
m.mtx.Lock()
state, found := m.values[gid]
m.mtx.Unlock()
if !found {
return nil, false
}
value, ok = state[key]
return value, ok
} | go | func (m *ContextManager) GetValue(key interface{}) (
value interface{}, ok bool) {
gid, ok := GetGoroutineId()
if !ok {
return nil, false
}
m.mtx.Lock()
state, found := m.values[gid]
m.mtx.Unlock()
if !found {
return nil, false
}
value, ok = state[key]
return value, ok
} | [
"func",
"(",
"m",
"*",
"ContextManager",
")",
"GetValue",
"(",
"key",
"interface",
"{",
"}",
")",
"(",
"value",
"interface",
"{",
"}",
",",
"ok",
"bool",
")",
"{",
"gid",
",",
"ok",
":=",
"GetGoroutineId",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"r... | // GetValue will return a previously set value, provided that the value was set
// by SetValues somewhere higher up the stack. If the value is not found, ok
// will be false. | [
"GetValue",
"will",
"return",
"a",
"previously",
"set",
"value",
"provided",
"that",
"the",
"value",
"was",
"set",
"by",
"SetValues",
"somewhere",
"higher",
"up",
"the",
"stack",
".",
"If",
"the",
"value",
"is",
"not",
"found",
"ok",
"will",
"be",
"false",... | b4936e06046bbecbb94cae9c18127ebe510a2cb9 | https://github.com/jtolds/gls/blob/b4936e06046bbecbb94cae9c18127ebe510a2cb9/context.go#L104-L120 |
20,127 | jtolds/gls | context.go | Go | func Go(cb func()) {
mgrRegistryMtx.RLock()
defer mgrRegistryMtx.RUnlock()
for mgr := range mgrRegistry {
values := mgr.getValues()
if len(values) > 0 {
cb = func(mgr *ContextManager, cb func()) func() {
return func() { mgr.SetValues(values, cb) }
}(mgr, cb)
}
}
go cb()
} | go | func Go(cb func()) {
mgrRegistryMtx.RLock()
defer mgrRegistryMtx.RUnlock()
for mgr := range mgrRegistry {
values := mgr.getValues()
if len(values) > 0 {
cb = func(mgr *ContextManager, cb func()) func() {
return func() { mgr.SetValues(values, cb) }
}(mgr, cb)
}
}
go cb()
} | [
"func",
"Go",
"(",
"cb",
"func",
"(",
")",
")",
"{",
"mgrRegistryMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"mgrRegistryMtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"for",
"mgr",
":=",
"range",
"mgrRegistry",
"{",
"values",
":=",
"mgr",
".",
"getValues",
... | // Go preserves ContextManager values and Goroutine-local-storage across new
// goroutine invocations. The Go method makes a copy of all existing values on
// all registered context managers and makes sure they are still set after
// kicking off the provided function in a new goroutine. If you don't use this
// Go meth... | [
"Go",
"preserves",
"ContextManager",
"values",
"and",
"Goroutine",
"-",
"local",
"-",
"storage",
"across",
"new",
"goroutine",
"invocations",
".",
"The",
"Go",
"method",
"makes",
"a",
"copy",
"of",
"all",
"existing",
"values",
"on",
"all",
"registered",
"conte... | b4936e06046bbecbb94cae9c18127ebe510a2cb9 | https://github.com/jtolds/gls/blob/b4936e06046bbecbb94cae9c18127ebe510a2cb9/context.go#L139-L153 |
20,128 | jtolds/gls | gen_sym.go | GenSym | func GenSym() ContextKey {
keyMtx.Lock()
defer keyMtx.Unlock()
keyCounter += 1
return ContextKey{id: keyCounter}
} | go | func GenSym() ContextKey {
keyMtx.Lock()
defer keyMtx.Unlock()
keyCounter += 1
return ContextKey{id: keyCounter}
} | [
"func",
"GenSym",
"(",
")",
"ContextKey",
"{",
"keyMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"keyMtx",
".",
"Unlock",
"(",
")",
"\n",
"keyCounter",
"+=",
"1",
"\n",
"return",
"ContextKey",
"{",
"id",
":",
"keyCounter",
"}",
"\n",
"}"
] | // GenSym will return a brand new, never-before-used ContextKey | [
"GenSym",
"will",
"return",
"a",
"brand",
"new",
"never",
"-",
"before",
"-",
"used",
"ContextKey"
] | b4936e06046bbecbb94cae9c18127ebe510a2cb9 | https://github.com/jtolds/gls/blob/b4936e06046bbecbb94cae9c18127ebe510a2cb9/gen_sym.go#L16-L21 |
20,129 | jtolds/gls | gid.go | EnsureGoroutineId | func EnsureGoroutineId(cb func(gid uint)) {
if gid, ok := readStackTag(); ok {
cb(gid)
return
}
gid := stackTagPool.Acquire()
defer stackTagPool.Release(gid)
addStackTag(gid, func() { cb(gid) })
} | go | func EnsureGoroutineId(cb func(gid uint)) {
if gid, ok := readStackTag(); ok {
cb(gid)
return
}
gid := stackTagPool.Acquire()
defer stackTagPool.Release(gid)
addStackTag(gid, func() { cb(gid) })
} | [
"func",
"EnsureGoroutineId",
"(",
"cb",
"func",
"(",
"gid",
"uint",
")",
")",
"{",
"if",
"gid",
",",
"ok",
":=",
"readStackTag",
"(",
")",
";",
"ok",
"{",
"cb",
"(",
"gid",
")",
"\n",
"return",
"\n",
"}",
"\n",
"gid",
":=",
"stackTagPool",
".",
"... | // Will call cb with the current goroutine identifier. If one hasn't already
// been generated, one will be created and set first. The goroutine identifier
// might be invalid after cb returns. | [
"Will",
"call",
"cb",
"with",
"the",
"current",
"goroutine",
"identifier",
".",
"If",
"one",
"hasn",
"t",
"already",
"been",
"generated",
"one",
"will",
"be",
"created",
"and",
"set",
"first",
".",
"The",
"goroutine",
"identifier",
"might",
"be",
"invalid",
... | b4936e06046bbecbb94cae9c18127ebe510a2cb9 | https://github.com/jtolds/gls/blob/b4936e06046bbecbb94cae9c18127ebe510a2cb9/gid.go#L17-L25 |
20,130 | mwitkow/grpc-proxy | proxy/handler.go | handler | func (s *handler) handler(srv interface{}, serverStream grpc.ServerStream) error {
// little bit of gRPC internals never hurt anyone
fullMethodName, ok := grpc.MethodFromServerStream(serverStream)
if !ok {
return grpc.Errorf(codes.Internal, "lowLevelServerStream not exists in context")
}
// We require that the d... | go | func (s *handler) handler(srv interface{}, serverStream grpc.ServerStream) error {
// little bit of gRPC internals never hurt anyone
fullMethodName, ok := grpc.MethodFromServerStream(serverStream)
if !ok {
return grpc.Errorf(codes.Internal, "lowLevelServerStream not exists in context")
}
// We require that the d... | [
"func",
"(",
"s",
"*",
"handler",
")",
"handler",
"(",
"srv",
"interface",
"{",
"}",
",",
"serverStream",
"grpc",
".",
"ServerStream",
")",
"error",
"{",
"// little bit of gRPC internals never hurt anyone",
"fullMethodName",
",",
"ok",
":=",
"grpc",
".",
"Method... | // handler is where the real magic of proxying happens.
// It is invoked like any gRPC server stream and uses the gRPC server framing to get and receive bytes from the wire,
// forwarding it to a ClientStream established against the relevant ClientConn. | [
"handler",
"is",
"where",
"the",
"real",
"magic",
"of",
"proxying",
"happens",
".",
"It",
"is",
"invoked",
"like",
"any",
"gRPC",
"server",
"stream",
"and",
"uses",
"the",
"gRPC",
"server",
"framing",
"to",
"get",
"and",
"receive",
"bytes",
"from",
"the",
... | 0f1106ef9c766333b9acb4b81e705da4bade7215 | https://github.com/mwitkow/grpc-proxy/blob/0f1106ef9c766333b9acb4b81e705da4bade7215/proxy/handler.go#L60-L112 |
20,131 | couchbase/moss | store_footer.go | AddRef | func (f *Footer) AddRef() {
f.m.Lock()
f.refs++
f.m.Unlock()
} | go | func (f *Footer) AddRef() {
f.m.Lock()
f.refs++
f.m.Unlock()
} | [
"func",
"(",
"f",
"*",
"Footer",
")",
"AddRef",
"(",
")",
"{",
"f",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"f",
".",
"refs",
"++",
"\n",
"f",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // AddRef increases the ref count on this footer | [
"AddRef",
"increases",
"the",
"ref",
"count",
"on",
"this",
"footer"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_footer.go#L408-L412 |
20,132 | couchbase/moss | store_footer.go | DecRef | func (f *Footer) DecRef() {
f.m.Lock()
f.refs--
if f.refs <= 0 {
f.SegmentLocs.DecRef()
f.SegmentLocs = nil
f.ss = nil
}
f.m.Unlock()
} | go | func (f *Footer) DecRef() {
f.m.Lock()
f.refs--
if f.refs <= 0 {
f.SegmentLocs.DecRef()
f.SegmentLocs = nil
f.ss = nil
}
f.m.Unlock()
} | [
"func",
"(",
"f",
"*",
"Footer",
")",
"DecRef",
"(",
")",
"{",
"f",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"f",
".",
"refs",
"--",
"\n",
"if",
"f",
".",
"refs",
"<=",
"0",
"{",
"f",
".",
"SegmentLocs",
".",
"DecRef",
"(",
")",
"\n",
"f",
... | // DecRef decreases the ref count on this footer | [
"DecRef",
"decreases",
"the",
"ref",
"count",
"on",
"this",
"footer"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_footer.go#L415-L424 |
20,133 | couchbase/moss | store_footer.go | Length | func (f *Footer) Length() uint64 {
jBuf, err := json.Marshal(f)
if err != nil {
return 0
}
footerLen := footerBegLen + len(jBuf) + footerEndLen
return uint64(footerLen)
} | go | func (f *Footer) Length() uint64 {
jBuf, err := json.Marshal(f)
if err != nil {
return 0
}
footerLen := footerBegLen + len(jBuf) + footerEndLen
return uint64(footerLen)
} | [
"func",
"(",
"f",
"*",
"Footer",
")",
"Length",
"(",
")",
"uint64",
"{",
"jBuf",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"f",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"footerLen",
":=",
"footerBegLen",
"+... | // Length returns the length of this footer | [
"Length",
"returns",
"the",
"length",
"of",
"this",
"footer"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_footer.go#L427-L435 |
20,134 | couchbase/moss | collection_stats.go | Stats | func (m *collection) Stats() (*CollectionStats, error) {
rv := &CollectionStats{}
m.stats.AtomicCopyTo(rv)
m.m.Lock()
m.statsSegmentsLOCKED(rv)
m.m.Unlock()
return rv, nil
} | go | func (m *collection) Stats() (*CollectionStats, error) {
rv := &CollectionStats{}
m.stats.AtomicCopyTo(rv)
m.m.Lock()
m.statsSegmentsLOCKED(rv)
m.m.Unlock()
return rv, nil
} | [
"func",
"(",
"m",
"*",
"collection",
")",
"Stats",
"(",
")",
"(",
"*",
"CollectionStats",
",",
"error",
")",
"{",
"rv",
":=",
"&",
"CollectionStats",
"{",
"}",
"\n\n",
"m",
".",
"stats",
".",
"AtomicCopyTo",
"(",
"rv",
")",
"\n\n",
"m",
".",
"m",
... | // Stats returns stats for this collection. | [
"Stats",
"returns",
"stats",
"for",
"this",
"collection",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection_stats.go#L22-L32 |
20,135 | couchbase/moss | collection_stats.go | statsSegmentsLOCKED | func (m *collection) statsSegmentsLOCKED(rv *CollectionStats) {
var sssDirtyTop *SegmentStackStats
var sssDirtyMid *SegmentStackStats
var sssDirtyBase *SegmentStackStats
var sssClean *SegmentStackStats
if m.stackDirtyTop != nil {
sssDirtyTop = m.stackDirtyTop.Stats()
}
if m.stackDirtyMid != nil {
sssDirtyM... | go | func (m *collection) statsSegmentsLOCKED(rv *CollectionStats) {
var sssDirtyTop *SegmentStackStats
var sssDirtyMid *SegmentStackStats
var sssDirtyBase *SegmentStackStats
var sssClean *SegmentStackStats
if m.stackDirtyTop != nil {
sssDirtyTop = m.stackDirtyTop.Stats()
}
if m.stackDirtyMid != nil {
sssDirtyM... | [
"func",
"(",
"m",
"*",
"collection",
")",
"statsSegmentsLOCKED",
"(",
"rv",
"*",
"CollectionStats",
")",
"{",
"var",
"sssDirtyTop",
"*",
"SegmentStackStats",
"\n",
"var",
"sssDirtyMid",
"*",
"SegmentStackStats",
"\n",
"var",
"sssDirtyBase",
"*",
"SegmentStackStats... | // statsSegmentsLOCKED retrieves stats related to segments. | [
"statsSegmentsLOCKED",
"retrieves",
"stats",
"related",
"to",
"segments",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection_stats.go#L41-L95 |
20,136 | couchbase/moss | store.go | buildNewFooter | func (s *Store) buildNewFooter(storeFooter *Footer, ss *segmentStack) *Footer {
footer := &Footer{refs: 1, incarNum: ss.incarNum}
numSegmentLocs := len(ss.a)
var segmentLocs []SegmentLoc
if storeFooter != nil {
numSegmentLocs += len(storeFooter.SegmentLocs)
segmentLocs = make([]SegmentLoc, 0, numSegmentLocs)
... | go | func (s *Store) buildNewFooter(storeFooter *Footer, ss *segmentStack) *Footer {
footer := &Footer{refs: 1, incarNum: ss.incarNum}
numSegmentLocs := len(ss.a)
var segmentLocs []SegmentLoc
if storeFooter != nil {
numSegmentLocs += len(storeFooter.SegmentLocs)
segmentLocs = make([]SegmentLoc, 0, numSegmentLocs)
... | [
"func",
"(",
"s",
"*",
"Store",
")",
"buildNewFooter",
"(",
"storeFooter",
"*",
"Footer",
",",
"ss",
"*",
"segmentStack",
")",
"*",
"Footer",
"{",
"footer",
":=",
"&",
"Footer",
"{",
"refs",
":",
"1",
",",
"incarNum",
":",
"ss",
".",
"incarNum",
"}",... | // buildNewFooter will construct a new Footer for the store by combining
// the given storeFooter's segmentLocs with that of the incoming snapshot. | [
"buildNewFooter",
"will",
"construct",
"a",
"new",
"Footer",
"for",
"the",
"store",
"by",
"combining",
"the",
"given",
"storeFooter",
"s",
"segmentLocs",
"with",
"that",
"of",
"the",
"incoming",
"snapshot",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store.go#L178-L220 |
20,137 | couchbase/moss | store.go | persistSegments | func (s *Store) persistSegments(ss *segmentStack, footer *Footer,
file File, fref *FileRef) error {
// First persist the child segments recursively.
for cName, childSegStack := range ss.childSegStacks {
err := s.persistSegments(childSegStack, footer.ChildFooters[cName],
file, fref)
if err != nil {
return e... | go | func (s *Store) persistSegments(ss *segmentStack, footer *Footer,
file File, fref *FileRef) error {
// First persist the child segments recursively.
for cName, childSegStack := range ss.childSegStacks {
err := s.persistSegments(childSegStack, footer.ChildFooters[cName],
file, fref)
if err != nil {
return e... | [
"func",
"(",
"s",
"*",
"Store",
")",
"persistSegments",
"(",
"ss",
"*",
"segmentStack",
",",
"footer",
"*",
"Footer",
",",
"file",
"File",
",",
"fref",
"*",
"FileRef",
")",
"error",
"{",
"// First persist the child segments recursively.",
"for",
"cName",
",",
... | // persistSegments will recursively write out all the segments of the
// current collection as well as any of its child collections. | [
"persistSegments",
"will",
"recursively",
"write",
"out",
"all",
"the",
"segments",
"of",
"the",
"current",
"collection",
"as",
"well",
"as",
"any",
"of",
"its",
"child",
"collections",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store.go#L224-L251 |
20,138 | couchbase/moss | store.go | removeFileOnClose | func (s *Store) removeFileOnClose(fref *FileRef) (os.FileInfo, error) {
finfo, err := fref.file.Stat()
if err != nil {
return nil, err
}
if len(finfo.Name()) > 0 {
fref.OnAfterClose(func() {
fileName := finfo.Name()
go func() {
s.m.Lock()
delete(s.fileRefMap, fileName)
s.m.Unlock()
err :=... | go | func (s *Store) removeFileOnClose(fref *FileRef) (os.FileInfo, error) {
finfo, err := fref.file.Stat()
if err != nil {
return nil, err
}
if len(finfo.Name()) > 0 {
fref.OnAfterClose(func() {
fileName := finfo.Name()
go func() {
s.m.Lock()
delete(s.fileRefMap, fileName)
s.m.Unlock()
err :=... | [
"func",
"(",
"s",
"*",
"Store",
")",
"removeFileOnClose",
"(",
"fref",
"*",
"FileRef",
")",
"(",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"finfo",
",",
"err",
":=",
"fref",
".",
"file",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // removeFileOnClose will setup the callback to wipe out the file safely
// when all references to it are closed. | [
"removeFileOnClose",
"will",
"setup",
"the",
"callback",
"to",
"wipe",
"out",
"the",
"file",
"safely",
"when",
"all",
"references",
"to",
"it",
"are",
"closed",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store.go#L314-L340 |
20,139 | couchbase/moss | store.go | pageOffset | func pageOffset(pos, pageSize int64) int64 {
rem := pos % pageSize
if rem != 0 {
return pos - rem
}
return pos
} | go | func pageOffset(pos, pageSize int64) int64 {
rem := pos % pageSize
if rem != 0 {
return pos - rem
}
return pos
} | [
"func",
"pageOffset",
"(",
"pos",
",",
"pageSize",
"int64",
")",
"int64",
"{",
"rem",
":=",
"pos",
"%",
"pageSize",
"\n",
"if",
"rem",
"!=",
"0",
"{",
"return",
"pos",
"-",
"rem",
"\n",
"}",
"\n",
"return",
"pos",
"\n",
"}"
] | // pageOffset returns the page offset for a given pos. | [
"pageOffset",
"returns",
"the",
"page",
"offset",
"for",
"a",
"given",
"pos",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store.go#L510-L516 |
20,140 | couchbase/moss | store_stats.go | Stats | func (s *Store) Stats() (map[string]interface{}, error) {
finfos, err := ioutil.ReadDir(s.dir)
if err != nil {
return nil, err
}
var numBytesUsedDisk uint64
for _, finfo := range finfos {
if !finfo.IsDir() {
numBytesUsedDisk += uint64(finfo.Size())
}
}
s.m.Lock()
totPersists := s.totPersists
totComp... | go | func (s *Store) Stats() (map[string]interface{}, error) {
finfos, err := ioutil.ReadDir(s.dir)
if err != nil {
return nil, err
}
var numBytesUsedDisk uint64
for _, finfo := range finfos {
if !finfo.IsDir() {
numBytesUsedDisk += uint64(finfo.Size())
}
}
s.m.Lock()
totPersists := s.totPersists
totComp... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Stats",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"finfos",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"s",
".",
"dir",
")",
"\n",
"if",
"err",
"!=",
"... | // Stats returns a map of stats. | [
"Stats",
"returns",
"a",
"map",
"of",
"stats",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_stats.go#L21-L84 |
20,141 | couchbase/moss | store_stats.go | Histograms | func (s *Store) Histograms() ghistogram.Histograms {
histogramsSnapshot := make(ghistogram.Histograms)
histogramsSnapshot.AddAll(s.histograms)
return histogramsSnapshot
} | go | func (s *Store) Histograms() ghistogram.Histograms {
histogramsSnapshot := make(ghistogram.Histograms)
histogramsSnapshot.AddAll(s.histograms)
return histogramsSnapshot
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Histograms",
"(",
")",
"ghistogram",
".",
"Histograms",
"{",
"histogramsSnapshot",
":=",
"make",
"(",
"ghistogram",
".",
"Histograms",
")",
"\n",
"histogramsSnapshot",
".",
"AddAll",
"(",
"s",
".",
"histograms",
")",
"... | // Histograms returns a snapshot of the histograms for this store. | [
"Histograms",
"returns",
"a",
"snapshot",
"of",
"the",
"histograms",
"for",
"this",
"store",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_stats.go#L87-L91 |
20,142 | couchbase/moss | collection.go | Close | func (m *collection) Close() error {
m.fireEvent(EventKindCloseStart, 0)
startTime := time.Now()
defer func() {
m.fireEvent(EventKindClose, time.Now().Sub(startTime))
}()
atomic.AddUint64(&m.stats.TotCloseBeg, 1)
m.m.Lock()
m.invalidateLatestSnapshotLOCKED()
close(m.stopCh)
m.stackDirtyTopCond.Broadcast... | go | func (m *collection) Close() error {
m.fireEvent(EventKindCloseStart, 0)
startTime := time.Now()
defer func() {
m.fireEvent(EventKindClose, time.Now().Sub(startTime))
}()
atomic.AddUint64(&m.stats.TotCloseBeg, 1)
m.m.Lock()
m.invalidateLatestSnapshotLOCKED()
close(m.stopCh)
m.stackDirtyTopCond.Broadcast... | [
"func",
"(",
"m",
"*",
"collection",
")",
"Close",
"(",
")",
"error",
"{",
"m",
".",
"fireEvent",
"(",
"EventKindCloseStart",
",",
"0",
")",
"\n",
"startTime",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"m",
".",
"f... | // Close synchronously stops background goroutines. | [
"Close",
"synchronously",
"stops",
"background",
"goroutines",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection.go#L125-L184 |
20,143 | couchbase/moss | collection.go | Snapshot | func (m *collection) Snapshot() (rv Snapshot, err error) {
m.m.Lock()
rv = reuseSnapshot(m.latestSnapshot)
if rv == nil { // No cached snapshot.
rv, err = m.newSnapshotLOCKED()
if err == nil {
// collection holds 1 ref count for its cached snapshot copy.
m.latestSnapshot = reuseSnapshot(rv)
}
}
m.m.Unl... | go | func (m *collection) Snapshot() (rv Snapshot, err error) {
m.m.Lock()
rv = reuseSnapshot(m.latestSnapshot)
if rv == nil { // No cached snapshot.
rv, err = m.newSnapshotLOCKED()
if err == nil {
// collection holds 1 ref count for its cached snapshot copy.
m.latestSnapshot = reuseSnapshot(rv)
}
}
m.m.Unl... | [
"func",
"(",
"m",
"*",
"collection",
")",
"Snapshot",
"(",
")",
"(",
"rv",
"Snapshot",
",",
"err",
"error",
")",
"{",
"m",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"rv",
"=",
"reuseSnapshot",
"(",
"m",
".",
"latestSnapshot",
")",
"\n",
"if",
"rv",
... | // Snapshot returns a stable snapshot of the key-value entries. | [
"Snapshot",
"returns",
"a",
"stable",
"snapshot",
"of",
"the",
"key",
"-",
"value",
"entries",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection.go#L214-L227 |
20,144 | couchbase/moss | collection.go | newSnapshotLOCKED | func (m *collection) newSnapshotLOCKED() (Snapshot, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotSnapshotBeg, 1)
rv, _, _, _, _ := m.snapshot(0, nil, true) // collection lock already held.
atomic.AddUint64(&m.stats.TotSnapshotEnd, 1)
return rv, nil
} | go | func (m *collection) newSnapshotLOCKED() (Snapshot, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotSnapshotBeg, 1)
rv, _, _, _, _ := m.snapshot(0, nil, true) // collection lock already held.
atomic.AddUint64(&m.stats.TotSnapshotEnd, 1)
return rv, nil
} | [
"func",
"(",
"m",
"*",
"collection",
")",
"newSnapshotLOCKED",
"(",
")",
"(",
"Snapshot",
",",
"error",
")",
"{",
"if",
"m",
".",
"isClosed",
"(",
")",
"{",
"return",
"nil",
",",
"ErrClosed",
"\n",
"}",
"\n\n",
"atomic",
".",
"AddUint64",
"(",
"&",
... | // newSnapshotLOCKED creates a new stable snapshot of the key-value
// entries. | [
"newSnapshotLOCKED",
"creates",
"a",
"new",
"stable",
"snapshot",
"of",
"the",
"key",
"-",
"value",
"entries",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection.go#L240-L252 |
20,145 | couchbase/moss | collection.go | Get | func (m *collection) Get(key []byte, readOptions ReadOptions) ([]byte, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotGet, 1)
val, err := m.get(key, readOptions)
if err != nil {
atomic.AddUint64(&m.stats.TotGetErr, 1)
}
return val, err
} | go | func (m *collection) Get(key []byte, readOptions ReadOptions) ([]byte, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotGet, 1)
val, err := m.get(key, readOptions)
if err != nil {
atomic.AddUint64(&m.stats.TotGetErr, 1)
}
return val, err
} | [
"func",
"(",
"m",
"*",
"collection",
")",
"Get",
"(",
"key",
"[",
"]",
"byte",
",",
"readOptions",
"ReadOptions",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"m",
".",
"isClosed",
"(",
")",
"{",
"return",
"nil",
",",
"ErrClosed",
"\... | // Get retrieves a value by iterating over all the segments within
// the collection, if the key is not found a nil val is returned. | [
"Get",
"retrieves",
"a",
"value",
"by",
"iterating",
"over",
"all",
"the",
"segments",
"within",
"the",
"collection",
"if",
"the",
"key",
"is",
"not",
"found",
"a",
"nil",
"val",
"is",
"returned",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection.go#L256-L270 |
20,146 | couchbase/moss | collection.go | NewBatch | func (m *collection) NewBatch(totalOps, totalKeyValBytes int) (
Batch, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotNewBatch, 1)
atomic.AddUint64(&m.stats.TotNewBatchTotalOps, uint64(totalOps))
atomic.AddUint64(&m.stats.TotNewBatchTotalKeyValBytes, uint64(totalKeyValBytes))
... | go | func (m *collection) NewBatch(totalOps, totalKeyValBytes int) (
Batch, error) {
if m.isClosed() {
return nil, ErrClosed
}
atomic.AddUint64(&m.stats.TotNewBatch, 1)
atomic.AddUint64(&m.stats.TotNewBatchTotalOps, uint64(totalOps))
atomic.AddUint64(&m.stats.TotNewBatchTotalKeyValBytes, uint64(totalKeyValBytes))
... | [
"func",
"(",
"m",
"*",
"collection",
")",
"NewBatch",
"(",
"totalOps",
",",
"totalKeyValBytes",
"int",
")",
"(",
"Batch",
",",
"error",
")",
"{",
"if",
"m",
".",
"isClosed",
"(",
")",
"{",
"return",
"nil",
",",
"ErrClosed",
"\n",
"}",
"\n\n",
"atomic... | // NewBatch returns a new Batch instance with hinted amount of
// resources expected to be required. | [
"NewBatch",
"returns",
"a",
"new",
"Batch",
"instance",
"with",
"hinted",
"amount",
"of",
"resources",
"expected",
"to",
"be",
"required",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection.go#L274-L285 |
20,147 | couchbase/moss | collection.go | appendChildLLSnapshot | func (m *collection) appendChildLLSnapshot(dst *segmentStack,
src Snapshot) *segmentStack {
if m.incarNum != 0 {
dst.lowerLevelSnapshot = NewSnapshotWrapper(src, nil)
}
for cName, childCollection := range m.childCollections {
dstChildStack := childCollection.getOrInitChildStack(dst, cName)
var childSnap Sna... | go | func (m *collection) appendChildLLSnapshot(dst *segmentStack,
src Snapshot) *segmentStack {
if m.incarNum != 0 {
dst.lowerLevelSnapshot = NewSnapshotWrapper(src, nil)
}
for cName, childCollection := range m.childCollections {
dstChildStack := childCollection.getOrInitChildStack(dst, cName)
var childSnap Sna... | [
"func",
"(",
"m",
"*",
"collection",
")",
"appendChildLLSnapshot",
"(",
"dst",
"*",
"segmentStack",
",",
"src",
"Snapshot",
")",
"*",
"segmentStack",
"{",
"if",
"m",
".",
"incarNum",
"!=",
"0",
"{",
"dst",
".",
"lowerLevelSnapshot",
"=",
"NewSnapshotWrapper"... | // appendChildLLSnapshot recursively appends lower level child snapshots. | [
"appendChildLLSnapshot",
"recursively",
"appends",
"lower",
"level",
"child",
"snapshots",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection.go#L708-L727 |
20,148 | couchbase/moss | collection.go | appendChildStacks | func (m *collection) appendChildStacks(dst, src *segmentStack) *segmentStack {
if src == nil {
return dst
}
dst.a = append(dst.a, src.a...)
for cName, srcChildStack := range src.childSegStacks {
childCollection, exists := m.childCollections[cName]
if !exists || // This child collection was dropped recently,... | go | func (m *collection) appendChildStacks(dst, src *segmentStack) *segmentStack {
if src == nil {
return dst
}
dst.a = append(dst.a, src.a...)
for cName, srcChildStack := range src.childSegStacks {
childCollection, exists := m.childCollections[cName]
if !exists || // This child collection was dropped recently,... | [
"func",
"(",
"m",
"*",
"collection",
")",
"appendChildStacks",
"(",
"dst",
",",
"src",
"*",
"segmentStack",
")",
"*",
"segmentStack",
"{",
"if",
"src",
"==",
"nil",
"{",
"return",
"dst",
"\n",
"}",
"\n\n",
"dst",
".",
"a",
"=",
"append",
"(",
"dst",
... | // appendChildStacks recursively appends child segment stacks. | [
"appendChildStacks",
"recursively",
"appends",
"child",
"segment",
"stacks",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/collection.go#L730-L752 |
20,149 | couchbase/moss | segment.go | nextDelta | func (c *segmentCursor) nextDelta(delta int) error {
c.curr += delta
if c.curr >= c.end {
return ErrIteratorDone
}
return nil
} | go | func (c *segmentCursor) nextDelta(delta int) error {
c.curr += delta
if c.curr >= c.end {
return ErrIteratorDone
}
return nil
} | [
"func",
"(",
"c",
"*",
"segmentCursor",
")",
"nextDelta",
"(",
"delta",
"int",
")",
"error",
"{",
"c",
".",
"curr",
"+=",
"delta",
"\n",
"if",
"c",
".",
"curr",
">=",
"c",
".",
"end",
"{",
"return",
"ErrIteratorDone",
"\n",
"}",
"\n",
"return",
"ni... | // nextDelta advances the cursor position by 'delta' steps. | [
"nextDelta",
"advances",
"the",
"cursor",
"position",
"by",
"delta",
"steps",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment.go#L370-L376 |
20,150 | couchbase/moss | segment.go | currentKey | func (c *segmentCursor) currentKey() (idx int, key []byte) {
if c.curr >= c.start && c.curr < c.end {
idx = c.curr
_, key, _ = c.s.getOperationKeyVal(c.curr)
}
return
} | go | func (c *segmentCursor) currentKey() (idx int, key []byte) {
if c.curr >= c.start && c.curr < c.end {
idx = c.curr
_, key, _ = c.s.getOperationKeyVal(c.curr)
}
return
} | [
"func",
"(",
"c",
"*",
"segmentCursor",
")",
"currentKey",
"(",
")",
"(",
"idx",
"int",
",",
"key",
"[",
"]",
"byte",
")",
"{",
"if",
"c",
".",
"curr",
">=",
"c",
".",
"start",
"&&",
"c",
".",
"curr",
"<",
"c",
".",
"end",
"{",
"idx",
"=",
... | // currentKey returns the array position and the key pointed to by the cursor. | [
"currentKey",
"returns",
"the",
"array",
"position",
"and",
"the",
"key",
"pointed",
"to",
"by",
"the",
"cursor",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment.go#L379-L385 |
20,151 | couchbase/moss | segment.go | searchIndex | func (a *segment) searchIndex(key []byte) (int, int) {
if a.index != nil {
// Check the in-memory index for a more accurate window.
return a.index.lookup(key)
}
return 0, a.Len()
} | go | func (a *segment) searchIndex(key []byte) (int, int) {
if a.index != nil {
// Check the in-memory index for a more accurate window.
return a.index.lookup(key)
}
return 0, a.Len()
} | [
"func",
"(",
"a",
"*",
"segment",
")",
"searchIndex",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"int",
")",
"{",
"if",
"a",
".",
"index",
"!=",
"nil",
"{",
"// Check the in-memory index for a more accurate window.",
"return",
"a",
".",
"index",
... | // Searches for the key within the in-memory index of the segment
// if available. Returns left and right positions between which
// the key likely exists. | [
"Searches",
"for",
"the",
"key",
"within",
"the",
"in",
"-",
"memory",
"index",
"of",
"the",
"segment",
"if",
"available",
".",
"Returns",
"left",
"and",
"right",
"positions",
"between",
"which",
"the",
"key",
"likely",
"exists",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment.go#L417-L424 |
20,152 | couchbase/moss | util_merge.go | FullMerge | func (mo *MergeOperatorStringAppend) FullMerge(key, existingValue []byte,
operands [][]byte) ([]byte, bool) {
mo.m.Lock()
mo.numFull++
mo.m.Unlock()
s := string(existingValue)
for _, operand := range operands {
s = s + mo.Sep + string(operand)
}
return []byte(s), true
} | go | func (mo *MergeOperatorStringAppend) FullMerge(key, existingValue []byte,
operands [][]byte) ([]byte, bool) {
mo.m.Lock()
mo.numFull++
mo.m.Unlock()
s := string(existingValue)
for _, operand := range operands {
s = s + mo.Sep + string(operand)
}
return []byte(s), true
} | [
"func",
"(",
"mo",
"*",
"MergeOperatorStringAppend",
")",
"FullMerge",
"(",
"key",
",",
"existingValue",
"[",
"]",
"byte",
",",
"operands",
"[",
"]",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
")",
"{",
"mo",
".",
"m",
".",
"Lock",
... | // FullMerge performs the full merge of a string append operation | [
"FullMerge",
"performs",
"the",
"full",
"merge",
"of",
"a",
"string",
"append",
"operation"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/util_merge.go#L33-L44 |
20,153 | couchbase/moss | util_merge.go | PartialMerge | func (mo *MergeOperatorStringAppend) PartialMerge(key,
leftOperand, rightOperand []byte) ([]byte, bool) {
mo.m.Lock()
mo.numPartial++
mo.m.Unlock()
return []byte(string(leftOperand) + mo.Sep + string(rightOperand)), true
} | go | func (mo *MergeOperatorStringAppend) PartialMerge(key,
leftOperand, rightOperand []byte) ([]byte, bool) {
mo.m.Lock()
mo.numPartial++
mo.m.Unlock()
return []byte(string(leftOperand) + mo.Sep + string(rightOperand)), true
} | [
"func",
"(",
"mo",
"*",
"MergeOperatorStringAppend",
")",
"PartialMerge",
"(",
"key",
",",
"leftOperand",
",",
"rightOperand",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
")",
"{",
"mo",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"mo",
"... | // PartialMerge performs the partial merge of a string append operation | [
"PartialMerge",
"performs",
"the",
"partial",
"merge",
"of",
"a",
"string",
"append",
"operation"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/util_merge.go#L47-L54 |
20,154 | couchbase/moss | file.go | OnAfterClose | func (r *FileRef) OnAfterClose(cb func()) {
r.m.Lock()
r.afterCloseCallbacks = append(r.afterCloseCallbacks, cb)
r.m.Unlock()
} | go | func (r *FileRef) OnAfterClose(cb func()) {
r.m.Lock()
r.afterCloseCallbacks = append(r.afterCloseCallbacks, cb)
r.m.Unlock()
} | [
"func",
"(",
"r",
"*",
"FileRef",
")",
"OnAfterClose",
"(",
"cb",
"func",
"(",
")",
")",
"{",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"afterCloseCallbacks",
"=",
"append",
"(",
"r",
".",
"afterCloseCallbacks",
",",
"cb",
")",
"\n",
... | // OnAfterClose registers event callback func's that are invoked after the
// file is closed. | [
"OnAfterClose",
"registers",
"event",
"callback",
"func",
"s",
"that",
"are",
"invoked",
"after",
"the",
"file",
"is",
"closed",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/file.go#L70-L74 |
20,155 | couchbase/moss | file.go | AddRef | func (r *FileRef) AddRef() File {
if r == nil {
return nil
}
r.m.Lock()
r.refs++
file := r.file
r.m.Unlock()
return file
} | go | func (r *FileRef) AddRef() File {
if r == nil {
return nil
}
r.m.Lock()
r.refs++
file := r.file
r.m.Unlock()
return file
} | [
"func",
"(",
"r",
"*",
"FileRef",
")",
"AddRef",
"(",
")",
"File",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"refs",
"++",
"\n",
"file",
":=",
"r",
".",
"file... | // AddRef increases the ref-count on the file ref. | [
"AddRef",
"increases",
"the",
"ref",
"-",
"count",
"on",
"the",
"file",
"ref",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/file.go#L77-L88 |
20,156 | couchbase/moss | file.go | DecRef | func (r *FileRef) DecRef() (err error) {
if r == nil {
return nil
}
r.m.Lock()
r.refs--
if r.refs <= 0 {
for _, cb := range r.beforeCloseCallbacks {
cb()
}
r.beforeCloseCallbacks = nil
err = r.file.Close()
for _, cb := range r.afterCloseCallbacks {
cb()
}
r.afterCloseCallbacks = nil
r.... | go | func (r *FileRef) DecRef() (err error) {
if r == nil {
return nil
}
r.m.Lock()
r.refs--
if r.refs <= 0 {
for _, cb := range r.beforeCloseCallbacks {
cb()
}
r.beforeCloseCallbacks = nil
err = r.file.Close()
for _, cb := range r.afterCloseCallbacks {
cb()
}
r.afterCloseCallbacks = nil
r.... | [
"func",
"(",
"r",
"*",
"FileRef",
")",
"DecRef",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n\n",
"r",
".",
"refs",
"--",
"\n",
"if",
"r"... | // DecRef decreases the ref-count on the file ref, and closing the
// underlying file when the ref-count reaches zero. | [
"DecRef",
"decreases",
"the",
"ref",
"-",
"count",
"on",
"the",
"file",
"ref",
"and",
"closing",
"the",
"underlying",
"file",
"when",
"the",
"ref",
"-",
"count",
"reaches",
"zero",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/file.go#L92-L119 |
20,157 | couchbase/moss | file.go | FetchRefCount | func (r *FileRef) FetchRefCount() int {
if r == nil {
return 0
}
r.m.Lock()
ref := r.refs
r.m.Unlock()
return ref
} | go | func (r *FileRef) FetchRefCount() int {
if r == nil {
return 0
}
r.m.Lock()
ref := r.refs
r.m.Unlock()
return ref
} | [
"func",
"(",
"r",
"*",
"FileRef",
")",
"FetchRefCount",
"(",
")",
"int",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"ref",
":=",
"r",
".",
"refs",
"\n",
"r",
".",
"m",
"."... | // FetchRefCount fetches the ref-count on the file ref. | [
"FetchRefCount",
"fetches",
"the",
"ref",
"-",
"count",
"on",
"the",
"file",
"ref",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/file.go#L129-L139 |
20,158 | couchbase/moss | file.go | ToOsFile | func ToOsFile(f File) *os.File {
if osFile, ok := f.(*os.File); ok {
return osFile
}
if osFile2, ok := f.(OsFile); ok {
return osFile2.OsFile()
}
return nil
} | go | func ToOsFile(f File) *os.File {
if osFile, ok := f.(*os.File); ok {
return osFile
}
if osFile2, ok := f.(OsFile); ok {
return osFile2.OsFile()
}
return nil
} | [
"func",
"ToOsFile",
"(",
"f",
"File",
")",
"*",
"os",
".",
"File",
"{",
"if",
"osFile",
",",
"ok",
":=",
"f",
".",
"(",
"*",
"os",
".",
"File",
")",
";",
"ok",
"{",
"return",
"osFile",
"\n",
"}",
"\n",
"if",
"osFile2",
",",
"ok",
":=",
"f",
... | // ToOsFile provides the underlying os.File for a File, if available. | [
"ToOsFile",
"provides",
"the",
"underlying",
"os",
".",
"File",
"for",
"a",
"File",
"if",
"available",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/file.go#L149-L157 |
20,159 | couchbase/moss | segment_index.go | add | func (s *segmentKeysIndex) add(keyIdx int, key []byte) bool {
if s.numKeys >= s.numIndexableKeys {
// All keys that can be indexed already have been,
// return false indicating that there's no room for
// anymore.
return false
}
if len(key) > (len(s.data) - s.numKeyBytes) {
// No room for any more keys.
... | go | func (s *segmentKeysIndex) add(keyIdx int, key []byte) bool {
if s.numKeys >= s.numIndexableKeys {
// All keys that can be indexed already have been,
// return false indicating that there's no room for
// anymore.
return false
}
if len(key) > (len(s.data) - s.numKeyBytes) {
// No room for any more keys.
... | [
"func",
"(",
"s",
"*",
"segmentKeysIndex",
")",
"add",
"(",
"keyIdx",
"int",
",",
"key",
"[",
"]",
"byte",
")",
"bool",
"{",
"if",
"s",
".",
"numKeys",
">=",
"s",
".",
"numIndexableKeys",
"{",
"// All keys that can be indexed already have been,",
"// return fa... | // Adds a qualified entry to the index. Returns true if space
// still available, false otherwise. | [
"Adds",
"a",
"qualified",
"entry",
"to",
"the",
"index",
".",
"Returns",
"true",
"if",
"space",
"still",
"available",
"false",
"otherwise",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment_index.go#L72-L96 |
20,160 | couchbase/moss | segment_index.go | lookup | func (s *segmentKeysIndex) lookup(key []byte) (leftPos int, rightPos int) {
i, j := 0, s.numKeys
if i == j || s.numKeys < 2 {
// The index either wasn't used or isn't of any use.
rightPos = s.srcKeyCount
return
}
// If key smaller than the first key, return early.
keyStart := s.offsets[0]
keyEnd := s.offs... | go | func (s *segmentKeysIndex) lookup(key []byte) (leftPos int, rightPos int) {
i, j := 0, s.numKeys
if i == j || s.numKeys < 2 {
// The index either wasn't used or isn't of any use.
rightPos = s.srcKeyCount
return
}
// If key smaller than the first key, return early.
keyStart := s.offsets[0]
keyEnd := s.offs... | [
"func",
"(",
"s",
"*",
"segmentKeysIndex",
")",
"lookup",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"leftPos",
"int",
",",
"rightPos",
"int",
")",
"{",
"i",
",",
"j",
":=",
"0",
",",
"s",
".",
"numKeys",
"\n\n",
"if",
"i",
"==",
"j",
"||",
"s",
... | // Fetches the range of offsets between which the key exists,
// if present at all. The returned leftPos and rightPos can
// directly be used as the left and right extreme cursors
// while binary searching over the source segment. | [
"Fetches",
"the",
"range",
"of",
"offsets",
"between",
"which",
"the",
"key",
"exists",
"if",
"present",
"at",
"all",
".",
"The",
"returned",
"leftPos",
"and",
"rightPos",
"can",
"directly",
"be",
"used",
"as",
"the",
"left",
"and",
"right",
"extreme",
"cu... | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment_index.go#L102-L160 |
20,161 | couchbase/moss | segment_stack.go | AddTo | func (sss *SegmentStackStats) AddTo(dest *SegmentStackStats) {
if sss == nil {
return
}
dest.CurOps += sss.CurOps
dest.CurBytes += sss.CurBytes
dest.CurSegments += sss.CurSegments
} | go | func (sss *SegmentStackStats) AddTo(dest *SegmentStackStats) {
if sss == nil {
return
}
dest.CurOps += sss.CurOps
dest.CurBytes += sss.CurBytes
dest.CurSegments += sss.CurSegments
} | [
"func",
"(",
"sss",
"*",
"SegmentStackStats",
")",
"AddTo",
"(",
"dest",
"*",
"SegmentStackStats",
")",
"{",
"if",
"sss",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"dest",
".",
"CurOps",
"+=",
"sss",
".",
"CurOps",
"\n",
"dest",
".",
"CurBytes",
... | // AddTo adds the values from this SegmentStackStats to the dest
// SegmentStackStats. | [
"AddTo",
"adds",
"the",
"values",
"from",
"this",
"SegmentStackStats",
"to",
"the",
"dest",
"SegmentStackStats",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment_stack.go#L177-L185 |
20,162 | couchbase/moss | segment_stack.go | Stats | func (ss *segmentStack) Stats() *SegmentStackStats {
rv := &SegmentStackStats{CurSegments: uint64(len(ss.a))}
for _, seg := range ss.a {
rv.CurOps += uint64(seg.Len())
nk, nv := seg.NumKeyValBytes()
rv.CurBytes += nk + nv
}
return rv
} | go | func (ss *segmentStack) Stats() *SegmentStackStats {
rv := &SegmentStackStats{CurSegments: uint64(len(ss.a))}
for _, seg := range ss.a {
rv.CurOps += uint64(seg.Len())
nk, nv := seg.NumKeyValBytes()
rv.CurBytes += nk + nv
}
return rv
} | [
"func",
"(",
"ss",
"*",
"segmentStack",
")",
"Stats",
"(",
")",
"*",
"SegmentStackStats",
"{",
"rv",
":=",
"&",
"SegmentStackStats",
"{",
"CurSegments",
":",
"uint64",
"(",
"len",
"(",
"ss",
".",
"a",
")",
")",
"}",
"\n",
"for",
"_",
",",
"seg",
":... | // Stats returns the stats for this segment stack. | [
"Stats",
"returns",
"the",
"stats",
"for",
"this",
"segment",
"stack",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment_stack.go#L188-L196 |
20,163 | couchbase/moss | segment_stack.go | ensureFullySorted | func (ss *segmentStack) ensureFullySorted() {
ss.ensureSorted(0, len(ss.a)-1)
for _, childSnapshot := range ss.childSegStacks {
childSnapshot.ensureFullySorted()
}
} | go | func (ss *segmentStack) ensureFullySorted() {
ss.ensureSorted(0, len(ss.a)-1)
for _, childSnapshot := range ss.childSegStacks {
childSnapshot.ensureFullySorted()
}
} | [
"func",
"(",
"ss",
"*",
"segmentStack",
")",
"ensureFullySorted",
"(",
")",
"{",
"ss",
".",
"ensureSorted",
"(",
"0",
",",
"len",
"(",
"ss",
".",
"a",
")",
"-",
"1",
")",
"\n",
"for",
"_",
",",
"childSnapshot",
":=",
"range",
"ss",
".",
"childSegSt... | // ensureFullySorted recursively ensures that all child segmentStacks
// are sorted from 0 to end. | [
"ensureFullySorted",
"recursively",
"ensures",
"that",
"all",
"child",
"segmentStacks",
"are",
"sorted",
"from",
"0",
"to",
"end",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/segment_stack.go#L226-L231 |
20,164 | couchbase/moss | wrap.go | Get | func (w *SnapshotWrapper) Get(key []byte, readOptions ReadOptions) (
[]byte, error) {
return w.ss.Get(key, readOptions)
} | go | func (w *SnapshotWrapper) Get(key []byte, readOptions ReadOptions) (
[]byte, error) {
return w.ss.Get(key, readOptions)
} | [
"func",
"(",
"w",
"*",
"SnapshotWrapper",
")",
"Get",
"(",
"key",
"[",
"]",
"byte",
",",
"readOptions",
"ReadOptions",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"w",
".",
"ss",
".",
"Get",
"(",
"key",
",",
"readOptions",
")",
... | // Get returns the key from the underlying snapshot. | [
"Get",
"returns",
"the",
"key",
"from",
"the",
"underlying",
"snapshot",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/wrap.go#L93-L96 |
20,165 | couchbase/moss | wrap.go | StartIterator | func (w *SnapshotWrapper) StartIterator(
startKeyInclusive, endKeyExclusive []byte,
iteratorOptions IteratorOptions,
) (Iterator, error) {
return w.ss.StartIterator(startKeyInclusive, endKeyExclusive,
iteratorOptions)
} | go | func (w *SnapshotWrapper) StartIterator(
startKeyInclusive, endKeyExclusive []byte,
iteratorOptions IteratorOptions,
) (Iterator, error) {
return w.ss.StartIterator(startKeyInclusive, endKeyExclusive,
iteratorOptions)
} | [
"func",
"(",
"w",
"*",
"SnapshotWrapper",
")",
"StartIterator",
"(",
"startKeyInclusive",
",",
"endKeyExclusive",
"[",
"]",
"byte",
",",
"iteratorOptions",
"IteratorOptions",
",",
")",
"(",
"Iterator",
",",
"error",
")",
"{",
"return",
"w",
".",
"ss",
".",
... | // StartIterator initiates a start iterator over the underlying snapshot. | [
"StartIterator",
"initiates",
"a",
"start",
"iterator",
"over",
"the",
"underlying",
"snapshot",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/wrap.go#L99-L105 |
20,166 | couchbase/moss | store_api.go | AddRef | func (slocs SegmentLocs) AddRef() {
for _, sloc := range slocs {
if sloc.mref != nil {
sloc.mref.AddRef()
}
}
} | go | func (slocs SegmentLocs) AddRef() {
for _, sloc := range slocs {
if sloc.mref != nil {
sloc.mref.AddRef()
}
}
} | [
"func",
"(",
"slocs",
"SegmentLocs",
")",
"AddRef",
"(",
")",
"{",
"for",
"_",
",",
"sloc",
":=",
"range",
"slocs",
"{",
"if",
"sloc",
".",
"mref",
"!=",
"nil",
"{",
"sloc",
".",
"mref",
".",
"AddRef",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
... | // AddRef increases the ref count on each SegmentLoc in this SegmentLocs | [
"AddRef",
"increases",
"the",
"ref",
"count",
"on",
"each",
"SegmentLoc",
"in",
"this",
"SegmentLocs"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_api.go#L200-L206 |
20,167 | couchbase/moss | store_api.go | DecRef | func (slocs SegmentLocs) DecRef() {
for _, sloc := range slocs {
if sloc.mref != nil {
sloc.mref.DecRef()
}
}
} | go | func (slocs SegmentLocs) DecRef() {
for _, sloc := range slocs {
if sloc.mref != nil {
sloc.mref.DecRef()
}
}
} | [
"func",
"(",
"slocs",
"SegmentLocs",
")",
"DecRef",
"(",
")",
"{",
"for",
"_",
",",
"sloc",
":=",
"range",
"slocs",
"{",
"if",
"sloc",
".",
"mref",
"!=",
"nil",
"{",
"sloc",
".",
"mref",
".",
"DecRef",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
... | // DecRef decreases the ref count on each SegmentLoc in this SegmentLocs | [
"DecRef",
"decreases",
"the",
"ref",
"count",
"on",
"each",
"SegmentLoc",
"in",
"this",
"SegmentLocs"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_api.go#L209-L215 |
20,168 | couchbase/moss | store_api.go | AddRef | func (s *Store) AddRef() {
s.m.Lock()
s.refs++
s.m.Unlock()
} | go | func (s *Store) AddRef() {
s.m.Lock()
s.refs++
s.m.Unlock()
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"AddRef",
"(",
")",
"{",
"s",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"refs",
"++",
"\n",
"s",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // AddRef increases the ref count on this store | [
"AddRef",
"increases",
"the",
"ref",
"count",
"on",
"this",
"store"
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_api.go#L280-L284 |
20,169 | couchbase/moss | store_api.go | Close | func (s *Store) Close() error {
s.m.Lock()
defer s.m.Unlock()
s.refs--
if s.refs > 0 || s.footer == nil {
return nil
}
footer := s.footer
s.footer = nil
return footer.Close()
} | go | func (s *Store) Close() error {
s.m.Lock()
defer s.m.Unlock()
s.refs--
if s.refs > 0 || s.footer == nil {
return nil
}
footer := s.footer
s.footer = nil
return footer.Close()
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Close",
"(",
")",
"error",
"{",
"s",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"refs",
"--",
"\n",
"if",
"s",
".",
"refs",
">",
"0",
"||... | // Close decreases the ref count on this store, and if the count is 0
// proceeds to actually close the store. | [
"Close",
"decreases",
"the",
"ref",
"count",
"on",
"this",
"store",
"and",
"if",
"the",
"count",
"is",
"0",
"proceeds",
"to",
"actually",
"close",
"the",
"store",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_api.go#L288-L301 |
20,170 | couchbase/moss | store_api.go | CloseEx | func (s *Store) CloseEx(options StoreCloseExOptions) error {
if options.Abort {
close(s.abortCh)
}
return s.Close()
} | go | func (s *Store) CloseEx(options StoreCloseExOptions) error {
if options.Abort {
close(s.abortCh)
}
return s.Close()
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"CloseEx",
"(",
"options",
"StoreCloseExOptions",
")",
"error",
"{",
"if",
"options",
".",
"Abort",
"{",
"close",
"(",
"s",
".",
"abortCh",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"Close",
"(",
")",
"\n",
"}"
... | // CloseEx provides more advanced closing options. | [
"CloseEx",
"provides",
"more",
"advanced",
"closing",
"options",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/store_api.go#L304-L309 |
20,171 | couchbase/moss | smat.go | delta | func delta(cb func(c *smatContext)) func(ctx smat.Context) (next smat.State, err error) {
return func(ctx smat.Context) (next smat.State, err error) {
c := ctx.(*smatContext)
cb(c)
if c.curBatch < 0 {
c.curBatch = 1000
}
if c.curSnapshot < 0 {
c.curSnapshot = 1000
}
if c.curIterator < 0 {
c.curI... | go | func delta(cb func(c *smatContext)) func(ctx smat.Context) (next smat.State, err error) {
return func(ctx smat.Context) (next smat.State, err error) {
c := ctx.(*smatContext)
cb(c)
if c.curBatch < 0 {
c.curBatch = 1000
}
if c.curSnapshot < 0 {
c.curSnapshot = 1000
}
if c.curIterator < 0 {
c.curI... | [
"func",
"delta",
"(",
"cb",
"func",
"(",
"c",
"*",
"smatContext",
")",
")",
"func",
"(",
"ctx",
"smat",
".",
"Context",
")",
"(",
"next",
"smat",
".",
"State",
",",
"err",
"error",
")",
"{",
"return",
"func",
"(",
"ctx",
"smat",
".",
"Context",
"... | // Creates an action func based on a callback, used for moving the curXxxx properties. | [
"Creates",
"an",
"action",
"func",
"based",
"on",
"a",
"callback",
"used",
"for",
"moving",
"the",
"curXxxx",
"properties",
"."
] | a0cae174c4987cb28c071e0796e25b58834108d8 | https://github.com/couchbase/moss/blob/a0cae174c4987cb28c071e0796e25b58834108d8/smat.go#L142-L160 |
20,172 | qiangxue/fasthttp-routing | router.go | HandleRequest | func (r *Router) HandleRequest(ctx *fasthttp.RequestCtx) {
c := r.pool.Get().(*Context)
c.init(ctx)
c.handlers, c.pnames = r.find(string(ctx.Method()), string(ctx.Path()), c.pvalues)
if err := c.Next(); err != nil {
r.handleError(c, err)
}
r.pool.Put(c)
} | go | func (r *Router) HandleRequest(ctx *fasthttp.RequestCtx) {
c := r.pool.Get().(*Context)
c.init(ctx)
c.handlers, c.pnames = r.find(string(ctx.Method()), string(ctx.Path()), c.pvalues)
if err := c.Next(); err != nil {
r.handleError(c, err)
}
r.pool.Put(c)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"HandleRequest",
"(",
"ctx",
"*",
"fasthttp",
".",
"RequestCtx",
")",
"{",
"c",
":=",
"r",
".",
"pool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Context",
")",
"\n",
"c",
".",
"init",
"(",
"ctx",
")",
"\n",
... | // HandleRequest handles the HTTP request. | [
"HandleRequest",
"handles",
"the",
"HTTP",
"request",
"."
] | 6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71 | https://github.com/qiangxue/fasthttp-routing/blob/6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71/router.go#L71-L79 |
20,173 | qiangxue/fasthttp-routing | router.go | handleError | func (r *Router) handleError(c *Context, err error) {
if httpError, ok := err.(HTTPError); ok {
c.Error(httpError.Error(), httpError.StatusCode())
} else {
c.Error(err.Error(), http.StatusInternalServerError)
}
} | go | func (r *Router) handleError(c *Context, err error) {
if httpError, ok := err.(HTTPError); ok {
c.Error(httpError.Error(), httpError.StatusCode())
} else {
c.Error(err.Error(), http.StatusInternalServerError)
}
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"handleError",
"(",
"c",
"*",
"Context",
",",
"err",
"error",
")",
"{",
"if",
"httpError",
",",
"ok",
":=",
"err",
".",
"(",
"HTTPError",
")",
";",
"ok",
"{",
"c",
".",
"Error",
"(",
"httpError",
".",
"Error"... | // handleError is the error handler for handling any unhandled errors. | [
"handleError",
"is",
"the",
"error",
"handler",
"for",
"handling",
"any",
"unhandled",
"errors",
"."
] | 6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71 | https://github.com/qiangxue/fasthttp-routing/blob/6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71/router.go#L101-L107 |
20,174 | qiangxue/fasthttp-routing | group.go | Patch | func (r *RouteGroup) Patch(path string, handlers ...Handler) *Route {
return newRoute(path, r).Patch(handlers...)
} | go | func (r *RouteGroup) Patch(path string, handlers ...Handler) *Route {
return newRoute(path, r).Patch(handlers...)
} | [
"func",
"(",
"r",
"*",
"RouteGroup",
")",
"Patch",
"(",
"path",
"string",
",",
"handlers",
"...",
"Handler",
")",
"*",
"Route",
"{",
"return",
"newRoute",
"(",
"path",
",",
"r",
")",
".",
"Patch",
"(",
"handlers",
"...",
")",
"\n",
"}"
] | // Patch adds a PATCH route to the router with the given route path and handlers. | [
"Patch",
"adds",
"a",
"PATCH",
"route",
"to",
"the",
"router",
"with",
"the",
"given",
"route",
"path",
"and",
"handlers",
"."
] | 6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71 | https://github.com/qiangxue/fasthttp-routing/blob/6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71/group.go#L43-L45 |
20,175 | qiangxue/fasthttp-routing | context.go | URL | func (c *Context) URL(route string, pairs ...interface{}) string {
if r := c.router.routes[route]; r != nil {
return r.URL(pairs...)
}
return ""
} | go | func (c *Context) URL(route string, pairs ...interface{}) string {
if r := c.router.routes[route]; r != nil {
return r.URL(pairs...)
}
return ""
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"URL",
"(",
"route",
"string",
",",
"pairs",
"...",
"interface",
"{",
"}",
")",
"string",
"{",
"if",
"r",
":=",
"c",
".",
"router",
".",
"routes",
"[",
"route",
"]",
";",
"r",
"!=",
"nil",
"{",
"return",
"... | // URL creates a URL using the named route and the parameter values.
// The parameters should be given in the sequence of name1, value1, name2, value2, and so on.
// If a parameter in the route is not provided a value, the parameter token will remain in the resulting URL.
// Parameter values will be properly URL encode... | [
"URL",
"creates",
"a",
"URL",
"using",
"the",
"named",
"route",
"and",
"the",
"parameter",
"values",
".",
"The",
"parameters",
"should",
"be",
"given",
"in",
"the",
"sequence",
"of",
"name1",
"value1",
"name2",
"value2",
"and",
"so",
"on",
".",
"If",
"a"... | 6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71 | https://github.com/qiangxue/fasthttp-routing/blob/6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71/context.go#L86-L91 |
20,176 | qiangxue/fasthttp-routing | context.go | Serialize | func Serialize(data interface{}) (bytes []byte, err error) {
switch data.(type) {
case []byte:
return data.([]byte), nil
case string:
return []byte(data.(string)), nil
default:
if data != nil {
return []byte(fmt.Sprint(data)), nil
}
}
return nil, nil
} | go | func Serialize(data interface{}) (bytes []byte, err error) {
switch data.(type) {
case []byte:
return data.([]byte), nil
case string:
return []byte(data.(string)), nil
default:
if data != nil {
return []byte(fmt.Sprint(data)), nil
}
}
return nil, nil
} | [
"func",
"Serialize",
"(",
"data",
"interface",
"{",
"}",
")",
"(",
"bytes",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"switch",
"data",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"byte",
":",
"return",
"data",
".",
"(",
"[",
"]",
"byt... | // Serialize converts the given data into a byte array.
// If the data is neither a byte array nor a string, it will call fmt.Sprint to convert it into a string. | [
"Serialize",
"converts",
"the",
"given",
"data",
"into",
"a",
"byte",
"array",
".",
"If",
"the",
"data",
"is",
"neither",
"a",
"byte",
"array",
"nor",
"a",
"string",
"it",
"will",
"call",
"fmt",
".",
"Sprint",
"to",
"convert",
"it",
"into",
"a",
"strin... | 6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71 | https://github.com/qiangxue/fasthttp-routing/blob/6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71/context.go#L114-L126 |
20,177 | qiangxue/fasthttp-routing | route.go | add | func (r *Route) add(method string, handlers []Handler) *Route {
hh := combineHandlers(r.group.handlers, handlers)
r.group.router.add(method, r.path, hh)
return r
} | go | func (r *Route) add(method string, handlers []Handler) *Route {
hh := combineHandlers(r.group.handlers, handlers)
r.group.router.add(method, r.path, hh)
return r
} | [
"func",
"(",
"r",
"*",
"Route",
")",
"add",
"(",
"method",
"string",
",",
"handlers",
"[",
"]",
"Handler",
")",
"*",
"Route",
"{",
"hh",
":=",
"combineHandlers",
"(",
"r",
".",
"group",
".",
"handlers",
",",
"handlers",
")",
"\n",
"r",
".",
"group"... | // add registers the route, the specified HTTP method and the handlers to the router.
// The handlers will be combined with the handlers of the route group. | [
"add",
"registers",
"the",
"route",
"the",
"specified",
"HTTP",
"method",
"and",
"the",
"handlers",
"to",
"the",
"router",
".",
"The",
"handlers",
"will",
"be",
"combined",
"with",
"the",
"handlers",
"of",
"the",
"route",
"group",
"."
] | 6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71 | https://github.com/qiangxue/fasthttp-routing/blob/6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71/route.go#L122-L126 |
20,178 | qiangxue/fasthttp-routing | route.go | buildURLTemplate | func buildURLTemplate(path string) string {
template, start, end := "", -1, -1
for i := 0; i < len(path); i++ {
if path[i] == '<' && start < 0 {
start = i
} else if path[i] == '>' && start >= 0 {
name := path[start+1 : i]
for j := start + 1; j < i; j++ {
if path[j] == ':' {
name = path[start+1 :... | go | func buildURLTemplate(path string) string {
template, start, end := "", -1, -1
for i := 0; i < len(path); i++ {
if path[i] == '<' && start < 0 {
start = i
} else if path[i] == '>' && start >= 0 {
name := path[start+1 : i]
for j := start + 1; j < i; j++ {
if path[j] == ':' {
name = path[start+1 :... | [
"func",
"buildURLTemplate",
"(",
"path",
"string",
")",
"string",
"{",
"template",
",",
"start",
",",
"end",
":=",
"\"",
"\"",
",",
"-",
"1",
",",
"-",
"1",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"path",
")",
";",
"i",
"++",
... | // buildURLTemplate converts a route pattern into a URL template by removing regular expressions in parameter tokens. | [
"buildURLTemplate",
"converts",
"a",
"route",
"pattern",
"into",
"a",
"URL",
"template",
"by",
"removing",
"regular",
"expressions",
"in",
"parameter",
"tokens",
"."
] | 6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71 | https://github.com/qiangxue/fasthttp-routing/blob/6ccdc2a18d8712f842de50ddcb8c9a3d025ddc71/route.go#L129-L153 |
20,179 | gen2brain/beeep | beep_unix.go | ioctl | func ioctl(fd, name, data uintptr) error {
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(name), uintptr(data))
if e != 0 {
return e
}
return nil
} | go | func ioctl(fd, name, data uintptr) error {
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(name), uintptr(data))
if e != 0 {
return e
}
return nil
} | [
"func",
"ioctl",
"(",
"fd",
",",
"name",
",",
"data",
"uintptr",
")",
"error",
"{",
"_",
",",
"_",
",",
"e",
":=",
"syscall",
".",
"Syscall",
"(",
"syscall",
".",
"SYS_IOCTL",
",",
"fd",
",",
"uintptr",
"(",
"name",
")",
",",
"uintptr",
"(",
"dat... | // ioctl system call manipulates the underlying device parameters of special files. | [
"ioctl",
"system",
"call",
"manipulates",
"the",
"underlying",
"device",
"parameters",
"of",
"special",
"files",
"."
] | aa3d7c1499fd45bc0160d65471e4a182dce73570 | https://github.com/gen2brain/beeep/blob/aa3d7c1499fd45bc0160d65471e4a182dce73570/beep_unix.go#L43-L50 |
20,180 | gen2brain/beeep | notify_js.go | Notify | func Notify(title, message, appIcon string) (err error) {
defer func() {
e := recover()
if e == nil {
return
}
if e, ok := e.(*js.Error); ok {
err = e
} else {
panic(e)
}
}()
n := js.Global().Get("Notification")
opts := js.Global().Get("Object").Invoke()
opts.Set("body", message)
opts.Set... | go | func Notify(title, message, appIcon string) (err error) {
defer func() {
e := recover()
if e == nil {
return
}
if e, ok := e.(*js.Error); ok {
err = e
} else {
panic(e)
}
}()
n := js.Global().Get("Notification")
opts := js.Global().Get("Object").Invoke()
opts.Set("body", message)
opts.Set... | [
"func",
"Notify",
"(",
"title",
",",
"message",
",",
"appIcon",
"string",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"e",
":=",
"recover",
"(",
")",
"\n\n",
"if",
"e",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
... | // Notify sends desktop notification.
//
// On Web, in Firefox it just works, in Chrome you must call it from some "user gesture" like `onclick`,
// and you must use TLS certificate, it doesn't work with plain http. | [
"Notify",
"sends",
"desktop",
"notification",
".",
"On",
"Web",
"in",
"Firefox",
"it",
"just",
"works",
"in",
"Chrome",
"you",
"must",
"call",
"it",
"from",
"some",
"user",
"gesture",
"like",
"onclick",
"and",
"you",
"must",
"use",
"TLS",
"certificate",
"i... | aa3d7c1499fd45bc0160d65471e4a182dce73570 | https://github.com/gen2brain/beeep/blob/aa3d7c1499fd45bc0160d65471e4a182dce73570/notify_js.go#L13-L49 |
20,181 | gen2brain/beeep | alert_js.go | Alert | func Alert(title, message, appIcon string) error {
if err := Notify(title, message, appIcon); err != nil {
return err
}
return Beep(DefaultFreq, DefaultDuration)
} | go | func Alert(title, message, appIcon string) error {
if err := Notify(title, message, appIcon); err != nil {
return err
}
return Beep(DefaultFreq, DefaultDuration)
} | [
"func",
"Alert",
"(",
"title",
",",
"message",
",",
"appIcon",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"Notify",
"(",
"title",
",",
"message",
",",
"appIcon",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"B... | // Alert displays a desktop notification and plays a beep. | [
"Alert",
"displays",
"a",
"desktop",
"notification",
"and",
"plays",
"a",
"beep",
"."
] | aa3d7c1499fd45bc0160d65471e4a182dce73570 | https://github.com/gen2brain/beeep/blob/aa3d7c1499fd45bc0160d65471e4a182dce73570/alert_js.go#L6-L11 |
20,182 | gen2brain/beeep | notify_unix.go | Notify | func Notify(title, message, appIcon string) error {
appIcon = pathAbs(appIcon)
cmd := func() error {
send, err := exec.LookPath("sw-notify-send")
if err != nil {
send, err = exec.LookPath("notify-send")
if err != nil {
return err
}
}
c := exec.Command(send, title, message, "-i", appIcon)
retu... | go | func Notify(title, message, appIcon string) error {
appIcon = pathAbs(appIcon)
cmd := func() error {
send, err := exec.LookPath("sw-notify-send")
if err != nil {
send, err = exec.LookPath("notify-send")
if err != nil {
return err
}
}
c := exec.Command(send, title, message, "-i", appIcon)
retu... | [
"func",
"Notify",
"(",
"title",
",",
"message",
",",
"appIcon",
"string",
")",
"error",
"{",
"appIcon",
"=",
"pathAbs",
"(",
"appIcon",
")",
"\n\n",
"cmd",
":=",
"func",
"(",
")",
"error",
"{",
"send",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
... | // Notify sends desktop notification.
//
// On Linux it tries to send notification via D-Bus and it will fallback to `notify-send` binary. | [
"Notify",
"sends",
"desktop",
"notification",
".",
"On",
"Linux",
"it",
"tries",
"to",
"send",
"notification",
"via",
"D",
"-",
"Bus",
"and",
"it",
"will",
"fallback",
"to",
"notify",
"-",
"send",
"binary",
"."
] | aa3d7c1499fd45bc0160d65471e4a182dce73570 | https://github.com/gen2brain/beeep/blob/aa3d7c1499fd45bc0160d65471e4a182dce73570/notify_unix.go#L15-L61 |
20,183 | gen2brain/beeep | notify_windows.go | Notify | func Notify(title, message, appIcon string) error {
if isWindows10 {
return toastNotify(title, message, appIcon)
}
err := baloonNotify(title, message, appIcon, false)
if err != nil {
e := msgNotify(title, message)
if e != nil {
return errors.New("beeep: " + err.Error() + "; " + e.Error())
}
}
return ... | go | func Notify(title, message, appIcon string) error {
if isWindows10 {
return toastNotify(title, message, appIcon)
}
err := baloonNotify(title, message, appIcon, false)
if err != nil {
e := msgNotify(title, message)
if e != nil {
return errors.New("beeep: " + err.Error() + "; " + e.Error())
}
}
return ... | [
"func",
"Notify",
"(",
"title",
",",
"message",
",",
"appIcon",
"string",
")",
"error",
"{",
"if",
"isWindows10",
"{",
"return",
"toastNotify",
"(",
"title",
",",
"message",
",",
"appIcon",
")",
"\n",
"}",
"\n\n",
"err",
":=",
"baloonNotify",
"(",
"title... | // Notify sends desktop notification. | [
"Notify",
"sends",
"desktop",
"notification",
"."
] | aa3d7c1499fd45bc0160d65471e4a182dce73570 | https://github.com/gen2brain/beeep/blob/aa3d7c1499fd45bc0160d65471e4a182dce73570/notify_windows.go#L42-L57 |
20,184 | cbednarski/hostess | hostname.go | LooksLikeIPv6 | func LooksLikeIPv6(ip string) bool {
if !strings.Contains(ip, ":") {
return false
}
return ipv6Pattern.MatchString(ip)
} | go | func LooksLikeIPv6(ip string) bool {
if !strings.Contains(ip, ":") {
return false
}
return ipv6Pattern.MatchString(ip)
} | [
"func",
"LooksLikeIPv6",
"(",
"ip",
"string",
")",
"bool",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"ip",
",",
"\"",
"\"",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"ipv6Pattern",
".",
"MatchString",
"(",
"ip",
")",
"\n",
"}"
] | // LooksLikeIPv6 returns true if the IP looks like it's IPv6. This does not
// validate whether the string is a valid IP address. | [
"LooksLikeIPv6",
"returns",
"true",
"if",
"the",
"IP",
"looks",
"like",
"it",
"s",
"IPv6",
".",
"This",
"does",
"not",
"validate",
"whether",
"the",
"string",
"is",
"a",
"valid",
"IP",
"address",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostname.go#L21-L26 |
20,185 | cbednarski/hostess | hostname.go | NewHostname | func NewHostname(domain, ip string, enabled bool) (*Hostname, error) {
if !LooksLikeIPv4(ip) && !LooksLikeIPv6(ip) {
return nil, fmt.Errorf("Unable to parse IP address %q", ip)
}
IP := net.ParseIP(ip)
return &Hostname{domain, IP, enabled, LooksLikeIPv6(ip)}, nil
} | go | func NewHostname(domain, ip string, enabled bool) (*Hostname, error) {
if !LooksLikeIPv4(ip) && !LooksLikeIPv6(ip) {
return nil, fmt.Errorf("Unable to parse IP address %q", ip)
}
IP := net.ParseIP(ip)
return &Hostname{domain, IP, enabled, LooksLikeIPv6(ip)}, nil
} | [
"func",
"NewHostname",
"(",
"domain",
",",
"ip",
"string",
",",
"enabled",
"bool",
")",
"(",
"*",
"Hostname",
",",
"error",
")",
"{",
"if",
"!",
"LooksLikeIPv4",
"(",
"ip",
")",
"&&",
"!",
"LooksLikeIPv6",
"(",
"ip",
")",
"{",
"return",
"nil",
",",
... | // NewHostname creates a new Hostname struct and automatically sets the IPv6
// field based on the IP you pass in. | [
"NewHostname",
"creates",
"a",
"new",
"Hostname",
"struct",
"and",
"automatically",
"sets",
"the",
"IPv6",
"field",
"based",
"on",
"the",
"IP",
"you",
"pass",
"in",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostname.go#L44-L50 |
20,186 | cbednarski/hostess | hostname.go | MustHostname | func MustHostname(domain, ip string, enabled bool) *Hostname {
hostname, err := NewHostname(domain, ip, enabled)
if err != nil {
panic(err)
}
return hostname
} | go | func MustHostname(domain, ip string, enabled bool) *Hostname {
hostname, err := NewHostname(domain, ip, enabled)
if err != nil {
panic(err)
}
return hostname
} | [
"func",
"MustHostname",
"(",
"domain",
",",
"ip",
"string",
",",
"enabled",
"bool",
")",
"*",
"Hostname",
"{",
"hostname",
",",
"err",
":=",
"NewHostname",
"(",
"domain",
",",
"ip",
",",
"enabled",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"... | // MustHostname calls NewHostname but panics if there is an error parsing it. | [
"MustHostname",
"calls",
"NewHostname",
"but",
"panics",
"if",
"there",
"is",
"an",
"error",
"parsing",
"it",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostname.go#L53-L59 |
20,187 | cbednarski/hostess | hostname.go | Equal | func (h *Hostname) Equal(n *Hostname) bool {
return h.Domain == n.Domain && h.IP.Equal(n.IP)
} | go | func (h *Hostname) Equal(n *Hostname) bool {
return h.Domain == n.Domain && h.IP.Equal(n.IP)
} | [
"func",
"(",
"h",
"*",
"Hostname",
")",
"Equal",
"(",
"n",
"*",
"Hostname",
")",
"bool",
"{",
"return",
"h",
".",
"Domain",
"==",
"n",
".",
"Domain",
"&&",
"h",
".",
"IP",
".",
"Equal",
"(",
"n",
".",
"IP",
")",
"\n",
"}"
] | // Equal compares two Hostnames. Note that only the Domain and IP fields are
// compared because Enabled is transient state, and IPv6 should be set
// automatically based on IP. | [
"Equal",
"compares",
"two",
"Hostnames",
".",
"Note",
"that",
"only",
"the",
"Domain",
"and",
"IP",
"fields",
"are",
"compared",
"because",
"Enabled",
"is",
"transient",
"state",
"and",
"IPv6",
"should",
"be",
"set",
"automatically",
"based",
"on",
"IP",
"."... | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostname.go#L64-L66 |
20,188 | cbednarski/hostess | hostname.go | EqualIP | func (h *Hostname) EqualIP(ip net.IP) bool {
return h.IP.Equal(ip)
} | go | func (h *Hostname) EqualIP(ip net.IP) bool {
return h.IP.Equal(ip)
} | [
"func",
"(",
"h",
"*",
"Hostname",
")",
"EqualIP",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"return",
"h",
".",
"IP",
".",
"Equal",
"(",
"ip",
")",
"\n",
"}"
] | // EqualIP compares an IP against this Hostname. | [
"EqualIP",
"compares",
"an",
"IP",
"against",
"this",
"Hostname",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/hostname.go#L69-L71 |
20,189 | cbednarski/hostess | commands.go | AnyBool | func AnyBool(c *cli.Context, key string) bool {
return c.Bool(key) || c.GlobalBool(key)
} | go | func AnyBool(c *cli.Context, key string) bool {
return c.Bool(key) || c.GlobalBool(key)
} | [
"func",
"AnyBool",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"key",
"string",
")",
"bool",
"{",
"return",
"c",
".",
"Bool",
"(",
"key",
")",
"||",
"c",
".",
"GlobalBool",
"(",
"key",
")",
"\n",
"}"
] | // AnyBool checks whether a boolean CLI flag is set either globally or on this
// individual command. This provides more flexible flag parsing behavior. | [
"AnyBool",
"checks",
"whether",
"a",
"boolean",
"CLI",
"flag",
"is",
"set",
"either",
"globally",
"or",
"on",
"this",
"individual",
"command",
".",
"This",
"provides",
"more",
"flexible",
"flag",
"parsing",
"behavior",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L15-L17 |
20,190 | cbednarski/hostess | commands.go | MaybeErrorln | func MaybeErrorln(c *cli.Context, message string) {
if !AnyBool(c, "s") {
os.Stderr.WriteString(fmt.Sprintf("%s\n", message))
}
} | go | func MaybeErrorln(c *cli.Context, message string) {
if !AnyBool(c, "s") {
os.Stderr.WriteString(fmt.Sprintf("%s\n", message))
}
} | [
"func",
"MaybeErrorln",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"message",
"string",
")",
"{",
"if",
"!",
"AnyBool",
"(",
"c",
",",
"\"",
"\"",
")",
"{",
"os",
".",
"Stderr",
".",
"WriteString",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\... | // MaybeErrorln will print an error message unless -s is passed | [
"MaybeErrorln",
"will",
"print",
"an",
"error",
"message",
"unless",
"-",
"s",
"is",
"passed"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L24-L28 |
20,191 | cbednarski/hostess | commands.go | MaybeError | func MaybeError(c *cli.Context, message string) {
MaybeErrorln(c, message)
os.Exit(1)
} | go | func MaybeError(c *cli.Context, message string) {
MaybeErrorln(c, message)
os.Exit(1)
} | [
"func",
"MaybeError",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"message",
"string",
")",
"{",
"MaybeErrorln",
"(",
"c",
",",
"message",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
] | // MaybeError will print an error message unless -s is passed and then exit | [
"MaybeError",
"will",
"print",
"an",
"error",
"message",
"unless",
"-",
"s",
"is",
"passed",
"and",
"then",
"exit"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L31-L34 |
20,192 | cbednarski/hostess | commands.go | MaybePrintln | func MaybePrintln(c *cli.Context, message string) {
if !AnyBool(c, "q") && !AnyBool(c, "s") {
fmt.Println(message)
}
} | go | func MaybePrintln(c *cli.Context, message string) {
if !AnyBool(c, "q") && !AnyBool(c, "s") {
fmt.Println(message)
}
} | [
"func",
"MaybePrintln",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"message",
"string",
")",
"{",
"if",
"!",
"AnyBool",
"(",
"c",
",",
"\"",
"\"",
")",
"&&",
"!",
"AnyBool",
"(",
"c",
",",
"\"",
"\"",
")",
"{",
"fmt",
".",
"Println",
"(",
"mess... | // MaybePrintln will print a message unless -q or -s is passed | [
"MaybePrintln",
"will",
"print",
"a",
"message",
"unless",
"-",
"q",
"or",
"-",
"s",
"is",
"passed"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L37-L41 |
20,193 | cbednarski/hostess | commands.go | MaybeLoadHostFile | func MaybeLoadHostFile(c *cli.Context) *Hostfile {
hostsfile, errs := LoadHostfile()
if len(errs) > 0 && !AnyBool(c, "f") {
for _, err := range errs {
MaybeErrorln(c, err.Error())
}
MaybeError(c, "Errors while parsing hostsfile. Try hostess fix")
}
return hostsfile
} | go | func MaybeLoadHostFile(c *cli.Context) *Hostfile {
hostsfile, errs := LoadHostfile()
if len(errs) > 0 && !AnyBool(c, "f") {
for _, err := range errs {
MaybeErrorln(c, err.Error())
}
MaybeError(c, "Errors while parsing hostsfile. Try hostess fix")
}
return hostsfile
} | [
"func",
"MaybeLoadHostFile",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"*",
"Hostfile",
"{",
"hostsfile",
",",
"errs",
":=",
"LoadHostfile",
"(",
")",
"\n",
"if",
"len",
"(",
"errs",
")",
">",
"0",
"&&",
"!",
"AnyBool",
"(",
"c",
",",
"\"",
"\"",
... | // MaybeLoadHostFile will try to load, parse, and return a Hostfile. If we
// encounter errors we will terminate, unless -f is passed. | [
"MaybeLoadHostFile",
"will",
"try",
"to",
"load",
"parse",
"and",
"return",
"a",
"Hostfile",
".",
"If",
"we",
"encounter",
"errors",
"we",
"will",
"terminate",
"unless",
"-",
"f",
"is",
"passed",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L45-L54 |
20,194 | cbednarski/hostess | commands.go | AlwaysLoadHostFile | func AlwaysLoadHostFile(c *cli.Context) *Hostfile {
hostsfile, errs := LoadHostfile()
if len(errs) > 0 {
for _, err := range errs {
MaybeErrorln(c, err.Error())
}
}
return hostsfile
} | go | func AlwaysLoadHostFile(c *cli.Context) *Hostfile {
hostsfile, errs := LoadHostfile()
if len(errs) > 0 {
for _, err := range errs {
MaybeErrorln(c, err.Error())
}
}
return hostsfile
} | [
"func",
"AlwaysLoadHostFile",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"*",
"Hostfile",
"{",
"hostsfile",
",",
"errs",
":=",
"LoadHostfile",
"(",
")",
"\n",
"if",
"len",
"(",
"errs",
")",
">",
"0",
"{",
"for",
"_",
",",
"err",
":=",
"range",
"err... | // AlwaysLoadHostFile will load, parse, and return a Hostfile. If we encouter
// errors they will be printed to the terminal, but we'll try to continue. | [
"AlwaysLoadHostFile",
"will",
"load",
"parse",
"and",
"return",
"a",
"Hostfile",
".",
"If",
"we",
"encouter",
"errors",
"they",
"will",
"be",
"printed",
"to",
"the",
"terminal",
"but",
"we",
"ll",
"try",
"to",
"continue",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L58-L66 |
20,195 | cbednarski/hostess | commands.go | MaybeSaveHostFile | func MaybeSaveHostFile(c *cli.Context, hostfile *Hostfile) {
// If -n is passed, no-op and output the resultant hosts file to stdout.
// Otherwise it's for real and we're going to write it.
if AnyBool(c, "n") {
fmt.Printf("%s", hostfile.Format())
} else {
err := hostfile.Save()
if err != nil {
MaybeError(c... | go | func MaybeSaveHostFile(c *cli.Context, hostfile *Hostfile) {
// If -n is passed, no-op and output the resultant hosts file to stdout.
// Otherwise it's for real and we're going to write it.
if AnyBool(c, "n") {
fmt.Printf("%s", hostfile.Format())
} else {
err := hostfile.Save()
if err != nil {
MaybeError(c... | [
"func",
"MaybeSaveHostFile",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"hostfile",
"*",
"Hostfile",
")",
"{",
"// If -n is passed, no-op and output the resultant hosts file to stdout.",
"// Otherwise it's for real and we're going to write it.",
"if",
"AnyBool",
"(",
"c",
","... | // MaybeSaveHostFile will output or write the Hostfile, or exit 1 and error. | [
"MaybeSaveHostFile",
"will",
"output",
"or",
"write",
"the",
"Hostfile",
"or",
"exit",
"1",
"and",
"error",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L69-L80 |
20,196 | cbednarski/hostess | commands.go | StrPadRight | func StrPadRight(s string, l int) string {
r := l - len(s)
if r < 0 {
r = 0
}
return s + strings.Repeat(" ", r)
} | go | func StrPadRight(s string, l int) string {
r := l - len(s)
if r < 0 {
r = 0
}
return s + strings.Repeat(" ", r)
} | [
"func",
"StrPadRight",
"(",
"s",
"string",
",",
"l",
"int",
")",
"string",
"{",
"r",
":=",
"l",
"-",
"len",
"(",
"s",
")",
"\n",
"if",
"r",
"<",
"0",
"{",
"r",
"=",
"0",
"\n",
"}",
"\n",
"return",
"s",
"+",
"strings",
".",
"Repeat",
"(",
"\... | // StrPadRight adds spaces to the right of a string until it reaches l length.
// If the input string is already that long, do nothing. | [
"StrPadRight",
"adds",
"spaces",
"to",
"the",
"right",
"of",
"a",
"string",
"until",
"it",
"reaches",
"l",
"length",
".",
"If",
"the",
"input",
"string",
"is",
"already",
"that",
"long",
"do",
"nothing",
"."
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L84-L90 |
20,197 | cbednarski/hostess | commands.go | Has | func Has(c *cli.Context) {
if len(c.Args()) != 1 {
MaybeError(c, "expected <hostname>")
}
domain := c.Args()[0]
hostsfile := MaybeLoadHostFile(c)
found := hostsfile.Hosts.ContainsDomain(domain)
if found {
MaybePrintln(c, fmt.Sprintf("Found %s in %s", domain, GetHostsPath()))
} else {
MaybeError(c, fmt.Spr... | go | func Has(c *cli.Context) {
if len(c.Args()) != 1 {
MaybeError(c, "expected <hostname>")
}
domain := c.Args()[0]
hostsfile := MaybeLoadHostFile(c)
found := hostsfile.Hosts.ContainsDomain(domain)
if found {
MaybePrintln(c, fmt.Sprintf("Found %s in %s", domain, GetHostsPath()))
} else {
MaybeError(c, fmt.Spr... | [
"func",
"Has",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"!=",
"1",
"{",
"MaybeError",
"(",
"c",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"domain",
":=",
"c",
".",
"Args",
"(",
")",
"... | // Has command indicates whether a hostname is present in the hosts file | [
"Has",
"command",
"indicates",
"whether",
"a",
"hostname",
"is",
"present",
"in",
"the",
"hosts",
"file"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L158-L172 |
20,198 | cbednarski/hostess | commands.go | Ls | func Ls(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
maxdomain := 0
maxip := 0
for _, hostname := range hostsfile.Hosts {
dlen := len(hostname.Domain)
if dlen > maxdomain {
maxdomain = dlen
}
ilen := len(hostname.IP)
if ilen > maxip {
maxip = ilen
}
}
for _, hostname := range hostsfile.... | go | func Ls(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
maxdomain := 0
maxip := 0
for _, hostname := range hostsfile.Hosts {
dlen := len(hostname.Domain)
if dlen > maxdomain {
maxdomain = dlen
}
ilen := len(hostname.IP)
if ilen > maxip {
maxip = ilen
}
}
for _, hostname := range hostsfile.... | [
"func",
"Ls",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"hostsfile",
":=",
"AlwaysLoadHostFile",
"(",
"c",
")",
"\n",
"maxdomain",
":=",
"0",
"\n",
"maxip",
":=",
"0",
"\n",
"for",
"_",
",",
"hostname",
":=",
"range",
"hostsfile",
".",
"Hosts",... | // Ls command shows a list of hostnames in the hosts file | [
"Ls",
"command",
"shows",
"a",
"list",
"of",
"hostnames",
"in",
"the",
"hosts",
"file"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L204-L225 |
20,199 | cbednarski/hostess | commands.go | Fix | func Fix(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
if bytes.Equal(hostsfile.GetData(), hostsfile.Format()) {
MaybePrintln(c, fmt.Sprintf("%s is already formatted and contains no dupes or conflicts; nothing to do", GetHostsPath()))
os.Exit(0)
}
MaybeSaveHostFile(c, hostsfile)
} | go | func Fix(c *cli.Context) {
hostsfile := AlwaysLoadHostFile(c)
if bytes.Equal(hostsfile.GetData(), hostsfile.Format()) {
MaybePrintln(c, fmt.Sprintf("%s is already formatted and contains no dupes or conflicts; nothing to do", GetHostsPath()))
os.Exit(0)
}
MaybeSaveHostFile(c, hostsfile)
} | [
"func",
"Fix",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"hostsfile",
":=",
"AlwaysLoadHostFile",
"(",
"c",
")",
"\n",
"if",
"bytes",
".",
"Equal",
"(",
"hostsfile",
".",
"GetData",
"(",
")",
",",
"hostsfile",
".",
"Format",
"(",
")",
")",
"{... | // Fix command removes duplicates and conflicts from the hosts file | [
"Fix",
"command",
"removes",
"duplicates",
"and",
"conflicts",
"from",
"the",
"hosts",
"file"
] | 4c91c5787547219e13bce8e17bd1d0049e3918e6 | https://github.com/cbednarski/hostess/blob/4c91c5787547219e13bce8e17bd1d0049e3918e6/commands.go#L238-L245 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.