id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,400 | kata-containers/agent | protocols/client/client.go | heartBeat | func heartBeat(session *yamux.Session) {
if session == nil {
return
}
for {
if session.IsClosed() {
break
}
session.Ping()
// 1 Hz heartbeat
time.Sleep(time.Second)
}
} | go | func heartBeat(session *yamux.Session) {
if session == nil {
return
}
for {
if session.IsClosed() {
break
}
session.Ping()
// 1 Hz heartbeat
time.Sleep(time.Second)
}
} | [
"func",
"heartBeat",
"(",
"session",
"*",
"yamux",
".",
"Session",
")",
"{",
"if",
"session",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"{",
"if",
"session",
".",
"IsClosed",
"(",
")",
"{",
"break",
"\n",
"}",
"\n\n",
"session",
".",
"P... | // This function is meant to run in a go routine since it will send ping
// commands every second. It behaves as a heartbeat to maintain a proper
// communication state with the Yamux server in the agent. | [
"This",
"function",
"is",
"meant",
"to",
"run",
"in",
"a",
"go",
"routine",
"since",
"it",
"will",
"send",
"ping",
"commands",
"every",
"second",
".",
"It",
"behaves",
"as",
"a",
"heartbeat",
"to",
"maintain",
"a",
"proper",
"communication",
"state",
"with... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/client/client.go#L171-L186 |
28,401 | kata-containers/agent | mount.go | ensureDestinationExists | func ensureDestinationExists(source, destination string, fsType string) error {
fileInfo, err := os.Stat(source)
if err != nil {
return grpcStatus.Errorf(codes.Internal, "could not stat source location: %v",
source)
}
if err := createDestinationDir(destination); err != nil {
return grpcStatus.Errorf(codes.I... | go | func ensureDestinationExists(source, destination string, fsType string) error {
fileInfo, err := os.Stat(source)
if err != nil {
return grpcStatus.Errorf(codes.Internal, "could not stat source location: %v",
source)
}
if err := createDestinationDir(destination); err != nil {
return grpcStatus.Errorf(codes.I... | [
"func",
"ensureDestinationExists",
"(",
"source",
",",
"destination",
"string",
",",
"fsType",
"string",
")",
"error",
"{",
"fileInfo",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"source",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcStatus",
... | // ensureDestinationExists will recursively create a given mountpoint. If directories
// are created, their permissions are initialized to mountPerm | [
"ensureDestinationExists",
"will",
"recursively",
"create",
"a",
"given",
"mountpoint",
".",
"If",
"directories",
"are",
"created",
"their",
"permissions",
"are",
"initialized",
"to",
"mountPerm"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L134-L159 |
28,402 | kata-containers/agent | mount.go | virtio9pStorageHandler | func virtio9pStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
return commonStorageHandler(storage)
} | go | func virtio9pStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
return commonStorageHandler(storage)
} | [
"func",
"virtio9pStorageHandler",
"(",
"storage",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"commonStorageHandler",
"(",
"storage",
")",
"\n",
"}"
] | // virtio9pStorageHandler handles the storage for 9p driver. | [
"virtio9pStorageHandler",
"handles",
"the",
"storage",
"for",
"9p",
"driver",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L257-L259 |
28,403 | kata-containers/agent | mount.go | virtioBlkStorageHandler | func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Get the device node path based on the PCI address provided
// in Storage Source
devPath, err := getPCIDeviceName(s, storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | go | func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Get the device node path based on the PCI address provided
// in Storage Source
devPath, err := getPCIDeviceName(s, storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | [
"func",
"virtioBlkStorageHandler",
"(",
"storage",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Get the device node path based on the PCI address provided",
"// in Storage Source",
"devPath",
",",
"err",
":=",
"getPCI... | // virtioBlkStorageHandler handles the storage for blk driver. | [
"virtioBlkStorageHandler",
"handles",
"the",
"storage",
"for",
"blk",
"driver",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L273-L283 |
28,404 | kata-containers/agent | mount.go | virtioSCSIStorageHandler | func virtioSCSIStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Retrieve the device path from SCSI address.
devPath, err := getSCSIDevPath(storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | go | func virtioSCSIStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Retrieve the device path from SCSI address.
devPath, err := getSCSIDevPath(storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | [
"func",
"virtioSCSIStorageHandler",
"(",
"storage",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Retrieve the device path from SCSI address.",
"devPath",
",",
"err",
":=",
"getSCSIDevPath",
"(",
"storage",
".",
... | // virtioSCSIStorageHandler handles the storage for scsi driver. | [
"virtioSCSIStorageHandler",
"handles",
"the",
"storage",
"for",
"scsi",
"driver",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L286-L295 |
28,405 | kata-containers/agent | mount.go | mountStorage | func mountStorage(storage pb.Storage) error {
flags, options, err := parseMountFlagsAndOptions(storage.Options)
if err != nil {
return err
}
return mount(storage.Source, storage.MountPoint, storage.Fstype, flags, options)
} | go | func mountStorage(storage pb.Storage) error {
flags, options, err := parseMountFlagsAndOptions(storage.Options)
if err != nil {
return err
}
return mount(storage.Source, storage.MountPoint, storage.Fstype, flags, options)
} | [
"func",
"mountStorage",
"(",
"storage",
"pb",
".",
"Storage",
")",
"error",
"{",
"flags",
",",
"options",
",",
"err",
":=",
"parseMountFlagsAndOptions",
"(",
"storage",
".",
"Options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",... | // mountStorage performs the mount described by the storage structure. | [
"mountStorage",
"performs",
"the",
"mount",
"described",
"by",
"the",
"storage",
"structure",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L307-L314 |
28,406 | kata-containers/agent | mount.go | addStorages | func addStorages(ctx context.Context, storages []*pb.Storage, s *sandbox) ([]string, error) {
span, ctx := trace(ctx, "mount", "addStorages")
span.SetTag("sandbox", s.id)
defer span.Finish()
var mountList []string
for _, storage := range storages {
if storage == nil {
continue
}
devHandler, ok := stora... | go | func addStorages(ctx context.Context, storages []*pb.Storage, s *sandbox) ([]string, error) {
span, ctx := trace(ctx, "mount", "addStorages")
span.SetTag("sandbox", s.id)
defer span.Finish()
var mountList []string
for _, storage := range storages {
if storage == nil {
continue
}
devHandler, ok := stora... | [
"func",
"addStorages",
"(",
"ctx",
"context",
".",
"Context",
",",
"storages",
"[",
"]",
"*",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"span",
",",
"ctx",
":=",
"trace",
"(",
"ctx",
","... | // addStorages takes a list of storages passed by the caller, and perform the
// associated operations such as waiting for the device to show up, and mount
// it to a specific location, according to the type of handler chosen, and for
// each storage. | [
"addStorages",
"takes",
"a",
"list",
"of",
"storages",
"passed",
"by",
"the",
"caller",
"and",
"perform",
"the",
"associated",
"operations",
"such",
"as",
"waiting",
"for",
"the",
"device",
"to",
"show",
"up",
"and",
"mount",
"it",
"to",
"a",
"specific",
"... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L320-L356 |
28,407 | kata-containers/agent | config.go | getConfig | func (c *agentConfig) getConfig(cmdLineFile string) error {
if cmdLineFile == "" {
return grpcStatus.Error(codes.FailedPrecondition, "Kernel cmdline file cannot be empty")
}
kernelCmdline, err := ioutil.ReadFile(cmdLineFile)
if err != nil {
return err
}
words := strings.Fields(string(kernelCmdline))
for _,... | go | func (c *agentConfig) getConfig(cmdLineFile string) error {
if cmdLineFile == "" {
return grpcStatus.Error(codes.FailedPrecondition, "Kernel cmdline file cannot be empty")
}
kernelCmdline, err := ioutil.ReadFile(cmdLineFile)
if err != nil {
return err
}
words := strings.Fields(string(kernelCmdline))
for _,... | [
"func",
"(",
"c",
"*",
"agentConfig",
")",
"getConfig",
"(",
"cmdLineFile",
"string",
")",
"error",
"{",
"if",
"cmdLineFile",
"==",
"\"",
"\"",
"{",
"return",
"grpcStatus",
".",
"Error",
"(",
"codes",
".",
"FailedPrecondition",
",",
"\"",
"\"",
")",
"\n"... | //Get the agent configuration from kernel cmdline | [
"Get",
"the",
"agent",
"configuration",
"from",
"kernel",
"cmdline"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/config.go#L44-L65 |
28,408 | kata-containers/agent | config.go | parseCmdlineOption | func (c *agentConfig) parseCmdlineOption(option string) error {
const (
optionPosition = iota
valuePosition
optionSeparator = "="
)
if option == devModeFlag {
crashOnError = true
debug = true
return nil
}
if option == traceModeFlag {
enableTracing(traceModeStatic, defaultTraceType)
return nil
}... | go | func (c *agentConfig) parseCmdlineOption(option string) error {
const (
optionPosition = iota
valuePosition
optionSeparator = "="
)
if option == devModeFlag {
crashOnError = true
debug = true
return nil
}
if option == traceModeFlag {
enableTracing(traceModeStatic, defaultTraceType)
return nil
}... | [
"func",
"(",
"c",
"*",
"agentConfig",
")",
"parseCmdlineOption",
"(",
"option",
"string",
")",
"error",
"{",
"const",
"(",
"optionPosition",
"=",
"iota",
"\n",
"valuePosition",
"\n",
"optionSeparator",
"=",
"\"",
"\"",
"\n",
")",
"\n\n",
"if",
"option",
"=... | //Parse a string that represents a kernel cmdline option | [
"Parse",
"a",
"string",
"that",
"represents",
"a",
"kernel",
"cmdline",
"option"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/config.go#L68-L130 |
28,409 | kata-containers/agent | pkg/uevent/uevent.go | NewReaderCloser | func NewReaderCloser() (io.ReadCloser, error) {
nl := unix.SockaddrNetlink{
Family: unix.AF_NETLINK,
// Passing Pid as 0 here allows the kernel to take care of assigning
// it. This allows multiple netlink sockets to be used.
Pid: uint32(0),
Groups: 1,
}
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOC... | go | func NewReaderCloser() (io.ReadCloser, error) {
nl := unix.SockaddrNetlink{
Family: unix.AF_NETLINK,
// Passing Pid as 0 here allows the kernel to take care of assigning
// it. This allows multiple netlink sockets to be used.
Pid: uint32(0),
Groups: 1,
}
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOC... | [
"func",
"NewReaderCloser",
"(",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"nl",
":=",
"unix",
".",
"SockaddrNetlink",
"{",
"Family",
":",
"unix",
".",
"AF_NETLINK",
",",
"// Passing Pid as 0 here allows the kernel to take care of assigning",
"// it.... | // NewReaderCloser returns an io.ReadCloser handle for uevent. | [
"NewReaderCloser",
"returns",
"an",
"io",
".",
"ReadCloser",
"handle",
"for",
"uevent",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L36-L55 |
28,410 | kata-containers/agent | pkg/uevent/uevent.go | Read | func (r *ReaderCloser) Read(p []byte) (int, error) {
count, err := unix.Read(r.fd, p)
if count < 0 && err != nil {
count = 0
}
return count, err
} | go | func (r *ReaderCloser) Read(p []byte) (int, error) {
count, err := unix.Read(r.fd, p)
if count < 0 && err != nil {
count = 0
}
return count, err
} | [
"func",
"(",
"r",
"*",
"ReaderCloser",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"unix",
".",
"Read",
"(",
"r",
".",
"fd",
",",
"p",
")",
"\n",
"if",
"count",
"<",
"0",
"&&"... | // Read implements reading function for uevent. | [
"Read",
"implements",
"reading",
"function",
"for",
"uevent",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L58-L64 |
28,411 | kata-containers/agent | pkg/uevent/uevent.go | NewHandler | func NewHandler() (*Handler, error) {
rdCloser, err := NewReaderCloser()
if err != nil {
return nil, err
}
return &Handler{
readerCloser: rdCloser,
bufioReader: bufio.NewReader(rdCloser),
}, nil
} | go | func NewHandler() (*Handler, error) {
rdCloser, err := NewReaderCloser()
if err != nil {
return nil, err
}
return &Handler{
readerCloser: rdCloser,
bufioReader: bufio.NewReader(rdCloser),
}, nil
} | [
"func",
"NewHandler",
"(",
")",
"(",
"*",
"Handler",
",",
"error",
")",
"{",
"rdCloser",
",",
"err",
":=",
"NewReaderCloser",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"Handler",
"... | // NewHandler returns a uevent handler. | [
"NewHandler",
"returns",
"a",
"uevent",
"handler",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L88-L98 |
28,412 | kata-containers/agent | pkg/uevent/uevent.go | Read | func (h *Handler) Read() (*Uevent, error) {
uEv := &Uevent{}
// Read header first.
header, err := h.bufioReader.ReadString(paramDelim)
if err != nil {
return nil, err
}
// Fill uevent header.
uEv.Header = header
exitLoop := false
// Read every parameter as "key=value".
for !exitLoop {
keyValue, err :=... | go | func (h *Handler) Read() (*Uevent, error) {
uEv := &Uevent{}
// Read header first.
header, err := h.bufioReader.ReadString(paramDelim)
if err != nil {
return nil, err
}
// Fill uevent header.
uEv.Header = header
exitLoop := false
// Read every parameter as "key=value".
for !exitLoop {
keyValue, err :=... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"Read",
"(",
")",
"(",
"*",
"Uevent",
",",
"error",
")",
"{",
"uEv",
":=",
"&",
"Uevent",
"{",
"}",
"\n\n",
"// Read header first.",
"header",
",",
"err",
":=",
"h",
".",
"bufioReader",
".",
"ReadString",
"(",
... | // Read blocks and returns the next uevent when available. | [
"Read",
"blocks",
"and",
"returns",
"the",
"next",
"uevent",
"when",
"available",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L101-L154 |
28,413 | kata-containers/agent | channel.go | Write | func (yw yamuxWriter) Write(bytes []byte) (int, error) {
message := string(bytes)
l := len(message)
// yamux messages are all warnings and errors
agentLog.WithField("component", "yamux").Warn(message)
return l, nil
} | go | func (yw yamuxWriter) Write(bytes []byte) (int, error) {
message := string(bytes)
l := len(message)
// yamux messages are all warnings and errors
agentLog.WithField("component", "yamux").Warn(message)
return l, nil
} | [
"func",
"(",
"yw",
"yamuxWriter",
")",
"Write",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"message",
":=",
"string",
"(",
"bytes",
")",
"\n\n",
"l",
":=",
"len",
"(",
"message",
")",
"\n\n",
"// yamux messages are all war... | // Write implements the Writer interface for the yamuxWriter. | [
"Write",
"implements",
"the",
"Writer",
"interface",
"for",
"the",
"yamuxWriter",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/channel.go#L226-L235 |
28,414 | kata-containers/agent | channel.go | isAFVSockSupported | func isAFVSockSupported() (bool, error) {
// Driver path for virtio-vsock
sysVsockPath := "/sys/bus/virtio/drivers/vmw_vsock_virtio_transport/"
files, err := ioutil.ReadDir(sysVsockPath)
// This should not happen for a hypervisor with vsock driver
if err != nil {
return false, err
}
// standard driver files... | go | func isAFVSockSupported() (bool, error) {
// Driver path for virtio-vsock
sysVsockPath := "/sys/bus/virtio/drivers/vmw_vsock_virtio_transport/"
files, err := ioutil.ReadDir(sysVsockPath)
// This should not happen for a hypervisor with vsock driver
if err != nil {
return false, err
}
// standard driver files... | [
"func",
"isAFVSockSupported",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// Driver path for virtio-vsock",
"sysVsockPath",
":=",
"\"",
"\"",
"\n\n",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"sysVsockPath",
")",
"\n\n",
"// This should not h... | // isAFVSockSupported checks if vsock channel is used by the runtime
// by checking for devices under the vhost-vsock driver path.
// It returns true if a device is found for the vhost-vsock driver. | [
"isAFVSockSupported",
"checks",
"if",
"vsock",
"channel",
"is",
"used",
"by",
"the",
"runtime",
"by",
"checking",
"for",
"devices",
"under",
"the",
"vhost",
"-",
"vsock",
"driver",
"path",
".",
"It",
"returns",
"true",
"if",
"a",
"device",
"is",
"found",
"... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/channel.go#L274-L316 |
28,415 | kata-containers/agent | agent.go | closePostExitFDs | func (p *process) closePostExitFDs() {
if p.termMaster != nil {
p.termMaster.Close()
}
if p.stdin != nil {
p.stdin.Close()
}
if p.stdout != nil {
p.stdout.Close()
}
if p.stderr != nil {
p.stderr.Close()
}
if p.epoller != nil {
p.epoller.sockR.Close()
}
} | go | func (p *process) closePostExitFDs() {
if p.termMaster != nil {
p.termMaster.Close()
}
if p.stdin != nil {
p.stdin.Close()
}
if p.stdout != nil {
p.stdout.Close()
}
if p.stderr != nil {
p.stderr.Close()
}
if p.epoller != nil {
p.epoller.sockR.Close()
}
} | [
"func",
"(",
"p",
"*",
"process",
")",
"closePostExitFDs",
"(",
")",
"{",
"if",
"p",
".",
"termMaster",
"!=",
"nil",
"{",
"p",
".",
"termMaster",
".",
"Close",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"p",
".",
"stdin",
"!=",
"nil",
"{",
"p",
".",
"s... | // This is the list of file descriptors we can properly close after the process
// has exited. These are the remaining file descriptors that we have opened and
// are no longer needed. | [
"This",
"is",
"the",
"list",
"of",
"file",
"descriptors",
"we",
"can",
"properly",
"close",
"after",
"the",
"process",
"has",
"exited",
".",
"These",
"are",
"the",
"remaining",
"file",
"descriptors",
"that",
"we",
"have",
"opened",
"and",
"are",
"no",
"lon... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L204-L224 |
28,416 | kata-containers/agent | agent.go | setSandboxStorage | func (s *sandbox) setSandboxStorage(path string) bool {
if _, ok := s.storages[path]; !ok {
sbs := &sandboxStorage{refCount: 1}
s.storages[path] = sbs
return true
}
sbs := s.storages[path]
sbs.refCount++
return false
} | go | func (s *sandbox) setSandboxStorage(path string) bool {
if _, ok := s.storages[path]; !ok {
sbs := &sandboxStorage{refCount: 1}
s.storages[path] = sbs
return true
}
sbs := s.storages[path]
sbs.refCount++
return false
} | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"setSandboxStorage",
"(",
"path",
"string",
")",
"bool",
"{",
"if",
"_",
",",
"ok",
":=",
"s",
".",
"storages",
"[",
"path",
"]",
";",
"!",
"ok",
"{",
"sbs",
":=",
"&",
"sandboxStorage",
"{",
"refCount",
":",
... | // setSandboxStorage sets the sandbox level reference
// counter for the sandbox storage.
// This method also returns a boolean to let
// callers know if the storage already existed or not.
// It will return true if storage is new.
//
// It's assumed that caller is calling this method after
// acquiring a lock on sandb... | [
"setSandboxStorage",
"sets",
"the",
"sandbox",
"level",
"reference",
"counter",
"for",
"the",
"sandbox",
"storage",
".",
"This",
"method",
"also",
"returns",
"a",
"boolean",
"to",
"let",
"callers",
"know",
"if",
"the",
"storage",
"already",
"existed",
"or",
"n... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L296-L305 |
28,417 | kata-containers/agent | agent.go | scanGuestHooks | func (s *sandbox) scanGuestHooks(guestHookPath string) {
span, _ := s.trace("scanGuestHooks")
span.SetTag("guest-hook-path", guestHookPath)
defer span.Finish()
fieldLogger := agentLog.WithField("oci-hook-path", guestHookPath)
fieldLogger.Info("Scanning guest filesystem for OCI hooks")
s.guestHooks.Prestart = fi... | go | func (s *sandbox) scanGuestHooks(guestHookPath string) {
span, _ := s.trace("scanGuestHooks")
span.SetTag("guest-hook-path", guestHookPath)
defer span.Finish()
fieldLogger := agentLog.WithField("oci-hook-path", guestHookPath)
fieldLogger.Info("Scanning guest filesystem for OCI hooks")
s.guestHooks.Prestart = fi... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"scanGuestHooks",
"(",
"guestHookPath",
"string",
")",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"guestHookPath",
")",
"\n",
"defe... | // scanGuestHooks will search the given guestHookPath
// for any OCI hooks | [
"scanGuestHooks",
"will",
"search",
"the",
"given",
"guestHookPath",
"for",
"any",
"OCI",
"hooks"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L309-L326 |
28,418 | kata-containers/agent | agent.go | addGuestHooks | func (s *sandbox) addGuestHooks(spec *specs.Spec) {
span, _ := s.trace("addGuestHooks")
defer span.Finish()
if spec == nil {
return
}
if spec.Hooks == nil {
spec.Hooks = &specs.Hooks{}
}
spec.Hooks.Prestart = append(spec.Hooks.Prestart, s.guestHooks.Prestart...)
spec.Hooks.Poststart = append(spec.Hooks.P... | go | func (s *sandbox) addGuestHooks(spec *specs.Spec) {
span, _ := s.trace("addGuestHooks")
defer span.Finish()
if spec == nil {
return
}
if spec.Hooks == nil {
spec.Hooks = &specs.Hooks{}
}
spec.Hooks.Prestart = append(spec.Hooks.Prestart, s.guestHooks.Prestart...)
spec.Hooks.Poststart = append(spec.Hooks.P... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"addGuestHooks",
"(",
"spec",
"*",
"specs",
".",
"Spec",
")",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"if",
"spec",
"==... | // addGuestHooks will add any guest OCI hooks that were
// found to the OCI spec | [
"addGuestHooks",
"will",
"add",
"any",
"guest",
"OCI",
"hooks",
"that",
"were",
"found",
"to",
"the",
"OCI",
"spec"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L330-L345 |
28,419 | kata-containers/agent | agent.go | unSetSandboxStorage | func (s *sandbox) unSetSandboxStorage(path string) (bool, error) {
span, _ := s.trace("unSetSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if sbs, ok := s.storages[path]; ok {
sbs.refCount--
// If this sandbox storage is not used by any container
// then remove it's reference
if sbs.refCoun... | go | func (s *sandbox) unSetSandboxStorage(path string) (bool, error) {
span, _ := s.trace("unSetSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if sbs, ok := s.storages[path]; ok {
sbs.refCount--
// If this sandbox storage is not used by any container
// then remove it's reference
if sbs.refCoun... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"unSetSandboxStorage",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"... | // unSetSandboxStorage will decrement the sandbox storage
// reference counter. If there aren't any containers using
// that sandbox storage, this method will remove the
// storage reference from the sandbox and return 'true, nil' to
// let the caller know that they can clean up the storage
// related directories by ca... | [
"unSetSandboxStorage",
"will",
"decrement",
"the",
"sandbox",
"storage",
"reference",
"counter",
".",
"If",
"there",
"aren",
"t",
"any",
"containers",
"using",
"that",
"sandbox",
"storage",
"this",
"method",
"will",
"remove",
"the",
"storage",
"reference",
"from",... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L356-L372 |
28,420 | kata-containers/agent | agent.go | removeSandboxStorage | func (s *sandbox) removeSandboxStorage(path string) error {
span, _ := s.trace("removeSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
err := removeMounts([]string{path})
if err != nil {
return grpcStatus.Errorf(codes.Unknown, "Unable to unmount sandbox storage path %s", path)
}
err = os.RemoveA... | go | func (s *sandbox) removeSandboxStorage(path string) error {
span, _ := s.trace("removeSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
err := removeMounts([]string{path})
if err != nil {
return grpcStatus.Errorf(codes.Unknown, "Unable to unmount sandbox storage path %s", path)
}
err = os.RemoveA... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"removeSandboxStorage",
"(",
"path",
"string",
")",
"error",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"defer... | // removeSandboxStorage removes the sandbox storage if no
// containers are using that storage.
//
// It's assumed that caller is calling this method after
// acquiring a lock on sandbox. | [
"removeSandboxStorage",
"removes",
"the",
"sandbox",
"storage",
"if",
"no",
"containers",
"are",
"using",
"that",
"storage",
".",
"It",
"s",
"assumed",
"that",
"caller",
"is",
"calling",
"this",
"method",
"after",
"acquiring",
"a",
"lock",
"on",
"sandbox",
"."... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L379-L393 |
28,421 | kata-containers/agent | agent.go | unsetAndRemoveSandboxStorage | func (s *sandbox) unsetAndRemoveSandboxStorage(path string) error {
span, _ := s.trace("unsetAndRemoveSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if _, ok := s.storages[path]; ok {
removeSbs, err := s.unSetSandboxStorage(path)
if err != nil {
return err
}
if removeSbs {
if err := ... | go | func (s *sandbox) unsetAndRemoveSandboxStorage(path string) error {
span, _ := s.trace("unsetAndRemoveSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if _, ok := s.storages[path]; ok {
removeSbs, err := s.unSetSandboxStorage(path)
if err != nil {
return err
}
if removeSbs {
if err := ... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"unsetAndRemoveSandboxStorage",
"(",
"path",
"string",
")",
"error",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
... | // unsetAndRemoveSandboxStorage unsets the storage from sandbox
// and if there are no containers using this storage it will
// remove it from the sandbox.
//
// It's assumed that caller is calling this method after
// acquiring a lock on sandbox. | [
"unsetAndRemoveSandboxStorage",
"unsets",
"the",
"storage",
"from",
"sandbox",
"and",
"if",
"there",
"are",
"no",
"containers",
"using",
"this",
"storage",
"it",
"will",
"remove",
"it",
"from",
"the",
"sandbox",
".",
"It",
"s",
"assumed",
"that",
"caller",
"is... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L401-L421 |
28,422 | kata-containers/agent | agent.go | signalHandlerLoop | func (s *sandbox) signalHandlerLoop(sigCh chan os.Signal) {
for sig := range sigCh {
logger := agentLog.WithField("signal", sig)
if sig == unix.SIGCHLD {
if err := s.subreaper.reap(); err != nil {
logger.WithError(err).Error("failed to reap")
continue
}
}
nativeSignal, ok := sig.(syscall.Signal... | go | func (s *sandbox) signalHandlerLoop(sigCh chan os.Signal) {
for sig := range sigCh {
logger := agentLog.WithField("signal", sig)
if sig == unix.SIGCHLD {
if err := s.subreaper.reap(); err != nil {
logger.WithError(err).Error("failed to reap")
continue
}
}
nativeSignal, ok := sig.(syscall.Signal... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"signalHandlerLoop",
"(",
"sigCh",
"chan",
"os",
".",
"Signal",
")",
"{",
"for",
"sig",
":=",
"range",
"sigCh",
"{",
"logger",
":=",
"agentLog",
".",
"WithField",
"(",
"\"",
"\"",
",",
"sig",
")",
"\n\n",
"if",
... | // This loop is meant to be run inside a separate Go routine. | [
"This",
"loop",
"is",
"meant",
"to",
"be",
"run",
"inside",
"a",
"separate",
"Go",
"routine",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L749-L780 |
28,423 | kata-containers/agent | agent.go | getMemory | func getMemory() (string, error) {
bytes, err := ioutil.ReadFile(meminfo)
if err != nil {
return "", err
}
lines := string(bytes)
for _, line := range strings.Split(lines, "\n") {
if !strings.HasPrefix(line, "MemTotal") {
continue
}
expectedFields := 2
fields := strings.Split(line, ":")
count :=... | go | func getMemory() (string, error) {
bytes, err := ioutil.ReadFile(meminfo)
if err != nil {
return "", err
}
lines := string(bytes)
for _, line := range strings.Split(lines, "\n") {
if !strings.HasPrefix(line, "MemTotal") {
continue
}
expectedFields := 2
fields := strings.Split(line, ":")
count :=... | [
"func",
"getMemory",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"meminfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"lines",
":... | // getMemory returns a string containing the total amount of memory reported
// by the kernel. The string includes a suffix denoting the units the memory
// is measured in. | [
"getMemory",
"returns",
"a",
"string",
"containing",
"the",
"total",
"amount",
"of",
"memory",
"reported",
"by",
"the",
"kernel",
".",
"The",
"string",
"includes",
"a",
"suffix",
"denoting",
"the",
"units",
"the",
"memory",
"is",
"measured",
"in",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L807-L839 |
28,424 | kata-containers/agent | agent.go | announce | func announce() error {
announceFields, err := getAnnounceFields()
if err != nil {
return err
}
if os.Getpid() == 1 {
fields := formatFields(agentFields)
extraFields := formatFields(announceFields)
fields = append(fields, extraFields...)
fmt.Printf("announce: %s\n", strings.Join(fields, ","))
} else {... | go | func announce() error {
announceFields, err := getAnnounceFields()
if err != nil {
return err
}
if os.Getpid() == 1 {
fields := formatFields(agentFields)
extraFields := formatFields(announceFields)
fields = append(fields, extraFields...)
fmt.Printf("announce: %s\n", strings.Join(fields, ","))
} else {... | [
"func",
"announce",
"(",
")",
"error",
"{",
"announceFields",
",",
"err",
":=",
"getAnnounceFields",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"os",
".",
"Getpid",
"(",
")",
"==",
"1",
"{",
"fields",
"... | // announce logs details of the agents version and capabilities. | [
"announce",
"logs",
"details",
"of",
"the",
"agents",
"version",
"and",
"capabilities",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L884-L902 |
28,425 | kata-containers/agent | agent.go | initAgentAsInit | func initAgentAsInit() error {
if err := generalMount(); err != nil {
return err
}
if err := cgroupsMount(); err != nil {
return err
}
if err := syscall.Unlink("/dev/ptmx"); err != nil {
return err
}
if err := syscall.Symlink("/dev/pts/ptmx", "/dev/ptmx"); err != nil {
return err
}
syscall.Setsid()
sy... | go | func initAgentAsInit() error {
if err := generalMount(); err != nil {
return err
}
if err := cgroupsMount(); err != nil {
return err
}
if err := syscall.Unlink("/dev/ptmx"); err != nil {
return err
}
if err := syscall.Symlink("/dev/pts/ptmx", "/dev/ptmx"); err != nil {
return err
}
syscall.Setsid()
sy... | [
"func",
"initAgentAsInit",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"generalMount",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cgroupsMount",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"er... | // initAgentAsInit will do the initializations such as setting up the rootfs
// when this agent has been run as the init process. | [
"initAgentAsInit",
"will",
"do",
"the",
"initializations",
"such",
"as",
"setting",
"up",
"the",
"rootfs",
"when",
"this",
"agent",
"has",
"been",
"run",
"as",
"the",
"init",
"process",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L1201-L1219 |
28,426 | kata-containers/agent | oci.go | findHooks | func findHooks(guestHookPath, hookType string) (hooksFound []specs.Hook) {
hooksPath := path.Join(guestHookPath, hookType)
files, err := ioutil.ReadDir(hooksPath)
if err != nil {
agentLog.WithError(err).WithField("oci-hook-type", hookType).Info("Skipping hook type")
return
}
for _, file := range files {
na... | go | func findHooks(guestHookPath, hookType string) (hooksFound []specs.Hook) {
hooksPath := path.Join(guestHookPath, hookType)
files, err := ioutil.ReadDir(hooksPath)
if err != nil {
agentLog.WithError(err).WithField("oci-hook-type", hookType).Info("Skipping hook type")
return
}
for _, file := range files {
na... | [
"func",
"findHooks",
"(",
"guestHookPath",
",",
"hookType",
"string",
")",
"(",
"hooksFound",
"[",
"]",
"specs",
".",
"Hook",
")",
"{",
"hooksPath",
":=",
"path",
".",
"Join",
"(",
"guestHookPath",
",",
"hookType",
")",
"\n\n",
"files",
",",
"err",
":=",... | // findHooks searches guestHookPath for any OCI hooks for a given hookType | [
"findHooks",
"searches",
"guestHookPath",
"for",
"any",
"OCI",
"hooks",
"for",
"a",
"given",
"hookType"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/oci.go#L83-L112 |
28,427 | kata-containers/agent | tracing.go | trace | func trace(ctx context.Context, subsystem, name string) (opentracing.Span, context.Context) {
span, ctx := opentracing.StartSpanFromContext(ctx, name)
span.SetTag("subsystem", subsystem)
// This is slightly confusing: when tracing is disabled, trace spans
// are still created - but the tracer used is a NOP. There... | go | func trace(ctx context.Context, subsystem, name string) (opentracing.Span, context.Context) {
span, ctx := opentracing.StartSpanFromContext(ctx, name)
span.SetTag("subsystem", subsystem)
// This is slightly confusing: when tracing is disabled, trace spans
// are still created - but the tracer used is a NOP. There... | [
"func",
"trace",
"(",
"ctx",
"context",
".",
"Context",
",",
"subsystem",
",",
"name",
"string",
")",
"(",
"opentracing",
".",
"Span",
",",
"context",
".",
"Context",
")",
"{",
"span",
",",
"ctx",
":=",
"opentracing",
".",
"StartSpanFromContext",
"(",
"c... | // trace creates a new tracing span based on the specified contex, subsystem
// and name. | [
"trace",
"creates",
"a",
"new",
"tracing",
"span",
"based",
"on",
"the",
"specified",
"contex",
"subsystem",
"and",
"name",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/tracing.go#L135-L148 |
28,428 | kata-containers/agent | grpc.go | handleError | func handleError(wait bool, err error) error {
if !wait {
agentLog.WithError(err).Error()
}
return err
} | go | func handleError(wait bool, err error) error {
if !wait {
agentLog.WithError(err).Error()
}
return err
} | [
"func",
"handleError",
"(",
"wait",
"bool",
",",
"err",
"error",
")",
"error",
"{",
"if",
"!",
"wait",
"{",
"agentLog",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // handleError will log the specified error if wait is false | [
"handleError",
"will",
"log",
"the",
"specified",
"error",
"if",
"wait",
"is",
"false"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L83-L89 |
28,429 | kata-containers/agent | grpc.go | onlineResources | func onlineResources(resource onlineResource, nbResources int32) (uint32, error) {
files, err := ioutil.ReadDir(resource.sysfsOnlinePath)
if err != nil {
return 0, err
}
var count uint32
for _, file := range files {
matched, err := regexp.MatchString(resource.regexpPattern, file.Name())
if err != nil {
r... | go | func onlineResources(resource onlineResource, nbResources int32) (uint32, error) {
files, err := ioutil.ReadDir(resource.sysfsOnlinePath)
if err != nil {
return 0, err
}
var count uint32
for _, file := range files {
matched, err := regexp.MatchString(resource.regexpPattern, file.Name())
if err != nil {
r... | [
"func",
"onlineResources",
"(",
"resource",
"onlineResource",
",",
"nbResources",
"int32",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"resource",
".",
"sysfsOnlinePath",
")",
"\n",
"if",
"err",
"!=... | // Online resources, nbResources specifies the maximum number of resources to online.
// If nbResources is <= 0 then there is no limit and all resources are connected.
// Returns the number of resources connected. | [
"Online",
"resources",
"nbResources",
"specifies",
"the",
"maximum",
"number",
"of",
"resources",
"to",
"online",
".",
"If",
"nbResources",
"is",
"<",
"=",
"0",
"then",
"there",
"is",
"no",
"limit",
"and",
"all",
"resources",
"are",
"connected",
".",
"Return... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L94-L131 |
28,430 | kata-containers/agent | grpc.go | updateCpusetPath | func updateCpusetPath(cgroupPath string, newCpuset string, cookies cookie) error {
// Each cpuset cgroup parent MUST BE updated with the actual number of vCPUs.
//Start to update from cgroup system root.
cgroupParentPath := cgroupCpusetPath
cpusetGuest, err := getCpusetGuest()
if err != nil {
return err
}
//... | go | func updateCpusetPath(cgroupPath string, newCpuset string, cookies cookie) error {
// Each cpuset cgroup parent MUST BE updated with the actual number of vCPUs.
//Start to update from cgroup system root.
cgroupParentPath := cgroupCpusetPath
cpusetGuest, err := getCpusetGuest()
if err != nil {
return err
}
//... | [
"func",
"updateCpusetPath",
"(",
"cgroupPath",
"string",
",",
"newCpuset",
"string",
",",
"cookies",
"cookie",
")",
"error",
"{",
"// Each cpuset cgroup parent MUST BE updated with the actual number of vCPUs.",
"//Start to update from cgroup system root.",
"cgroupParentPath",
":=",... | // updates a cpuset cgroups path visiting each sub-directory in cgroupPath parent and writing
// the maximal set of cpus in cpuset.cpus file, finally the cgroupPath is updated with the requsted
//value.
// cookies are used for performance reasons in order to
// don't update a cgroup twice. | [
"updates",
"a",
"cpuset",
"cgroups",
"path",
"visiting",
"each",
"sub",
"-",
"directory",
"in",
"cgroupPath",
"parent",
"and",
"writing",
"the",
"maximal",
"set",
"of",
"cpus",
"in",
"cpuset",
".",
"cpus",
"file",
"finally",
"the",
"cgroupPath",
"is",
"updat... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L170-L221 |
28,431 | kata-containers/agent | grpc.go | execProcess | func (a *agentGRPC) execProcess(ctr *container, proc *process, createContainer bool) (err error) {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
// This lock is very import... | go | func (a *agentGRPC) execProcess(ctr *container, proc *process, createContainer bool) (err error) {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
// This lock is very import... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"execProcess",
"(",
"ctr",
"*",
"container",
",",
"proc",
"*",
"process",
",",
"createContainer",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"if",
"ctr",
"==",
"nil",
"{",
"return",
"grpcStatus",
".",
"Error",
... | // Shared function between CreateContainer and ExecProcess, because those expect
// a process to be run. | [
"Shared",
"function",
"between",
"CreateContainer",
"and",
"ExecProcess",
"because",
"those",
"expect",
"a",
"process",
"to",
"be",
"run",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L392-L433 |
28,432 | kata-containers/agent | grpc.go | postExecProcess | func (a *agentGRPC) postExecProcess(ctr *container, proc *process) error {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
defer proc.closePostStartFDs()
// Setup terminal ... | go | func (a *agentGRPC) postExecProcess(ctr *container, proc *process) error {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
defer proc.closePostStartFDs()
// Setup terminal ... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"postExecProcess",
"(",
"ctr",
"*",
"container",
",",
"proc",
"*",
"process",
")",
"error",
"{",
"if",
"ctr",
"==",
"nil",
"{",
"return",
"grpcStatus",
".",
"Error",
"(",
"codes",
".",
"InvalidArgument",
",",
"\... | // Shared function between CreateContainer and ExecProcess, because those expect
// the console to be properly setup after the process has been started. | [
"Shared",
"function",
"between",
"CreateContainer",
"and",
"ExecProcess",
"because",
"those",
"expect",
"the",
"console",
"to",
"be",
"properly",
"setup",
"after",
"the",
"process",
"has",
"been",
"started",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L437-L476 |
28,433 | kata-containers/agent | grpc.go | updateContainerConfigNamespaces | func (a *agentGRPC) updateContainerConfigNamespaces(config *configs.Config, ctr *container) {
var ipcNs, utsNs bool
for idx, ns := range config.Namespaces {
if ns.Type == configs.NEWIPC {
config.Namespaces[idx].Path = a.sandbox.sharedIPCNs.path
ipcNs = true
}
if ns.Type == configs.NEWUTS {
config.Nam... | go | func (a *agentGRPC) updateContainerConfigNamespaces(config *configs.Config, ctr *container) {
var ipcNs, utsNs bool
for idx, ns := range config.Namespaces {
if ns.Type == configs.NEWIPC {
config.Namespaces[idx].Path = a.sandbox.sharedIPCNs.path
ipcNs = true
}
if ns.Type == configs.NEWUTS {
config.Nam... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"updateContainerConfigNamespaces",
"(",
"config",
"*",
"configs",
".",
"Config",
",",
"ctr",
"*",
"container",
")",
"{",
"var",
"ipcNs",
",",
"utsNs",
"bool",
"\n\n",
"for",
"idx",
",",
"ns",
":=",
"range",
"confi... | // This function updates the container namespaces configuration based on the
// sandbox information. When the sandbox is created, it can be setup in a way
// that all containers will share some specific namespaces. This is the agent
// responsibility to create those namespaces so that they can be shared across
// sever... | [
"This",
"function",
"updates",
"the",
"container",
"namespaces",
"configuration",
"based",
"on",
"the",
"sandbox",
"information",
".",
"When",
"the",
"sandbox",
"is",
"created",
"it",
"can",
"be",
"setup",
"in",
"a",
"way",
"that",
"all",
"containers",
"will",... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L489-L538 |
28,434 | kata-containers/agent | grpc.go | rollbackFailingContainerCreation | func (a *agentGRPC) rollbackFailingContainerCreation(ctr *container) {
if ctr.container != nil {
ctr.container.Destroy()
}
a.sandbox.deleteContainer(ctr.id)
if err := removeMounts(ctr.mounts); err != nil {
agentLog.WithError(err).Error("rollback failed removeMounts()")
}
} | go | func (a *agentGRPC) rollbackFailingContainerCreation(ctr *container) {
if ctr.container != nil {
ctr.container.Destroy()
}
a.sandbox.deleteContainer(ctr.id)
if err := removeMounts(ctr.mounts); err != nil {
agentLog.WithError(err).Error("rollback failed removeMounts()")
}
} | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"rollbackFailingContainerCreation",
"(",
"ctr",
"*",
"container",
")",
"{",
"if",
"ctr",
".",
"container",
"!=",
"nil",
"{",
"ctr",
".",
"container",
".",
"Destroy",
"(",
")",
"\n",
"}",
"\n\n",
"a",
".",
"sandb... | // rollbackFailingContainerCreation rolls back important steps that might have
// been performed before the container creation failed.
// - Destroy the container created by libcontainer
// - Delete the container from the agent internal map
// - Unmount all mounts related to this container | [
"rollbackFailingContainerCreation",
"rolls",
"back",
"important",
"steps",
"that",
"might",
"have",
"been",
"performed",
"before",
"the",
"container",
"creation",
"failed",
".",
"-",
"Destroy",
"the",
"container",
"created",
"by",
"libcontainer",
"-",
"Delete",
"the... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L563-L573 |
28,435 | kata-containers/agent | grpc.go | applyNetworkSysctls | func (a *agentGRPC) applyNetworkSysctls(ociSpec *specs.Spec) error {
sysctls := ociSpec.Linux.Sysctl
for key, value := range sysctls {
if isNetworkSysctl(key) {
if err := writeSystemProperty(key, value); err != nil {
return err
}
delete(sysctls, key)
}
}
ociSpec.Linux.Sysctl = sysctls
return nil
... | go | func (a *agentGRPC) applyNetworkSysctls(ociSpec *specs.Spec) error {
sysctls := ociSpec.Linux.Sysctl
for key, value := range sysctls {
if isNetworkSysctl(key) {
if err := writeSystemProperty(key, value); err != nil {
return err
}
delete(sysctls, key)
}
}
ociSpec.Linux.Sysctl = sysctls
return nil
... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"applyNetworkSysctls",
"(",
"ociSpec",
"*",
"specs",
".",
"Spec",
")",
"error",
"{",
"sysctls",
":=",
"ociSpec",
".",
"Linux",
".",
"Sysctl",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"sysctls",
"{",
"if"... | // libcontainer checks if the container is running in a separate network namespace
// before applying the network related sysctls. If it sees that the network namespace of the container
// is the same as the "host", it errors out. Since we do no create a new net namespace inside the guest,
// libcontainer would error o... | [
"libcontainer",
"checks",
"if",
"the",
"container",
"is",
"running",
"in",
"a",
"separate",
"network",
"namespace",
"before",
"applying",
"the",
"network",
"related",
"sysctls",
".",
"If",
"it",
"sees",
"that",
"the",
"network",
"namespace",
"of",
"the",
"cont... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L730-L743 |
28,436 | kata-containers/agent | grpc.go | isSignalHandled | func isSignalHandled(pid int, signum syscall.Signal) bool {
var sigMask uint64 = 1 << (uint(signum) - 1)
procFile := fmt.Sprintf("/proc/%d/status", pid)
file, err := os.Open(procFile)
if err != nil {
agentLog.WithField("procFile", procFile).Warn("Open proc file failed")
return false
}
defer file.Close()
sca... | go | func isSignalHandled(pid int, signum syscall.Signal) bool {
var sigMask uint64 = 1 << (uint(signum) - 1)
procFile := fmt.Sprintf("/proc/%d/status", pid)
file, err := os.Open(procFile)
if err != nil {
agentLog.WithField("procFile", procFile).Warn("Open proc file failed")
return false
}
defer file.Close()
sca... | [
"func",
"isSignalHandled",
"(",
"pid",
"int",
",",
"signum",
"syscall",
".",
"Signal",
")",
"bool",
"{",
"var",
"sigMask",
"uint64",
"=",
"1",
"<<",
"(",
"uint",
"(",
"signum",
")",
"-",
"1",
")",
"\n",
"procFile",
":=",
"fmt",
".",
"Sprintf",
"(",
... | // Check is the container process installed the
// handler for specific signal. | [
"Check",
"is",
"the",
"container",
"process",
"installed",
"the",
"handler",
"for",
"specific",
"signal",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L951-L980 |
28,437 | kata-containers/agent | device.go | findSCSIDisk | func findSCSIDisk(scsiPath string) (string, error) {
files, err := ioutil.ReadDir(scsiPath)
if err != nil {
return "", err
}
if len(files) != 1 {
return "", grpcStatus.Errorf(codes.Internal,
"Expecting a single SCSI device, found %v",
files)
}
return files[0].Name(), nil
} | go | func findSCSIDisk(scsiPath string) (string, error) {
files, err := ioutil.ReadDir(scsiPath)
if err != nil {
return "", err
}
if len(files) != 1 {
return "", grpcStatus.Errorf(codes.Internal,
"Expecting a single SCSI device, found %v",
files)
}
return files[0].Name(), nil
} | [
"func",
"findSCSIDisk",
"(",
"scsiPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"scsiPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"... | // findSCSIDisk finds the SCSI disk name associated with the given SCSI path.
// This approach eliminates the need to predict the disk name on the host side,
// but we do need to rescan SCSI bus for this. | [
"findSCSIDisk",
"finds",
"the",
"SCSI",
"disk",
"name",
"associated",
"with",
"the",
"given",
"SCSI",
"path",
".",
"This",
"approach",
"eliminates",
"the",
"need",
"to",
"predict",
"the",
"disk",
"name",
"on",
"the",
"host",
"side",
"but",
"we",
"do",
"nee... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/device.go#L383-L396 |
28,438 | kata-containers/agent | device.go | getSCSIDevPath | func getSCSIDevPath(scsiAddr string) (string, error) {
if err := scanSCSIBus(scsiAddr); err != nil {
return "", err
}
devPath := filepath.Join(scsiDiskPrefix+scsiAddr, scsiDiskSuffix)
checkUevent := func(uEv *uevent.Uevent) bool {
devSubPath := filepath.Join(scsiHostChannel+scsiAddr, scsiBlockSuffix)
return... | go | func getSCSIDevPath(scsiAddr string) (string, error) {
if err := scanSCSIBus(scsiAddr); err != nil {
return "", err
}
devPath := filepath.Join(scsiDiskPrefix+scsiAddr, scsiDiskSuffix)
checkUevent := func(uEv *uevent.Uevent) bool {
devSubPath := filepath.Join(scsiHostChannel+scsiAddr, scsiBlockSuffix)
return... | [
"func",
"getSCSIDevPath",
"(",
"scsiAddr",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"scanSCSIBus",
"(",
"scsiAddr",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"devPath",
":=... | // getSCSIDevPath scans SCSI bus looking for the provided SCSI address, then
// it waits for the SCSI disk to become available and returns the device path
// associated with the disk. | [
"getSCSIDevPath",
"scans",
"SCSI",
"bus",
"looking",
"for",
"the",
"provided",
"SCSI",
"address",
"then",
"it",
"waits",
"for",
"the",
"SCSI",
"disk",
"to",
"become",
"available",
"and",
"returns",
"the",
"device",
"path",
"associated",
"with",
"the",
"disk",
... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/device.go#L401-L423 |
28,439 | kata-containers/agent | network.go | updateInterface | func (s *sandbox) updateInterface(netHandle *netlink.Handle, iface *types.Interface) (resultingIfc *types.Interface, err error) {
if iface == nil {
return nil, errNoIF
}
s.network.ifacesLock.Lock()
defer s.network.ifacesLock.Unlock()
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE... | go | func (s *sandbox) updateInterface(netHandle *netlink.Handle, iface *types.Interface) (resultingIfc *types.Interface, err error) {
if iface == nil {
return nil, errNoIF
}
s.network.ifacesLock.Lock()
defer s.network.ifacesLock.Unlock()
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"updateInterface",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
",",
"iface",
"*",
"types",
".",
"Interface",
")",
"(",
"resultingIfc",
"*",
"types",
".",
"Interface",
",",
"err",
"error",
")",
"{",
"if",
"ifa... | // updateInterface will update an existing interface with the values provided in the types.Interface. It will identify the
// existing interface via MAC address and will return the state of the interface once the function completes as well an any
// errors observed. | [
"updateInterface",
"will",
"update",
"an",
"existing",
"interface",
"with",
"the",
"values",
"provided",
"in",
"the",
"types",
".",
"Interface",
".",
"It",
"will",
"identify",
"the",
"existing",
"interface",
"via",
"MAC",
"address",
"and",
"will",
"return",
"t... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L199-L277 |
28,440 | kata-containers/agent | network.go | getInterface | func getInterface(netHandle *netlink.Handle, link netlink.Link) (*types.Interface, error) {
if netHandle == nil {
return nil, errNoHandle
}
if link == nil {
return nil, errNoLink
}
var ifc types.Interface
linkAttrs := link.Attrs()
ifc.Name = linkAttrs.Name
ifc.Mtu = uint64(linkAttrs.MTU)
ifc.HwAddr = lin... | go | func getInterface(netHandle *netlink.Handle, link netlink.Link) (*types.Interface, error) {
if netHandle == nil {
return nil, errNoHandle
}
if link == nil {
return nil, errNoLink
}
var ifc types.Interface
linkAttrs := link.Attrs()
ifc.Name = linkAttrs.Name
ifc.Mtu = uint64(linkAttrs.MTU)
ifc.HwAddr = lin... | [
"func",
"getInterface",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
",",
"link",
"netlink",
".",
"Link",
")",
"(",
"*",
"types",
".",
"Interface",
",",
"error",
")",
"{",
"if",
"netHandle",
"==",
"nil",
"{",
"return",
"nil",
",",
"errNoHandle",
"\... | // getInterface will retrieve interface details from the provided link | [
"getInterface",
"will",
"retrieve",
"interface",
"details",
"from",
"the",
"provided",
"link"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L280-L310 |
28,441 | kata-containers/agent | network.go | updateRoutes | func (s *sandbox) updateRoutes(netHandle *netlink.Handle, requestedRoutes *pb.Routes) (resultingRoutes *pb.Routes, err error) {
if requestedRoutes == nil {
return nil, errNoRoutes
}
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netH... | go | func (s *sandbox) updateRoutes(netHandle *netlink.Handle, requestedRoutes *pb.Routes) (resultingRoutes *pb.Routes, err error) {
if requestedRoutes == nil {
return nil, errNoRoutes
}
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netH... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"updateRoutes",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
",",
"requestedRoutes",
"*",
"pb",
".",
"Routes",
")",
"(",
"resultingRoutes",
"*",
"pb",
".",
"Routes",
",",
"err",
"error",
")",
"{",
"if",
"reque... | //updateRoutes will take requestedRoutes and create netlink routes, with a goal of creating a final
// state which matches the requested routes. In doing this, preesxisting non-loopback routes will be
// removed from the network. If an error occurs, this function returns the list of routes in
// gRPC-route format at ... | [
"updateRoutes",
"will",
"take",
"requestedRoutes",
"and",
"create",
"netlink",
"routes",
"with",
"a",
"goal",
"of",
"creating",
"a",
"final",
"state",
"which",
"matches",
"the",
"requested",
"routes",
".",
"In",
"doing",
"this",
"preesxisting",
"non",
"-",
"lo... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L375-L435 |
28,442 | kata-containers/agent | network.go | getCurrentRoutes | func getCurrentRoutes(netHandle *netlink.Handle) (*pb.Routes, error) {
var err error
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netHandle.Delete()
}
var routes pb.Routes
finalRouteList, err := netHandle.RouteList(nil, netlink.FA... | go | func getCurrentRoutes(netHandle *netlink.Handle) (*pb.Routes, error) {
var err error
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netHandle.Delete()
}
var routes pb.Routes
finalRouteList, err := netHandle.RouteList(nil, netlink.FA... | [
"func",
"getCurrentRoutes",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
")",
"(",
"*",
"pb",
".",
"Routes",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"if",
"netHandle",
"==",
"nil",
"{",
"netHandle",
",",
"err",
"=",
"netlink",
".",
"... | //getCurrentRoutes is a helper to gather existing routes in gRPC protocol format | [
"getCurrentRoutes",
"is",
"a",
"helper",
"to",
"gather",
"existing",
"routes",
"in",
"gRPC",
"protocol",
"format"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L442-L485 |
28,443 | kata-containers/agent | network.go | handleLocalhost | func (s *sandbox) handleLocalhost() error {
span, _ := s.trace("handleLocalhost")
defer span.Finish()
// If not running as the init daemon, there is nothing to do as the
// localhost interface will already exist.
if os.Getpid() != 1 {
return nil
}
lo, err := netlink.LinkByName("lo")
if err != nil {
return... | go | func (s *sandbox) handleLocalhost() error {
span, _ := s.trace("handleLocalhost")
defer span.Finish()
// If not running as the init daemon, there is nothing to do as the
// localhost interface will already exist.
if os.Getpid() != 1 {
return nil
}
lo, err := netlink.LinkByName("lo")
if err != nil {
return... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"handleLocalhost",
"(",
")",
"error",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"// If not running as the init daemon, there is nothi... | // Bring up localhost network interface. | [
"Bring",
"up",
"localhost",
"network",
"interface",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L605-L621 |
28,444 | kata-containers/agent | reaper.go | run | func (r *agentReaper) run(c *exec.Cmd) error {
exitCodeCh, err := r.start(c)
if err != nil {
return fmt.Errorf("reaper: Could not start process: %v", err)
}
_, err = r.wait(exitCodeCh, (*reaperOSProcess)(c.Process))
return err
} | go | func (r *agentReaper) run(c *exec.Cmd) error {
exitCodeCh, err := r.start(c)
if err != nil {
return fmt.Errorf("reaper: Could not start process: %v", err)
}
_, err = r.wait(exitCodeCh, (*reaperOSProcess)(c.Process))
return err
} | [
"func",
"(",
"r",
"*",
"agentReaper",
")",
"run",
"(",
"c",
"*",
"exec",
".",
"Cmd",
")",
"error",
"{",
"exitCodeCh",
",",
"err",
":=",
"r",
".",
"start",
"(",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // run runs the exec command and waits for it, returns once the command
// has been reaped | [
"run",
"runs",
"the",
"exec",
"command",
"and",
"waits",
"for",
"it",
"returns",
"once",
"the",
"command",
"has",
"been",
"reaped"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/reaper.go#L228-L235 |
28,445 | kata-containers/agent | reaper.go | combinedOutput | func (r *agentReaper) combinedOutput(c *exec.Cmd) ([]byte, error) {
if c.Stdout != nil {
return nil, errors.New("reaper: Stdout already set")
}
if c.Stderr != nil {
return nil, errors.New("reaper: Stderr already set")
}
var b bytes.Buffer
c.Stdout = &b
c.Stderr = &b
err := r.run(c)
return b.Bytes(), err
} | go | func (r *agentReaper) combinedOutput(c *exec.Cmd) ([]byte, error) {
if c.Stdout != nil {
return nil, errors.New("reaper: Stdout already set")
}
if c.Stderr != nil {
return nil, errors.New("reaper: Stderr already set")
}
var b bytes.Buffer
c.Stdout = &b
c.Stderr = &b
err := r.run(c)
return b.Bytes(), err
} | [
"func",
"(",
"r",
"*",
"agentReaper",
")",
"combinedOutput",
"(",
"c",
"*",
"exec",
".",
"Cmd",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"c",
".",
"Stdout",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"... | // combinedOutput combines command's stdout and stderr in one buffer,
// returns once the command has been reaped | [
"combinedOutput",
"combines",
"command",
"s",
"stdout",
"and",
"stderr",
"in",
"one",
"buffer",
"returns",
"once",
"the",
"command",
"has",
"been",
"reaped"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/reaper.go#L239-L252 |
28,446 | mattn/go-oci8 | statement.go | Close | func (stmt *OCI8Stmt) Close() error {
if stmt.closed {
return nil
}
stmt.closed = true
C.OCIHandleFree(unsafe.Pointer(stmt.stmt), C.OCI_HTYPE_STMT)
stmt.stmt = nil
stmt.pbind = nil
return nil
} | go | func (stmt *OCI8Stmt) Close() error {
if stmt.closed {
return nil
}
stmt.closed = true
C.OCIHandleFree(unsafe.Pointer(stmt.stmt), C.OCI_HTYPE_STMT)
stmt.stmt = nil
stmt.pbind = nil
return nil
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"stmt",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"stmt",
".",
"closed",
"=",
"true",
"\n\n",
"C",
".",
"OCIHandleFree",
"(",
"unsafe",
".",
"Pointer",
"(... | // Close closes the statement | [
"Close",
"closes",
"the",
"statement"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L19-L31 |
28,447 | mattn/go-oci8 | statement.go | NumInput | func (stmt *OCI8Stmt) NumInput() int {
var bindCount C.ub4 // number of bind position
_, err := stmt.ociAttrGet(unsafe.Pointer(&bindCount), C.OCI_ATTR_BIND_COUNT)
if err != nil {
return -1
}
return int(bindCount)
} | go | func (stmt *OCI8Stmt) NumInput() int {
var bindCount C.ub4 // number of bind position
_, err := stmt.ociAttrGet(unsafe.Pointer(&bindCount), C.OCI_ATTR_BIND_COUNT)
if err != nil {
return -1
}
return int(bindCount)
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"NumInput",
"(",
")",
"int",
"{",
"var",
"bindCount",
"C",
".",
"ub4",
"// number of bind position",
"\n",
"_",
",",
"err",
":=",
"stmt",
".",
"ociAttrGet",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"bindCount",
... | // NumInput returns the number of input | [
"NumInput",
"returns",
"the",
"number",
"of",
"input"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L34-L42 |
28,448 | mattn/go-oci8 | statement.go | Query | func (stmt *OCI8Stmt) Query(args []driver.Value) (rows driver.Rows, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.query(context.Background(), list, false)
} | go | func (stmt *OCI8Stmt) Query(args []driver.Value) (rows driver.Rows, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.query(context.Background(), list, false)
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"Query",
"(",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"rows",
"driver",
".",
"Rows",
",",
"err",
"error",
")",
"{",
"list",
":=",
"make",
"(",
"[",
"]",
"namedValue",
",",
"len",
"(",
"args",... | // Query runs a query | [
"Query",
"runs",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L310-L319 |
28,449 | mattn/go-oci8 | statement.go | getRowid | func (stmt *OCI8Stmt) getRowid() (string, error) {
rowidP, _, err := stmt.conn.ociDescriptorAlloc(C.OCI_DTYPE_ROWID, 0)
if err != nil {
return "", err
}
// OCI_ATTR_ROWID returns the ROWID descriptor allocated with OCIDescriptorAlloc()
_, err = stmt.ociAttrGet(*rowidP, C.OCI_ATTR_ROWID)
if err != nil {
retur... | go | func (stmt *OCI8Stmt) getRowid() (string, error) {
rowidP, _, err := stmt.conn.ociDescriptorAlloc(C.OCI_DTYPE_ROWID, 0)
if err != nil {
return "", err
}
// OCI_ATTR_ROWID returns the ROWID descriptor allocated with OCIDescriptorAlloc()
_, err = stmt.ociAttrGet(*rowidP, C.OCI_ATTR_ROWID)
if err != nil {
retur... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"getRowid",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"rowidP",
",",
"_",
",",
"err",
":=",
"stmt",
".",
"conn",
".",
"ociDescriptorAlloc",
"(",
"C",
".",
"OCI_DTYPE_ROWID",
",",
"0",
")",
"\n",
"if... | // getRowid returns the rowid | [
"getRowid",
"returns",
"the",
"rowid"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L579-L601 |
28,450 | mattn/go-oci8 | statement.go | rowsAffected | func (stmt *OCI8Stmt) rowsAffected() (int64, error) {
var rowCount C.ub4 // Number of rows processed so far after SELECT statements. For INSERT, UPDATE, and DELETE statements, it is the number of rows processed by the most recent statement. The default value is 1.
_, err := stmt.ociAttrGet(unsafe.Pointer(&rowCount), ... | go | func (stmt *OCI8Stmt) rowsAffected() (int64, error) {
var rowCount C.ub4 // Number of rows processed so far after SELECT statements. For INSERT, UPDATE, and DELETE statements, it is the number of rows processed by the most recent statement. The default value is 1.
_, err := stmt.ociAttrGet(unsafe.Pointer(&rowCount), ... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"rowsAffected",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"rowCount",
"C",
".",
"ub4",
"// Number of rows processed so far after SELECT statements. For INSERT, UPDATE, and DELETE statements, it is the number of rows proc... | // rowsAffected returns the number of rows affected | [
"rowsAffected",
"returns",
"the",
"number",
"of",
"rows",
"affected"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L604-L611 |
28,451 | mattn/go-oci8 | statement.go | Exec | func (stmt *OCI8Stmt) Exec(args []driver.Value) (r driver.Result, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.exec(context.Background(), list)
} | go | func (stmt *OCI8Stmt) Exec(args []driver.Value) (r driver.Result, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.exec(context.Background(), list)
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"Exec",
"(",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"r",
"driver",
".",
"Result",
",",
"err",
"error",
")",
"{",
"list",
":=",
"make",
"(",
"[",
"]",
"namedValue",
",",
"len",
"(",
"args",
... | // Exec runs an exec query | [
"Exec",
"runs",
"an",
"exec",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L614-L623 |
28,452 | mattn/go-oci8 | statement.go | exec | func (stmt *OCI8Stmt) exec(ctx context.Context, args []namedValue) (driver.Result, error) {
binds, err := stmt.bind(ctx, args)
if err != nil {
return nil, err
}
defer freeBinds(binds)
mode := C.ub4(C.OCI_DEFAULT)
if stmt.conn.inTransaction == false {
mode = mode | C.OCI_COMMIT_ON_SUCCESS
}
done := make(c... | go | func (stmt *OCI8Stmt) exec(ctx context.Context, args []namedValue) (driver.Result, error) {
binds, err := stmt.bind(ctx, args)
if err != nil {
return nil, err
}
defer freeBinds(binds)
mode := C.ub4(C.OCI_DEFAULT)
if stmt.conn.inTransaction == false {
mode = mode | C.OCI_COMMIT_ON_SUCCESS
}
done := make(c... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"[",
"]",
"namedValue",
")",
"(",
"driver",
".",
"Result",
",",
"error",
")",
"{",
"binds",
",",
"err",
":=",
"stmt",
".",
"bind",
"(",
"ctx",
... | // exec runs an exec query | [
"exec",
"runs",
"an",
"exec",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L626-L662 |
28,453 | mattn/go-oci8 | statement.go | ociParamGet | func (stmt *OCI8Stmt) ociParamGet(position C.ub4) (*C.OCIParam, error) {
var paramTemp *C.OCIParam
param := ¶mTemp
result := C.OCIParamGet(
unsafe.Pointer(stmt.stmt), // A statement handle or describe handle
C.OCI_HTYPE_STMT, // Handle type: OCI_HTYPE_STMT, for a state... | go | func (stmt *OCI8Stmt) ociParamGet(position C.ub4) (*C.OCIParam, error) {
var paramTemp *C.OCIParam
param := ¶mTemp
result := C.OCIParamGet(
unsafe.Pointer(stmt.stmt), // A statement handle or describe handle
C.OCI_HTYPE_STMT, // Handle type: OCI_HTYPE_STMT, for a state... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociParamGet",
"(",
"position",
"C",
".",
"ub4",
")",
"(",
"*",
"C",
".",
"OCIParam",
",",
"error",
")",
"{",
"var",
"paramTemp",
"*",
"C",
".",
"OCIParam",
"\n",
"param",
":=",
"&",
"paramTemp",
"\n\n",
"... | // ociParamGet calls OCIParamGet then returns OCIParam and error.
// OCIDescriptorFree must be called on returned OCIParam. | [
"ociParamGet",
"calls",
"OCIParamGet",
"then",
"returns",
"OCIParam",
"and",
"error",
".",
"OCIDescriptorFree",
"must",
"be",
"called",
"on",
"returned",
"OCIParam",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L817-L835 |
28,454 | mattn/go-oci8 | statement.go | ociAttrGet | func (stmt *OCI8Stmt) ociAttrGet(value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(stmt.stmt), // Pointer to a handle type
C.OCI_HTYPE_STMT, // The handle type: OCI_HTYPE_STMT, for a statement handle
value, // Pointer ... | go | func (stmt *OCI8Stmt) ociAttrGet(value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(stmt.stmt), // Pointer to a handle type
C.OCI_HTYPE_STMT, // The handle type: OCI_HTYPE_STMT, for a statement handle
value, // Pointer ... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociAttrGet",
"(",
"value",
"unsafe",
".",
"Pointer",
",",
"attributeType",
"C",
".",
"ub4",
")",
"(",
"C",
".",
"ub4",
",",
"error",
")",
"{",
"var",
"size",
"C",
".",
"ub4",
"\n\n",
"result",
":=",
"C",
... | // ociAttrGet calls OCIAttrGet with OCIStmt then returns attribute size and error.
// The attribute value is stored into passed value. | [
"ociAttrGet",
"calls",
"OCIAttrGet",
"with",
"OCIStmt",
"then",
"returns",
"attribute",
"size",
"and",
"error",
".",
"The",
"attribute",
"value",
"is",
"stored",
"into",
"passed",
"value",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L839-L852 |
28,455 | mattn/go-oci8 | statement.go | ociBindByName | func (stmt *OCI8Stmt) ociBindByName(name []byte, bind *oci8Bind) error {
result := C.OCIBindByName(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deall... | go | func (stmt *OCI8Stmt) ociBindByName(name []byte, bind *oci8Bind) error {
result := C.OCIBindByName(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deall... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociBindByName",
"(",
"name",
"[",
"]",
"byte",
",",
"bind",
"*",
"oci8Bind",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIBindByName",
"(",
"stmt",
".",
"stmt",
",",
"// The statement handle",
"&",
"bind",
... | // ociBindByName calls OCIBindByName, then returns bind handle and error. | [
"ociBindByName",
"calls",
"OCIBindByName",
"then",
"returns",
"bind",
"handle",
"and",
"error",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L855-L874 |
28,456 | mattn/go-oci8 | statement.go | ociBindByPos | func (stmt *OCI8Stmt) ociBindByPos(position C.ub4, bind *oci8Bind) error {
result := C.OCIBindByPos(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deal... | go | func (stmt *OCI8Stmt) ociBindByPos(position C.ub4, bind *oci8Bind) error {
result := C.OCIBindByPos(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deal... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociBindByPos",
"(",
"position",
"C",
".",
"ub4",
",",
"bind",
"*",
"oci8Bind",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIBindByPos",
"(",
"stmt",
".",
"stmt",
",",
"// The statement handle",
"&",
"bind",... | // ociBindByPos calls OCIBindByPos, then returns bind handle and error. | [
"ociBindByPos",
"calls",
"OCIBindByPos",
"then",
"returns",
"bind",
"handle",
"and",
"error",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L877-L895 |
28,457 | mattn/go-oci8 | statement.go | ociStmtExecute | func (stmt *OCI8Stmt) ociStmtExecute(iters C.ub4, mode C.ub4) error {
result := C.OCIStmtExecute(
stmt.conn.svc, // Service context handle
stmt.stmt, // A statement handle
stmt.conn.errHandle, // An error handle
iters, // For non-SELECT statements, the number of times this stateme... | go | func (stmt *OCI8Stmt) ociStmtExecute(iters C.ub4, mode C.ub4) error {
result := C.OCIStmtExecute(
stmt.conn.svc, // Service context handle
stmt.stmt, // A statement handle
stmt.conn.errHandle, // An error handle
iters, // For non-SELECT statements, the number of times this stateme... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociStmtExecute",
"(",
"iters",
"C",
".",
"ub4",
",",
"mode",
"C",
".",
"ub4",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIStmtExecute",
"(",
"stmt",
".",
"conn",
".",
"svc",
",",
"// Service context hand... | // ociStmtExecute calls OCIStmtExecute | [
"ociStmtExecute",
"calls",
"OCIStmtExecute"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L898-L911 |
28,458 | mattn/go-oci8 | statement.go | ociBreak | func (stmt *OCI8Stmt) ociBreak(ctx context.Context, done chan struct{}) {
select {
case <-done:
case <-ctx.Done():
// select again to avoid race condition if both are done
select {
case <-done:
default:
result := C.OCIBreak(
unsafe.Pointer(stmt.conn.svc), // The service context handle or the server co... | go | func (stmt *OCI8Stmt) ociBreak(ctx context.Context, done chan struct{}) {
select {
case <-done:
case <-ctx.Done():
// select again to avoid race condition if both are done
select {
case <-done:
default:
result := C.OCIBreak(
unsafe.Pointer(stmt.conn.svc), // The service context handle or the server co... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociBreak",
"(",
"ctx",
"context",
".",
"Context",
",",
"done",
"chan",
"struct",
"{",
"}",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"// select a... | // ociBreak calls OCIBreak if ctx.Done is finished before done chan is closed | [
"ociBreak",
"calls",
"OCIBreak",
"if",
"ctx",
".",
"Done",
"is",
"finished",
"before",
"done",
"chan",
"is",
"closed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L914-L932 |
28,459 | mattn/go-oci8 | connection.go | Exec | func (conn *OCI8Conn) Exec(query string, args []driver.Value) (driver.Result, error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return conn.exec(context.Background(), query, list)
} | go | func (conn *OCI8Conn) Exec(query string, args []driver.Value) (driver.Result, error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return conn.exec(context.Background(), query, list)
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Exec",
"(",
"query",
"string",
",",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"driver",
".",
"Result",
",",
"error",
")",
"{",
"list",
":=",
"make",
"(",
"[",
"]",
"namedValue",
",",
"len",
"(... | // Exec executes a query | [
"Exec",
"executes",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L16-L25 |
28,460 | mattn/go-oci8 | connection.go | Ping | func (conn *OCI8Conn) Ping(ctx context.Context) error {
result := C.OCIPing(conn.svc, conn.errHandle, C.OCI_DEFAULT)
if result == C.OCI_SUCCESS || result == C.OCI_SUCCESS_WITH_INFO {
return nil
}
errorCode, err := conn.ociGetError()
if errorCode == 1010 {
// Older versions of Oracle do not support ping,
// b... | go | func (conn *OCI8Conn) Ping(ctx context.Context) error {
result := C.OCIPing(conn.svc, conn.errHandle, C.OCI_DEFAULT)
if result == C.OCI_SUCCESS || result == C.OCI_SUCCESS_WITH_INFO {
return nil
}
errorCode, err := conn.ociGetError()
if errorCode == 1010 {
// Older versions of Oracle do not support ping,
// b... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Ping",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIPing",
"(",
"conn",
".",
"svc",
",",
"conn",
".",
"errHandle",
",",
"C",
".",
"OCI_DEFAULT",
")",
"\n",
"if",... | // Ping database connection | [
"Ping",
"database",
"connection"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L54-L69 |
28,461 | mattn/go-oci8 | connection.go | Begin | func (conn *OCI8Conn) Begin() (driver.Tx, error) {
return conn.BeginTx(context.Background(), driver.TxOptions{})
} | go | func (conn *OCI8Conn) Begin() (driver.Tx, error) {
return conn.BeginTx(context.Background(), driver.TxOptions{})
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Begin",
"(",
")",
"(",
"driver",
".",
"Tx",
",",
"error",
")",
"{",
"return",
"conn",
".",
"BeginTx",
"(",
"context",
".",
"Background",
"(",
")",
",",
"driver",
".",
"TxOptions",
"{",
"}",
")",
"\n",
"... | // Begin starts a transaction | [
"Begin",
"starts",
"a",
"transaction"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L72-L74 |
28,462 | mattn/go-oci8 | connection.go | BeginTx | func (conn *OCI8Conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (driver.Tx, error) {
if conn.transactionMode != C.OCI_TRANS_READWRITE {
// transaction handle
trans, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_TRANS, 0)
if err != nil {
return nil, fmt.Errorf("allocate transaction handle error: %v"... | go | func (conn *OCI8Conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (driver.Tx, error) {
if conn.transactionMode != C.OCI_TRANS_READWRITE {
// transaction handle
trans, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_TRANS, 0)
if err != nil {
return nil, fmt.Errorf("allocate transaction handle error: %v"... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"BeginTx",
"(",
"ctx",
"context",
".",
"Context",
",",
"txOptions",
"driver",
".",
"TxOptions",
")",
"(",
"driver",
".",
"Tx",
",",
"error",
")",
"{",
"if",
"conn",
".",
"transactionMode",
"!=",
"C",
".",
"O... | // BeginTx starts a transaction | [
"BeginTx",
"starts",
"a",
"transaction"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L77-L110 |
28,463 | mattn/go-oci8 | connection.go | Prepare | func (conn *OCI8Conn) Prepare(query string) (driver.Stmt, error) {
return conn.PrepareContext(context.Background(), query)
} | go | func (conn *OCI8Conn) Prepare(query string) (driver.Stmt, error) {
return conn.PrepareContext(context.Background(), query)
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Prepare",
"(",
"query",
"string",
")",
"(",
"driver",
".",
"Stmt",
",",
"error",
")",
"{",
"return",
"conn",
".",
"PrepareContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"query",
")",
"\n",
"}"
... | // Prepare prepares a query | [
"Prepare",
"prepares",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L160-L162 |
28,464 | mattn/go-oci8 | connection.go | PrepareContext | func (conn *OCI8Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
if conn.enableQMPlaceholders {
query = placeholders(query)
}
queryP := cString(query)
defer C.free(unsafe.Pointer(queryP))
// statement handle
stmt, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_STMT, 0)
if err != nil ... | go | func (conn *OCI8Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
if conn.enableQMPlaceholders {
query = placeholders(query)
}
queryP := cString(query)
defer C.free(unsafe.Pointer(queryP))
// statement handle
stmt, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_STMT, 0)
if err != nil ... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"PrepareContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
")",
"(",
"driver",
".",
"Stmt",
",",
"error",
")",
"{",
"if",
"conn",
".",
"enableQMPlaceholders",
"{",
"query",
"=",
"placeholde... | // PrepareContext prepares a query | [
"PrepareContext",
"prepares",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L165-L192 |
28,465 | mattn/go-oci8 | connection.go | ociGetError | func (conn *OCI8Conn) ociGetError() (int, error) {
var errorCode C.sb4
errorText := make([]byte, 1024)
result := C.OCIErrorGet(
unsafe.Pointer(conn.errHandle), // error handle
1, // status record number, starts from 1
nil, // sqlstate, not supported in r... | go | func (conn *OCI8Conn) ociGetError() (int, error) {
var errorCode C.sb4
errorText := make([]byte, 1024)
result := C.OCIErrorGet(
unsafe.Pointer(conn.errHandle), // error handle
1, // status record number, starts from 1
nil, // sqlstate, not supported in r... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociGetError",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"errorCode",
"C",
".",
"sb4",
"\n",
"errorText",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1024",
")",
"\n\n",
"result",
":=",
"C",
".... | // ociGetError calls OCIErrorGet then returs error code and text | [
"ociGetError",
"calls",
"OCIErrorGet",
"then",
"returs",
"error",
"code",
"and",
"text"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L236-L256 |
28,466 | mattn/go-oci8 | connection.go | ociAttrGet | func (conn *OCI8Conn) ociAttrGet(paramHandle *C.OCIParam, value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(paramHandle), // Pointer to a handle type
C.OCI_DTYPE_PARAM, // The handle type: OCI_DTYPE_PARAM, for a parameter descriptor
valu... | go | func (conn *OCI8Conn) ociAttrGet(paramHandle *C.OCIParam, value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(paramHandle), // Pointer to a handle type
C.OCI_DTYPE_PARAM, // The handle type: OCI_DTYPE_PARAM, for a parameter descriptor
valu... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociAttrGet",
"(",
"paramHandle",
"*",
"C",
".",
"OCIParam",
",",
"value",
"unsafe",
".",
"Pointer",
",",
"attributeType",
"C",
".",
"ub4",
")",
"(",
"C",
".",
"ub4",
",",
"error",
")",
"{",
"var",
"size",
... | // ociAttrGet calls OCIAttrGet with OCIParam then returns attribute size and error.
// The attribute value is stored into passed value. | [
"ociAttrGet",
"calls",
"OCIAttrGet",
"with",
"OCIParam",
"then",
"returns",
"attribute",
"size",
"and",
"error",
".",
"The",
"attribute",
"value",
"is",
"stored",
"into",
"passed",
"value",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L260-L273 |
28,467 | mattn/go-oci8 | connection.go | ociAttrSet | func (conn *OCI8Conn) ociAttrSet(
handle unsafe.Pointer,
handleType C.ub4,
value unsafe.Pointer,
valueSize C.ub4,
attributeType C.ub4,
) error {
result := C.OCIAttrSet(
handle, // Pointer to a handle whose attribute gets modified
handleType, // The handle type
value, // Pointer to an at... | go | func (conn *OCI8Conn) ociAttrSet(
handle unsafe.Pointer,
handleType C.ub4,
value unsafe.Pointer,
valueSize C.ub4,
attributeType C.ub4,
) error {
result := C.OCIAttrSet(
handle, // Pointer to a handle whose attribute gets modified
handleType, // The handle type
value, // Pointer to an at... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociAttrSet",
"(",
"handle",
"unsafe",
".",
"Pointer",
",",
"handleType",
"C",
".",
"ub4",
",",
"value",
"unsafe",
".",
"Pointer",
",",
"valueSize",
"C",
".",
"ub4",
",",
"attributeType",
"C",
".",
"ub4",
",",... | // ociAttrSet calls OCIAttrSet.
// Only uses errHandle from conn, so can be called in conn setup after errHandle has been set. | [
"ociAttrSet",
"calls",
"OCIAttrSet",
".",
"Only",
"uses",
"errHandle",
"from",
"conn",
"so",
"can",
"be",
"called",
"in",
"conn",
"setup",
"after",
"errHandle",
"has",
"been",
"set",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L277-L294 |
28,468 | mattn/go-oci8 | connection.go | ociHandleAlloc | func (conn *OCI8Conn) ociHandleAlloc(handleType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var handleTemp unsafe.Pointer
handle := &handleTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIHandleAlloc(
unsafe.Pointer(conn.... | go | func (conn *OCI8Conn) ociHandleAlloc(handleType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var handleTemp unsafe.Pointer
handle := &handleTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIHandleAlloc(
unsafe.Pointer(conn.... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociHandleAlloc",
"(",
"handleType",
"C",
".",
"ub4",
",",
"size",
"C",
".",
"size_t",
")",
"(",
"*",
"unsafe",
".",
"Pointer",
",",
"*",
"unsafe",
".",
"Pointer",
",",
"error",
")",
"{",
"var",
"handleTemp"... | // ociHandleAlloc calls OCIHandleAlloc then returns
// handle pointer to pointer, buffer pointer to pointer, and error | [
"ociHandleAlloc",
"calls",
"OCIHandleAlloc",
"then",
"returns",
"handle",
"pointer",
"to",
"pointer",
"buffer",
"pointer",
"to",
"pointer",
"and",
"error"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L298-L325 |
28,469 | mattn/go-oci8 | connection.go | ociDescriptorAlloc | func (conn *OCI8Conn) ociDescriptorAlloc(descriptorType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var descriptorTemp unsafe.Pointer
descriptor := &descriptorTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIDescriptorAlloc... | go | func (conn *OCI8Conn) ociDescriptorAlloc(descriptorType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var descriptorTemp unsafe.Pointer
descriptor := &descriptorTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIDescriptorAlloc... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociDescriptorAlloc",
"(",
"descriptorType",
"C",
".",
"ub4",
",",
"size",
"C",
".",
"size_t",
")",
"(",
"*",
"unsafe",
".",
"Pointer",
",",
"*",
"unsafe",
".",
"Pointer",
",",
"error",
")",
"{",
"var",
"des... | // ociDescriptorAlloc calls OCIDescriptorAlloc then returns
// descriptor pointer to pointer, buffer pointer to pointer, and error | [
"ociDescriptorAlloc",
"calls",
"OCIDescriptorAlloc",
"then",
"returns",
"descriptor",
"pointer",
"to",
"pointer",
"buffer",
"pointer",
"to",
"pointer",
"and",
"error"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L329-L356 |
28,470 | mattn/go-oci8 | connection.go | ociLobRead | func (conn *OCI8Conn) ociLobRead(lobLocator *C.OCILobLocator, form C.ub1) ([]byte, error) {
readBuffer := make([]byte, lobBufferSize)
buffer := make([]byte, 0)
result := (C.sword)(C.OCI_NEED_DATA)
piece := (C.ub1)(C.OCI_FIRST_PIECE)
for result == C.OCI_NEED_DATA {
readBytes := (C.oraub8)(0)
// If both byte_a... | go | func (conn *OCI8Conn) ociLobRead(lobLocator *C.OCILobLocator, form C.ub1) ([]byte, error) {
readBuffer := make([]byte, lobBufferSize)
buffer := make([]byte, 0)
result := (C.sword)(C.OCI_NEED_DATA)
piece := (C.ub1)(C.OCI_FIRST_PIECE)
for result == C.OCI_NEED_DATA {
readBytes := (C.oraub8)(0)
// If both byte_a... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociLobRead",
"(",
"lobLocator",
"*",
"C",
".",
"OCILobLocator",
",",
"form",
"C",
".",
"ub1",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"readBuffer",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
... | // ociLobRead calls OCILobRead then returns lob bytes and error. | [
"ociLobRead",
"calls",
"OCILobRead",
"then",
"returns",
"lob",
"bytes",
"and",
"error",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L359-L395 |
28,471 | mattn/go-oci8 | connector.go | NewConnector | func NewConnector(hosts ...string) driver.Connector {
return &OCI8Connector{
Logger: log.New(ioutil.Discard, "", 0),
}
} | go | func NewConnector(hosts ...string) driver.Connector {
return &OCI8Connector{
Logger: log.New(ioutil.Discard, "", 0),
}
} | [
"func",
"NewConnector",
"(",
"hosts",
"...",
"string",
")",
"driver",
".",
"Connector",
"{",
"return",
"&",
"OCI8Connector",
"{",
"Logger",
":",
"log",
".",
"New",
"(",
"ioutil",
".",
"Discard",
",",
"\"",
"\"",
",",
"0",
")",
",",
"}",
"\n",
"}"
] | // NewConnector returns a new database connector | [
"NewConnector",
"returns",
"a",
"new",
"database",
"connector"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connector.go#L13-L17 |
28,472 | mattn/go-oci8 | connector.go | Connect | func (oci8Connector *OCI8Connector) Connect(ctx context.Context) (driver.Conn, error) {
oci8Conn := &OCI8Conn{
logger: oci8Connector.Logger,
}
if oci8Conn.logger == nil {
oci8Conn.logger = log.New(ioutil.Discard, "", 0)
}
return oci8Conn, nil
} | go | func (oci8Connector *OCI8Connector) Connect(ctx context.Context) (driver.Conn, error) {
oci8Conn := &OCI8Conn{
logger: oci8Connector.Logger,
}
if oci8Conn.logger == nil {
oci8Conn.logger = log.New(ioutil.Discard, "", 0)
}
return oci8Conn, nil
} | [
"func",
"(",
"oci8Connector",
"*",
"OCI8Connector",
")",
"Connect",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"driver",
".",
"Conn",
",",
"error",
")",
"{",
"oci8Conn",
":=",
"&",
"OCI8Conn",
"{",
"logger",
":",
"oci8Connector",
".",
"Logger",
","... | // Connect returns a new database connection | [
"Connect",
"returns",
"a",
"new",
"database",
"connection"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connector.go#L25-L34 |
28,473 | mattn/go-oci8 | oci8.go | Commit | func (tx *OCI8Tx) Commit() error {
tx.conn.inTransaction = false
if rv := C.OCITransCommit(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | go | func (tx *OCI8Tx) Commit() error {
tx.conn.inTransaction = false
if rv := C.OCITransCommit(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | [
"func",
"(",
"tx",
"*",
"OCI8Tx",
")",
"Commit",
"(",
")",
"error",
"{",
"tx",
".",
"conn",
".",
"inTransaction",
"=",
"false",
"\n",
"if",
"rv",
":=",
"C",
".",
"OCITransCommit",
"(",
"tx",
".",
"conn",
".",
"svc",
",",
"tx",
".",
"conn",
".",
... | // Commit transaction commit | [
"Commit",
"transaction",
"commit"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8.go#L130-L140 |
28,474 | mattn/go-oci8 | oci8.go | Rollback | func (tx *OCI8Tx) Rollback() error {
tx.conn.inTransaction = false
if rv := C.OCITransRollback(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | go | func (tx *OCI8Tx) Rollback() error {
tx.conn.inTransaction = false
if rv := C.OCITransRollback(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | [
"func",
"(",
"tx",
"*",
"OCI8Tx",
")",
"Rollback",
"(",
")",
"error",
"{",
"tx",
".",
"conn",
".",
"inTransaction",
"=",
"false",
"\n",
"if",
"rv",
":=",
"C",
".",
"OCITransRollback",
"(",
"tx",
".",
"conn",
".",
"svc",
",",
"tx",
".",
"conn",
".... | // Rollback transaction rollback | [
"Rollback",
"transaction",
"rollback"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8.go#L143-L153 |
28,475 | mattn/go-oci8 | oci8.go | LastInsertId | func (result *OCI8Result) LastInsertId() (int64, error) {
return int64(uintptr(unsafe.Pointer(&result.rowid))), result.rowidErr
} | go | func (result *OCI8Result) LastInsertId() (int64, error) {
return int64(uintptr(unsafe.Pointer(&result.rowid))), result.rowidErr
} | [
"func",
"(",
"result",
"*",
"OCI8Result",
")",
"LastInsertId",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"int64",
"(",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"result",
".",
"rowid",
")",
")",
")",
",",
"result",
".",
"r... | // LastInsertId returns last inserted ID | [
"LastInsertId",
"returns",
"last",
"inserted",
"ID"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8.go#L364-L366 |
28,476 | mattn/go-oci8 | oci8_go18.go | CheckNamedValue | func (conn *OCI8Conn) CheckNamedValue(nv *driver.NamedValue) error {
switch nv.Value.(type) {
default:
return driver.ErrSkip
case sql.Out:
return nil
}
} | go | func (conn *OCI8Conn) CheckNamedValue(nv *driver.NamedValue) error {
switch nv.Value.(type) {
default:
return driver.ErrSkip
case sql.Out:
return nil
}
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"CheckNamedValue",
"(",
"nv",
"*",
"driver",
".",
"NamedValue",
")",
"error",
"{",
"switch",
"nv",
".",
"Value",
".",
"(",
"type",
")",
"{",
"default",
":",
"return",
"driver",
".",
"ErrSkip",
"\n",
"case",
... | // CheckNamedValue checks the named value | [
"CheckNamedValue",
"checks",
"the",
"named",
"value"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8_go18.go#L52-L59 |
28,477 | mattn/go-oci8 | cHelpers.go | cByte | func cByte(b []byte) *C.OraText {
p := C.malloc(C.size_t(len(b)))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | go | func cByte(b []byte) *C.OraText {
p := C.malloc(C.size_t(len(b)))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | [
"func",
"cByte",
"(",
"b",
"[",
"]",
"byte",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"len",
"(",
"b",
")",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte",
... | // cByte comverts byte slice to OraText.
// must be freed | [
"cByte",
"comverts",
"byte",
"slice",
"to",
"OraText",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L22-L27 |
28,478 | mattn/go-oci8 | cHelpers.go | cByteN | func cByteN(b []byte, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | go | func cByteN(b []byte, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | [
"func",
"cByteN",
"(",
"b",
"[",
"]",
"byte",
",",
"size",
"int",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"size",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"b... | // cByteN comverts byte slice to C OraText with size.
// must be freed | [
"cByteN",
"comverts",
"byte",
"slice",
"to",
"C",
"OraText",
"with",
"size",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L31-L36 |
28,479 | mattn/go-oci8 | cHelpers.go | cString | func cString(s string) *C.OraText {
p := C.malloc(C.size_t(len(s) + 1))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
pp[len(s)] = 0
return (*C.OraText)(p)
} | go | func cString(s string) *C.OraText {
p := C.malloc(C.size_t(len(s) + 1))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
pp[len(s)] = 0
return (*C.OraText)(p)
} | [
"func",
"cString",
"(",
"s",
"string",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"len",
"(",
"s",
")",
"+",
"1",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte... | // cString coverts string to C OraText.
// must be freed | [
"cString",
"coverts",
"string",
"to",
"C",
"OraText",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L40-L46 |
28,480 | mattn/go-oci8 | cHelpers.go | cStringN | func cStringN(s string, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
if len(s) < size {
pp[len(s)] = 0
} else {
pp[size-1] = 0
}
return (*C.OraText)(p)
} | go | func cStringN(s string, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
if len(s) < size {
pp[len(s)] = 0
} else {
pp[size-1] = 0
}
return (*C.OraText)(p)
} | [
"func",
"cStringN",
"(",
"s",
"string",
",",
"size",
"int",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"size",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte",
")... | // cStringN coverts string to C OraText with size.
// must be freed | [
"cStringN",
"coverts",
"string",
"to",
"C",
"OraText",
"with",
"size",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L50-L60 |
28,481 | mattn/go-oci8 | cHelpers.go | cGoStringN | func cGoStringN(s *C.OraText, size int) string {
if size == 0 {
return ""
}
p := (*[1 << 30]byte)(unsafe.Pointer(s))
buf := make([]byte, size)
copy(buf, p[:])
return *(*string)(unsafe.Pointer(&buf))
} | go | func cGoStringN(s *C.OraText, size int) string {
if size == 0 {
return ""
}
p := (*[1 << 30]byte)(unsafe.Pointer(s))
buf := make([]byte, size)
copy(buf, p[:])
return *(*string)(unsafe.Pointer(&buf))
} | [
"func",
"cGoStringN",
"(",
"s",
"*",
"C",
".",
"OraText",
",",
"size",
"int",
")",
"string",
"{",
"if",
"size",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"p",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte",
")",
"(",
"unsafe",... | // CGoStringN coverts C OraText to Go string | [
"CGoStringN",
"coverts",
"C",
"OraText",
"to",
"Go",
"string"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L63-L71 |
28,482 | mattn/go-oci8 | cHelpers.go | freeDefines | func freeDefines(defines []oci8Define) {
for _, define := range defines {
if define.pbuf != nil {
freeBuffer(define.pbuf, define.dataType)
define.pbuf = nil
}
if define.length != nil {
C.free(unsafe.Pointer(define.length))
define.length = nil
}
if define.indicator != nil {
C.free(unsafe.Pointe... | go | func freeDefines(defines []oci8Define) {
for _, define := range defines {
if define.pbuf != nil {
freeBuffer(define.pbuf, define.dataType)
define.pbuf = nil
}
if define.length != nil {
C.free(unsafe.Pointer(define.length))
define.length = nil
}
if define.indicator != nil {
C.free(unsafe.Pointe... | [
"func",
"freeDefines",
"(",
"defines",
"[",
"]",
"oci8Define",
")",
"{",
"for",
"_",
",",
"define",
":=",
"range",
"defines",
"{",
"if",
"define",
".",
"pbuf",
"!=",
"nil",
"{",
"freeBuffer",
"(",
"define",
".",
"pbuf",
",",
"define",
".",
"dataType",
... | // freeDefines frees defines | [
"freeDefines",
"frees",
"defines"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L74-L90 |
28,483 | mattn/go-oci8 | cHelpers.go | freeBinds | func freeBinds(binds []oci8Bind) {
for _, bind := range binds {
if bind.pbuf != nil {
freeBuffer(bind.pbuf, bind.dataType)
bind.pbuf = nil
}
if bind.length != nil {
C.free(unsafe.Pointer(bind.length))
bind.length = nil
}
if bind.indicator != nil {
C.free(unsafe.Pointer(bind.indicator))
bind... | go | func freeBinds(binds []oci8Bind) {
for _, bind := range binds {
if bind.pbuf != nil {
freeBuffer(bind.pbuf, bind.dataType)
bind.pbuf = nil
}
if bind.length != nil {
C.free(unsafe.Pointer(bind.length))
bind.length = nil
}
if bind.indicator != nil {
C.free(unsafe.Pointer(bind.indicator))
bind... | [
"func",
"freeBinds",
"(",
"binds",
"[",
"]",
"oci8Bind",
")",
"{",
"for",
"_",
",",
"bind",
":=",
"range",
"binds",
"{",
"if",
"bind",
".",
"pbuf",
"!=",
"nil",
"{",
"freeBuffer",
"(",
"bind",
".",
"pbuf",
",",
"bind",
".",
"dataType",
")",
"\n",
... | // freeBinds frees binds | [
"freeBinds",
"frees",
"binds"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L93-L109 |
28,484 | mattn/go-oci8 | cHelpers.go | freeBuffer | func freeBuffer(buffer unsafe.Pointer, dataType C.ub2) {
switch dataType {
case C.SQLT_CLOB, C.SQLT_BLOB:
C.OCIDescriptorFree(*(*unsafe.Pointer)(buffer), C.OCI_DTYPE_LOB)
case C.SQLT_TIMESTAMP:
C.OCIDescriptorFree(*(*unsafe.Pointer)(buffer), C.OCI_DTYPE_TIMESTAMP)
case C.SQLT_TIMESTAMP_TZ:
C.OCIDescriptorFree... | go | func freeBuffer(buffer unsafe.Pointer, dataType C.ub2) {
switch dataType {
case C.SQLT_CLOB, C.SQLT_BLOB:
C.OCIDescriptorFree(*(*unsafe.Pointer)(buffer), C.OCI_DTYPE_LOB)
case C.SQLT_TIMESTAMP:
C.OCIDescriptorFree(*(*unsafe.Pointer)(buffer), C.OCI_DTYPE_TIMESTAMP)
case C.SQLT_TIMESTAMP_TZ:
C.OCIDescriptorFree... | [
"func",
"freeBuffer",
"(",
"buffer",
"unsafe",
".",
"Pointer",
",",
"dataType",
"C",
".",
"ub2",
")",
"{",
"switch",
"dataType",
"{",
"case",
"C",
".",
"SQLT_CLOB",
",",
"C",
".",
"SQLT_BLOB",
":",
"C",
".",
"OCIDescriptorFree",
"(",
"*",
"(",
"*",
"... | // freeBuffer calles OCIDescriptorFree to free double pointer to buffer
// or calles C free to free pointer to buffer | [
"freeBuffer",
"calles",
"OCIDescriptorFree",
"to",
"free",
"double",
"pointer",
"to",
"buffer",
"or",
"calles",
"C",
"free",
"to",
"free",
"pointer",
"to",
"buffer"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L113-L130 |
28,485 | mattn/go-oci8 | rows.go | Close | func (rows *OCI8Rows) Close() error {
if rows.closed {
return nil
}
rows.closed = true
close(rows.done)
if rows.cls {
rows.stmt.Close()
}
freeDefines(rows.defines)
return nil
} | go | func (rows *OCI8Rows) Close() error {
if rows.closed {
return nil
}
rows.closed = true
close(rows.done)
if rows.cls {
rows.stmt.Close()
}
freeDefines(rows.defines)
return nil
} | [
"func",
"(",
"rows",
"*",
"OCI8Rows",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"rows",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"rows",
".",
"closed",
"=",
"true",
"\n",
"close",
"(",
"rows",
".",
"done",
")",
"\n\n",
"if",
"row... | // Close closes rows | [
"Close",
"closes",
"rows"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/rows.go#L18-L33 |
28,486 | mattn/go-oci8 | rows.go | Columns | func (rows *OCI8Rows) Columns() []string {
names := make([]string, len(rows.defines))
for i, define := range rows.defines {
names[i] = define.name
}
return names
} | go | func (rows *OCI8Rows) Columns() []string {
names := make([]string, len(rows.defines))
for i, define := range rows.defines {
names[i] = define.name
}
return names
} | [
"func",
"(",
"rows",
"*",
"OCI8Rows",
")",
"Columns",
"(",
")",
"[",
"]",
"string",
"{",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"rows",
".",
"defines",
")",
")",
"\n",
"for",
"i",
",",
"define",
":=",
"range",
"rows",
... | // Columns returns column names | [
"Columns",
"returns",
"column",
"names"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/rows.go#L36-L42 |
28,487 | mattn/go-oci8 | rows.go | ColumnTypeLength | func (rows *OCI8Rows) ColumnTypeLength(i int) (length int64, ok bool) {
param, err := rows.stmt.ociParamGet(C.ub4(i + 1))
if err != nil {
return 0, false
}
defer C.OCIDescriptorFree(unsafe.Pointer(param), C.OCI_DTYPE_PARAM)
var dataSize C.ub4 // Maximum size in bytes of the external data for the column. This ca... | go | func (rows *OCI8Rows) ColumnTypeLength(i int) (length int64, ok bool) {
param, err := rows.stmt.ociParamGet(C.ub4(i + 1))
if err != nil {
return 0, false
}
defer C.OCIDescriptorFree(unsafe.Pointer(param), C.OCI_DTYPE_PARAM)
var dataSize C.ub4 // Maximum size in bytes of the external data for the column. This ca... | [
"func",
"(",
"rows",
"*",
"OCI8Rows",
")",
"ColumnTypeLength",
"(",
"i",
"int",
")",
"(",
"length",
"int64",
",",
"ok",
"bool",
")",
"{",
"param",
",",
"err",
":=",
"rows",
".",
"stmt",
".",
"ociParamGet",
"(",
"C",
".",
"ub4",
"(",
"i",
"+",
"1"... | // ColumnTypeLength returns column length | [
"ColumnTypeLength",
"returns",
"column",
"length"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/rows.go#L350-L364 |
28,488 | mattn/go-oci8 | dsn.go | ParseQuery | func ParseQuery(query string) (m Values, err error) {
m = make(Values)
err = parseQuery(m, query)
return
} | go | func ParseQuery(query string) (m Values, err error) {
m = make(Values)
err = parseQuery(m, query)
return
} | [
"func",
"ParseQuery",
"(",
"query",
"string",
")",
"(",
"m",
"Values",
",",
"err",
"error",
")",
"{",
"m",
"=",
"make",
"(",
"Values",
")",
"\n",
"err",
"=",
"parseQuery",
"(",
"m",
",",
"query",
")",
"\n",
"return",
"\n",
"}"
] | // ParseQuery parses the URL-encoded query string and returns
// a map listing the values specified for each key.
// ParseQuery always returns a non-nil map containing all the
// valid query parameters found; err describes the first decoding error
// encountered, if any. | [
"ParseQuery",
"parses",
"the",
"URL",
"-",
"encoded",
"query",
"string",
"and",
"returns",
"a",
"map",
"listing",
"the",
"values",
"specified",
"for",
"each",
"key",
".",
"ParseQuery",
"always",
"returns",
"a",
"non",
"-",
"nil",
"map",
"containing",
"all",
... | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/dsn.go#L296-L300 |
28,489 | gin-contrib/sessions | redis/redis.go | SetKeyPrefix | func SetKeyPrefix(s Store, prefix string) error {
err, rediStore := GetRedisStore(s)
if err != nil {
return err
}
rediStore.SetKeyPrefix(prefix)
return nil
} | go | func SetKeyPrefix(s Store, prefix string) error {
err, rediStore := GetRedisStore(s)
if err != nil {
return err
}
rediStore.SetKeyPrefix(prefix)
return nil
} | [
"func",
"SetKeyPrefix",
"(",
"s",
"Store",
",",
"prefix",
"string",
")",
"error",
"{",
"err",
",",
"rediStore",
":=",
"GetRedisStore",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"rediStore",
".",
"SetKeyPref... | // SetKeyPrefix sets the key prefix in the redis database. | [
"SetKeyPrefix",
"sets",
"the",
"key",
"prefix",
"in",
"the",
"redis",
"database",
"."
] | 1532893d996f0fedbac1162ea1311ebfb57a3da5 | https://github.com/gin-contrib/sessions/blob/1532893d996f0fedbac1162ea1311ebfb57a3da5/redis/redis.go#L78-L86 |
28,490 | bamzi/jobrunner | runjob.go | Every | func Every(duration time.Duration, job cron.Job) {
MainCron.Schedule(cron.Every(duration), New(job))
} | go | func Every(duration time.Duration, job cron.Job) {
MainCron.Schedule(cron.Every(duration), New(job))
} | [
"func",
"Every",
"(",
"duration",
"time",
".",
"Duration",
",",
"job",
"cron",
".",
"Job",
")",
"{",
"MainCron",
".",
"Schedule",
"(",
"cron",
".",
"Every",
"(",
"duration",
")",
",",
"New",
"(",
"job",
")",
")",
"\n",
"}"
] | // Run the given job at a fixed interval.
// The interval provided is the time between the job ending and the job being run again.
// The time that the job takes to run is not included in the interval. | [
"Run",
"the",
"given",
"job",
"at",
"a",
"fixed",
"interval",
".",
"The",
"interval",
"provided",
"is",
"the",
"time",
"between",
"the",
"job",
"ending",
"and",
"the",
"job",
"being",
"run",
"again",
".",
"The",
"time",
"that",
"the",
"job",
"takes",
"... | 273175f8b6ebabab8a639a4e6260a5c50fbf016a | https://github.com/bamzi/jobrunner/blob/273175f8b6ebabab8a639a4e6260a5c50fbf016a/runjob.go#L40-L43 |
28,491 | bamzi/jobrunner | runjob.go | In | func In(duration time.Duration, job cron.Job) {
go func() {
time.Sleep(duration)
New(job).Run()
}()
} | go | func In(duration time.Duration, job cron.Job) {
go func() {
time.Sleep(duration)
New(job).Run()
}()
} | [
"func",
"In",
"(",
"duration",
"time",
".",
"Duration",
",",
"job",
"cron",
".",
"Job",
")",
"{",
"go",
"func",
"(",
")",
"{",
"time",
".",
"Sleep",
"(",
"duration",
")",
"\n",
"New",
"(",
"job",
")",
".",
"Run",
"(",
")",
"\n",
"}",
"(",
")"... | // Run the given job once, after the given delay. | [
"Run",
"the",
"given",
"job",
"once",
"after",
"the",
"given",
"delay",
"."
] | 273175f8b6ebabab8a639a4e6260a5c50fbf016a | https://github.com/bamzi/jobrunner/blob/273175f8b6ebabab8a639a4e6260a5c50fbf016a/runjob.go#L51-L56 |
28,492 | klauspost/reedsolomon | streaming.go | NewStream | func NewStream(dataShards, parityShards int, o ...Option) (StreamEncoder, error) {
enc, err := New(dataShards, parityShards, o...)
if err != nil {
return nil, err
}
rs := enc.(*reedSolomon)
r := rsStream{r: rs, bs: 4 << 20}
r.readShards = readShards
r.writeShards = writeShards
return &r, err
} | go | func NewStream(dataShards, parityShards int, o ...Option) (StreamEncoder, error) {
enc, err := New(dataShards, parityShards, o...)
if err != nil {
return nil, err
}
rs := enc.(*reedSolomon)
r := rsStream{r: rs, bs: 4 << 20}
r.readShards = readShards
r.writeShards = writeShards
return &r, err
} | [
"func",
"NewStream",
"(",
"dataShards",
",",
"parityShards",
"int",
",",
"o",
"...",
"Option",
")",
"(",
"StreamEncoder",
",",
"error",
")",
"{",
"enc",
",",
"err",
":=",
"New",
"(",
"dataShards",
",",
"parityShards",
",",
"o",
"...",
")",
"\n",
"if",
... | // NewStream creates a new encoder and initializes it to
// the number of data shards and parity shards that
// you want to use. You can reuse this encoder.
// Note that the maximum number of data shards is 256. | [
"NewStream",
"creates",
"a",
"new",
"encoder",
"and",
"initializes",
"it",
"to",
"the",
"number",
"of",
"data",
"shards",
"and",
"parity",
"shards",
"that",
"you",
"want",
"to",
"use",
".",
"You",
"can",
"reuse",
"this",
"encoder",
".",
"Note",
"that",
"... | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/streaming.go#L148-L158 |
28,493 | klauspost/reedsolomon | streaming.go | NewStreamC | func NewStreamC(dataShards, parityShards int, conReads, conWrites bool, o ...Option) (StreamEncoder, error) {
enc, err := New(dataShards, parityShards, o...)
if err != nil {
return nil, err
}
rs := enc.(*reedSolomon)
r := rsStream{r: rs, bs: 4 << 20}
r.readShards = readShards
r.writeShards = writeShards
if co... | go | func NewStreamC(dataShards, parityShards int, conReads, conWrites bool, o ...Option) (StreamEncoder, error) {
enc, err := New(dataShards, parityShards, o...)
if err != nil {
return nil, err
}
rs := enc.(*reedSolomon)
r := rsStream{r: rs, bs: 4 << 20}
r.readShards = readShards
r.writeShards = writeShards
if co... | [
"func",
"NewStreamC",
"(",
"dataShards",
",",
"parityShards",
"int",
",",
"conReads",
",",
"conWrites",
"bool",
",",
"o",
"...",
"Option",
")",
"(",
"StreamEncoder",
",",
"error",
")",
"{",
"enc",
",",
"err",
":=",
"New",
"(",
"dataShards",
",",
"parityS... | // NewStreamC creates a new encoder and initializes it to
// the number of data shards and parity shards given.
//
// This functions as 'NewStream', but allows you to enable CONCURRENT reads and writes. | [
"NewStreamC",
"creates",
"a",
"new",
"encoder",
"and",
"initializes",
"it",
"to",
"the",
"number",
"of",
"data",
"shards",
"and",
"parity",
"shards",
"given",
".",
"This",
"functions",
"as",
"NewStream",
"but",
"allows",
"you",
"to",
"enable",
"CONCURRENT",
... | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/streaming.go#L164-L180 |
28,494 | klauspost/reedsolomon | streaming.go | trimShards | func trimShards(in [][]byte, size int) [][]byte {
for i := range in {
if in[i] != nil {
in[i] = in[i][0:size]
}
if len(in[i]) < size {
in[i] = nil
}
}
return in
} | go | func trimShards(in [][]byte, size int) [][]byte {
for i := range in {
if in[i] != nil {
in[i] = in[i][0:size]
}
if len(in[i]) < size {
in[i] = nil
}
}
return in
} | [
"func",
"trimShards",
"(",
"in",
"[",
"]",
"[",
"]",
"byte",
",",
"size",
"int",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"for",
"i",
":=",
"range",
"in",
"{",
"if",
"in",
"[",
"i",
"]",
"!=",
"nil",
"{",
"in",
"[",
"i",
"]",
"=",
"in",
"[",... | // Trim the shards so they are all the same size | [
"Trim",
"the",
"shards",
"so",
"they",
"are",
"all",
"the",
"same",
"size"
] | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/streaming.go#L245-L255 |
28,495 | klauspost/reedsolomon | streaming.go | cReadShards | func cReadShards(dst [][]byte, in []io.Reader) error {
if len(in) != len(dst) {
panic("internal error: in and dst size do not match")
}
var wg sync.WaitGroup
wg.Add(len(in))
res := make(chan readResult, len(in))
for i := range in {
if in[i] == nil {
dst[i] = nil
wg.Done()
continue
}
go func(i int... | go | func cReadShards(dst [][]byte, in []io.Reader) error {
if len(in) != len(dst) {
panic("internal error: in and dst size do not match")
}
var wg sync.WaitGroup
wg.Add(len(in))
res := make(chan readResult, len(in))
for i := range in {
if in[i] == nil {
dst[i] = nil
wg.Done()
continue
}
go func(i int... | [
"func",
"cReadShards",
"(",
"dst",
"[",
"]",
"[",
"]",
"byte",
",",
"in",
"[",
"]",
"io",
".",
"Reader",
")",
"error",
"{",
"if",
"len",
"(",
"in",
")",
"!=",
"len",
"(",
"dst",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"var... | // cReadShards reads shards concurrently | [
"cReadShards",
"reads",
"shards",
"concurrently"
] | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/streaming.go#L319-L364 |
28,496 | klauspost/reedsolomon | streaming.go | cWriteShards | func cWriteShards(out []io.Writer, in [][]byte) error {
if len(out) != len(in) {
panic("internal error: in and out size do not match")
}
var errs = make(chan error, len(out))
var wg sync.WaitGroup
wg.Add(len(out))
for i := range in {
go func(i int) {
defer wg.Done()
if out[i] == nil {
errs <- nil
... | go | func cWriteShards(out []io.Writer, in [][]byte) error {
if len(out) != len(in) {
panic("internal error: in and out size do not match")
}
var errs = make(chan error, len(out))
var wg sync.WaitGroup
wg.Add(len(out))
for i := range in {
go func(i int) {
defer wg.Done()
if out[i] == nil {
errs <- nil
... | [
"func",
"cWriteShards",
"(",
"out",
"[",
"]",
"io",
".",
"Writer",
",",
"in",
"[",
"]",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"out",
")",
"!=",
"len",
"(",
"in",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"va... | // cWriteShards writes shards concurrently | [
"cWriteShards",
"writes",
"shards",
"concurrently"
] | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/streaming.go#L367-L400 |
28,497 | klauspost/reedsolomon | streaming.go | Join | func (r rsStream) Join(dst io.Writer, shards []io.Reader, outSize int64) error {
// Do we have enough shards?
if len(shards) < r.r.DataShards {
return ErrTooFewShards
}
// Trim off parity shards if any
shards = shards[:r.r.DataShards]
for i := range shards {
if shards[i] == nil {
return StreamReadError{Er... | go | func (r rsStream) Join(dst io.Writer, shards []io.Reader, outSize int64) error {
// Do we have enough shards?
if len(shards) < r.r.DataShards {
return ErrTooFewShards
}
// Trim off parity shards if any
shards = shards[:r.r.DataShards]
for i := range shards {
if shards[i] == nil {
return StreamReadError{Er... | [
"func",
"(",
"r",
"rsStream",
")",
"Join",
"(",
"dst",
"io",
".",
"Writer",
",",
"shards",
"[",
"]",
"io",
".",
"Reader",
",",
"outSize",
"int64",
")",
"error",
"{",
"// Do we have enough shards?",
"if",
"len",
"(",
"shards",
")",
"<",
"r",
".",
"r",... | // Join the shards and write the data segment to dst.
//
// Only the data shards are considered.
//
// You must supply the exact output size you want.
// If there are to few shards given, ErrTooFewShards will be returned.
// If the total data size is less than outSize, ErrShortData will be returned. | [
"Join",
"the",
"shards",
"and",
"write",
"the",
"data",
"segment",
"to",
"dst",
".",
"Only",
"the",
"data",
"shards",
"are",
"considered",
".",
"You",
"must",
"supply",
"the",
"exact",
"output",
"size",
"you",
"want",
".",
"If",
"there",
"are",
"to",
"... | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/streaming.go#L512-L540 |
28,498 | klauspost/reedsolomon | streaming.go | Split | func (r rsStream) Split(data io.Reader, dst []io.Writer, size int64) error {
if size == 0 {
return ErrShortData
}
if len(dst) != r.r.DataShards {
return ErrInvShardNum
}
for i := range dst {
if dst[i] == nil {
return StreamWriteError{Err: ErrShardNoData, Stream: i}
}
}
// Calculate number of bytes p... | go | func (r rsStream) Split(data io.Reader, dst []io.Writer, size int64) error {
if size == 0 {
return ErrShortData
}
if len(dst) != r.r.DataShards {
return ErrInvShardNum
}
for i := range dst {
if dst[i] == nil {
return StreamWriteError{Err: ErrShardNoData, Stream: i}
}
}
// Calculate number of bytes p... | [
"func",
"(",
"r",
"rsStream",
")",
"Split",
"(",
"data",
"io",
".",
"Reader",
",",
"dst",
"[",
"]",
"io",
".",
"Writer",
",",
"size",
"int64",
")",
"error",
"{",
"if",
"size",
"==",
"0",
"{",
"return",
"ErrShortData",
"\n",
"}",
"\n",
"if",
"len"... | // Split a an input stream into the number of shards given to the encoder.
//
// The data will be split into equally sized shards.
// If the data size isn't dividable by the number of shards,
// the last shard will contain extra zeros.
//
// You must supply the total size of your input.
// 'ErrShortData' will be return... | [
"Split",
"a",
"an",
"input",
"stream",
"into",
"the",
"number",
"of",
"shards",
"given",
"to",
"the",
"encoder",
".",
"The",
"data",
"will",
"be",
"split",
"into",
"equally",
"sized",
"shards",
".",
"If",
"the",
"data",
"size",
"isn",
"t",
"dividable",
... | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/streaming.go#L551-L584 |
28,499 | klauspost/reedsolomon | options.go | WithMinSplitSize | func WithMinSplitSize(n int) Option {
return func(o *options) {
if n > 0 {
o.minSplitSize = n
}
}
} | go | func WithMinSplitSize(n int) Option {
return func(o *options) {
if n > 0 {
o.minSplitSize = n
}
}
} | [
"func",
"WithMinSplitSize",
"(",
"n",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"options",
")",
"{",
"if",
"n",
">",
"0",
"{",
"o",
".",
"minSplitSize",
"=",
"n",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // WithMinSplitSize is the minimum encoding size in bytes per goroutine.
// See WithMaxGoroutines on how jobs are split.
// If n <= 0, it is ignored. | [
"WithMinSplitSize",
"is",
"the",
"minimum",
"encoding",
"size",
"in",
"bytes",
"per",
"goroutine",
".",
"See",
"WithMaxGoroutines",
"on",
"how",
"jobs",
"are",
"split",
".",
"If",
"n",
"<",
"=",
"0",
"it",
"is",
"ignored",
"."
] | a373324398e4d088b67d6dd6157285b5d4e29642 | https://github.com/klauspost/reedsolomon/blob/a373324398e4d088b67d6dd6157285b5d4e29642/options.go#L66-L72 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.