id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
14,000
go-ozzo/ozzo-dbx
struct.go
pk
func (s *structValue) pk() map[string]interface{} { if len(s.pkNames) == 0 { return nil } return s.columns(s.pkNames, nil) }
go
func (s *structValue) pk() map[string]interface{} { if len(s.pkNames) == 0 { return nil } return s.columns(s.pkNames, nil) }
[ "func", "(", "s", "*", "structValue", ")", "pk", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "if", "len", "(", "s", ".", "pkNames", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", "s", ".", "columns", "(", ...
// pk returns the primary key values indexed by the corresponding primary key column names.
[ "pk", "returns", "the", "primary", "key", "values", "indexed", "by", "the", "corresponding", "primary", "key", "column", "names", "." ]
e984ee904f1b2df904d0b2e6b2ca5064c87c0409
https://github.com/go-ozzo/ozzo-dbx/blob/e984ee904f1b2df904d0b2e6b2ca5064c87c0409/struct.go#L94-L99
14,001
go-ozzo/ozzo-dbx
struct.go
columns
func (s *structValue) columns(include, exclude []string) map[string]interface{} { v := make(map[string]interface{}, len(s.nameMap)) if len(include) == 0 { for _, fi := range s.nameMap { v[fi.dbName] = fi.getValue(s.value) } } else { for _, attr := range include { if fi, ok := s.nameMap[attr]; ok { v[fi.dbName] = fi.getValue(s.value) } } } if len(exclude) > 0 { for _, name := range exclude { if fi, ok := s.nameMap[name]; ok { delete(v, fi.dbName) } } } return v }
go
func (s *structValue) columns(include, exclude []string) map[string]interface{} { v := make(map[string]interface{}, len(s.nameMap)) if len(include) == 0 { for _, fi := range s.nameMap { v[fi.dbName] = fi.getValue(s.value) } } else { for _, attr := range include { if fi, ok := s.nameMap[attr]; ok { v[fi.dbName] = fi.getValue(s.value) } } } if len(exclude) > 0 { for _, name := range exclude { if fi, ok := s.nameMap[name]; ok { delete(v, fi.dbName) } } } return v }
[ "func", "(", "s", "*", "structValue", ")", "columns", "(", "include", ",", "exclude", "[", "]", "string", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "v", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "...
// columns returns the struct field values indexed by their corresponding DB column names.
[ "columns", "returns", "the", "struct", "field", "values", "indexed", "by", "their", "corresponding", "DB", "column", "names", "." ]
e984ee904f1b2df904d0b2e6b2ca5064c87c0409
https://github.com/go-ozzo/ozzo-dbx/blob/e984ee904f1b2df904d0b2e6b2ca5064c87c0409/struct.go#L102-L123
14,002
go-ozzo/ozzo-dbx
struct.go
getValue
func (fi *fieldInfo) getValue(a reflect.Value) interface{} { for _, i := range fi.path { a = a.Field(i) if a.Kind() == reflect.Ptr { if a.IsNil() { return nil } a = a.Elem() } } return a.Interface() }
go
func (fi *fieldInfo) getValue(a reflect.Value) interface{} { for _, i := range fi.path { a = a.Field(i) if a.Kind() == reflect.Ptr { if a.IsNil() { return nil } a = a.Elem() } } return a.Interface() }
[ "func", "(", "fi", "*", "fieldInfo", ")", "getValue", "(", "a", "reflect", ".", "Value", ")", "interface", "{", "}", "{", "for", "_", ",", "i", ":=", "range", "fi", ".", "path", "{", "a", "=", "a", ".", "Field", "(", "i", ")", "\n", "if", "a"...
// getValue returns the field value for the given struct value.
[ "getValue", "returns", "the", "field", "value", "for", "the", "given", "struct", "value", "." ]
e984ee904f1b2df904d0b2e6b2ca5064c87c0409
https://github.com/go-ozzo/ozzo-dbx/blob/e984ee904f1b2df904d0b2e6b2ca5064c87c0409/struct.go#L126-L137
14,003
go-ozzo/ozzo-dbx
struct.go
getField
func (fi *fieldInfo) getField(a reflect.Value) reflect.Value { i := 0 for ; i < len(fi.path)-1; i++ { a = indirect(a.Field(fi.path[i])) } return a.Field(fi.path[i]) }
go
func (fi *fieldInfo) getField(a reflect.Value) reflect.Value { i := 0 for ; i < len(fi.path)-1; i++ { a = indirect(a.Field(fi.path[i])) } return a.Field(fi.path[i]) }
[ "func", "(", "fi", "*", "fieldInfo", ")", "getField", "(", "a", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "i", ":=", "0", "\n", "for", ";", "i", "<", "len", "(", "fi", ".", "path", ")", "-", "1", ";", "i", "++", "{", "a", ...
// getField returns the reflection value of the field for the given struct value.
[ "getField", "returns", "the", "reflection", "value", "of", "the", "field", "for", "the", "given", "struct", "value", "." ]
e984ee904f1b2df904d0b2e6b2ca5064c87c0409
https://github.com/go-ozzo/ozzo-dbx/blob/e984ee904f1b2df904d0b2e6b2ca5064c87c0409/struct.go#L140-L146
14,004
go-ozzo/ozzo-dbx
struct.go
indirect
func indirect(v reflect.Value) reflect.Value { for v.Kind() == reflect.Ptr { if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } v = v.Elem() } return v }
go
func indirect(v reflect.Value) reflect.Value { for v.Kind() == reflect.Ptr { if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } v = v.Elem() } return v }
[ "func", "indirect", "(", "v", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "for", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "if", "v", ".", "IsNil", "(", ")", "{", "v", ".", "Set", "(", "reflect", ".", "New", ...
// indirect dereferences pointers and returns the actual value it points to. // If a pointer is nil, it will be initialized with a new value.
[ "indirect", "dereferences", "pointers", "and", "returns", "the", "actual", "value", "it", "points", "to", ".", "If", "a", "pointer", "is", "nil", "it", "will", "be", "initialized", "with", "a", "new", "value", "." ]
e984ee904f1b2df904d0b2e6b2ca5064c87c0409
https://github.com/go-ozzo/ozzo-dbx/blob/e984ee904f1b2df904d0b2e6b2ca5064c87c0409/struct.go#L239-L247
14,005
go-ozzo/ozzo-dbx
expression.go
NewExp
func NewExp(e string, params ...Params) Expression { if len(params) > 0 { return &Exp{e, params[0]} } return &Exp{e, nil} }
go
func NewExp(e string, params ...Params) Expression { if len(params) > 0 { return &Exp{e, params[0]} } return &Exp{e, nil} }
[ "func", "NewExp", "(", "e", "string", ",", "params", "...", "Params", ")", "Expression", "{", "if", "len", "(", "params", ")", ">", "0", "{", "return", "&", "Exp", "{", "e", ",", "params", "[", "0", "]", "}", "\n", "}", "\n", "return", "&", "Ex...
// NewExp generates an expression with the specified SQL fragment and the optional binding parameters.
[ "NewExp", "generates", "an", "expression", "with", "the", "specified", "SQL", "fragment", "and", "the", "optional", "binding", "parameters", "." ]
e984ee904f1b2df904d0b2e6b2ca5064c87c0409
https://github.com/go-ozzo/ozzo-dbx/blob/e984ee904f1b2df904d0b2e6b2ca5064c87c0409/expression.go#L31-L36
14,006
go-ozzo/ozzo-dbx
expression.go
Escape
func (e *LikeExp) Escape(chars ...string) *LikeExp { e.escape = chars return e }
go
func (e *LikeExp) Escape(chars ...string) *LikeExp { e.escape = chars return e }
[ "func", "(", "e", "*", "LikeExp", ")", "Escape", "(", "chars", "...", "string", ")", "*", "LikeExp", "{", "e", ".", "escape", "=", "chars", "\n", "return", "e", "\n", "}" ]
// Escape specifies how a LIKE expression should be escaped. // Each string at position 2i represents a special character and the string at position 2i+1 is // the corresponding escaped version.
[ "Escape", "specifies", "how", "a", "LIKE", "expression", "should", "be", "escaped", ".", "Each", "string", "at", "position", "2i", "represents", "a", "special", "character", "and", "the", "string", "at", "position", "2i", "+", "1", "is", "the", "correspondin...
e984ee904f1b2df904d0b2e6b2ca5064c87c0409
https://github.com/go-ozzo/ozzo-dbx/blob/e984ee904f1b2df904d0b2e6b2ca5064c87c0409/expression.go#L316-L319
14,007
compose/transporter
message/ops/ops.go
String
func (o Op) String() string { switch o { case Insert: return "insert" case Update: return "update" case Delete: return "delete" case Command: return "command" case Noop: return "noop" case Skip: return "skip" default: return "unknown" } }
go
func (o Op) String() string { switch o { case Insert: return "insert" case Update: return "update" case Delete: return "delete" case Command: return "command" case Noop: return "noop" case Skip: return "skip" default: return "unknown" } }
[ "func", "(", "o", "Op", ")", "String", "(", ")", "string", "{", "switch", "o", "{", "case", "Insert", ":", "return", "\"", "\"", "\n", "case", "Update", ":", "return", "\"", "\"", "\n", "case", "Delete", ":", "return", "\"", "\"", "\n", "case", "...
// String returns the constant of the // string representation of the OpType object.
[ "String", "returns", "the", "constant", "of", "the", "string", "representation", "of", "the", "OpType", "object", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/message/ops/ops.go#L24-L41
14,008
compose/transporter
message/ops/ops.go
OpTypeFromString
func OpTypeFromString(s string) Op { switch s[0] { case 'i': return Insert case 'u': return Update case 'd': return Delete case 'c': return Command case 'n': return Noop case 's': return Skip default: return Unknown } }
go
func OpTypeFromString(s string) Op { switch s[0] { case 'i': return Insert case 'u': return Update case 'd': return Delete case 'c': return Command case 'n': return Noop case 's': return Skip default: return Unknown } }
[ "func", "OpTypeFromString", "(", "s", "string", ")", "Op", "{", "switch", "s", "[", "0", "]", "{", "case", "'i'", ":", "return", "Insert", "\n", "case", "'u'", ":", "return", "Update", "\n", "case", "'d'", ":", "return", "Delete", "\n", "case", "'c'"...
// OpTypeFromString returns the constant // representing the passed in string
[ "OpTypeFromString", "returns", "the", "constant", "representing", "the", "passed", "in", "string" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/message/ops/ops.go#L45-L62
14,009
compose/transporter
function/registry.go
GetFunction
func GetFunction(name string, conf map[string]interface{}) (Function, error) { creator, ok := functions[name] if ok { a := creator() b, err := json.Marshal(conf) if err != nil { return nil, err } err = json.Unmarshal(b, a) if err != nil { return nil, err } return a, nil } return nil, ErrNotFound{name} }
go
func GetFunction(name string, conf map[string]interface{}) (Function, error) { creator, ok := functions[name] if ok { a := creator() b, err := json.Marshal(conf) if err != nil { return nil, err } err = json.Unmarshal(b, a) if err != nil { return nil, err } return a, nil } return nil, ErrNotFound{name} }
[ "func", "GetFunction", "(", "name", "string", ",", "conf", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "Function", ",", "error", ")", "{", "creator", ",", "ok", ":=", "functions", "[", "name", "]", "\n", "if", "ok", "{", "a", ":=", ...
// GetFunction looks up a function by name and then init's it with the provided map. // returns ErrNotFound if the provided name was not registered.
[ "GetFunction", "looks", "up", "a", "function", "by", "name", "and", "then", "init", "s", "it", "with", "the", "provided", "map", ".", "returns", "ErrNotFound", "if", "the", "provided", "name", "was", "not", "registered", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/function/registry.go#L29-L44
14,010
compose/transporter
function/registry.go
RegisteredFunctions
func RegisteredFunctions() []string { all := make([]string, 0) for i := range functions { all = append(all, i) } return all }
go
func RegisteredFunctions() []string { all := make([]string, 0) for i := range functions { all = append(all, i) } return all }
[ "func", "RegisteredFunctions", "(", ")", "[", "]", "string", "{", "all", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "for", "i", ":=", "range", "functions", "{", "all", "=", "append", "(", "all", ",", "i", ")", "\n", "}", "\n", ...
// RegisteredFunctions returns a slice of the names of every function registered.
[ "RegisteredFunctions", "returns", "a", "slice", "of", "the", "names", "of", "every", "function", "registered", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/function/registry.go#L47-L53
14,011
compose/transporter
adaptor/postgres/tailer.go
Read
func (t *Tailer) Read(resumeMap map[string]client.MessageSet, filterFn client.NsFilterFunc) client.MessageChanFunc { return func(s client.Session, done chan struct{}) (chan client.MessageSet, error) { readFunc := t.reader.Read(resumeMap, filterFn) msgChan, err := readFunc(s, done) if err != nil { return nil, err } session := s.(*Session) out := make(chan client.MessageSet) go func() { defer close(out) // read until reader done for msg := range msgChan { out <- msg } // start tailing log.With("db", session.db).With("logical_decoding_slot", t.replicationSlot).Infoln("Listening for changes...") for { select { case <-done: log.With("db", session.db).Infoln("tailing stopping...") return case <-time.After(time.Second): msgSlice, err := t.pluckFromLogicalDecoding(s.(*Session), filterFn) if err != nil { log.With("db", session.db).Errorf("error plucking from logical decoding %v", err) continue } for _, msg := range msgSlice { out <- msg } } } }() return out, nil } }
go
func (t *Tailer) Read(resumeMap map[string]client.MessageSet, filterFn client.NsFilterFunc) client.MessageChanFunc { return func(s client.Session, done chan struct{}) (chan client.MessageSet, error) { readFunc := t.reader.Read(resumeMap, filterFn) msgChan, err := readFunc(s, done) if err != nil { return nil, err } session := s.(*Session) out := make(chan client.MessageSet) go func() { defer close(out) // read until reader done for msg := range msgChan { out <- msg } // start tailing log.With("db", session.db).With("logical_decoding_slot", t.replicationSlot).Infoln("Listening for changes...") for { select { case <-done: log.With("db", session.db).Infoln("tailing stopping...") return case <-time.After(time.Second): msgSlice, err := t.pluckFromLogicalDecoding(s.(*Session), filterFn) if err != nil { log.With("db", session.db).Errorf("error plucking from logical decoding %v", err) continue } for _, msg := range msgSlice { out <- msg } } } }() return out, nil } }
[ "func", "(", "t", "*", "Tailer", ")", "Read", "(", "resumeMap", "map", "[", "string", "]", "client", ".", "MessageSet", ",", "filterFn", "client", ".", "NsFilterFunc", ")", "client", ".", "MessageChanFunc", "{", "return", "func", "(", "s", "client", ".",...
// Tail does the things
[ "Tail", "does", "the", "things" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/postgres/tailer.go#L35-L72
14,012
compose/transporter
adaptor/postgres/tailer.go
pluckFromLogicalDecoding
func (t *Tailer) pluckFromLogicalDecoding(s *Session, filterFn client.NsFilterFunc) ([]client.MessageSet, error) { var result []client.MessageSet dataMatcher := regexp.MustCompile("(?s)^table ([^\\.]+)\\.([^:]+): (INSERT|DELETE|UPDATE): (.+)$") // 1 - schema, 2 - table, 3 - action, 4 - remaining changesResult, err := s.pqSession.Query(fmt.Sprintf("SELECT * FROM pg_logical_slot_get_changes('%v', NULL, NULL);", t.replicationSlot)) if err != nil { return result, err } for changesResult.Next() { var ( location string xid string d string ) err = changesResult.Scan(&location, &xid, &d) if err != nil { return result, err } // Ensure we are getting a data change row dataMatches := dataMatcher.FindStringSubmatch(d) if len(dataMatches) == 0 { continue } // Skippable because no primary key on record // Make sure we are getting changes on valid tables schemaAndTable := fmt.Sprintf("%v.%v", dataMatches[1], dataMatches[2]) if !filterFn(schemaAndTable) { continue } if dataMatches[4] == "(no-tuple-data)" { log.With("op", dataMatches[3]).With("schema", schemaAndTable).Infoln("no tuple data") continue } // normalize the action var action ops.Op switch dataMatches[3] { case "INSERT": action = ops.Insert case "DELETE": action = ops.Delete case "UPDATE": action = ops.Update default: return result, fmt.Errorf("Error processing action from string: %v", d) } log.With("op", action).With("table", schemaAndTable).Debugln("received") docMap := parseLogicalDecodingData(dataMatches[4]) result = append(result, client.MessageSet{ Msg: message.From(action, schemaAndTable, docMap), Mode: commitlog.Sync, }) } return result, err }
go
func (t *Tailer) pluckFromLogicalDecoding(s *Session, filterFn client.NsFilterFunc) ([]client.MessageSet, error) { var result []client.MessageSet dataMatcher := regexp.MustCompile("(?s)^table ([^\\.]+)\\.([^:]+): (INSERT|DELETE|UPDATE): (.+)$") // 1 - schema, 2 - table, 3 - action, 4 - remaining changesResult, err := s.pqSession.Query(fmt.Sprintf("SELECT * FROM pg_logical_slot_get_changes('%v', NULL, NULL);", t.replicationSlot)) if err != nil { return result, err } for changesResult.Next() { var ( location string xid string d string ) err = changesResult.Scan(&location, &xid, &d) if err != nil { return result, err } // Ensure we are getting a data change row dataMatches := dataMatcher.FindStringSubmatch(d) if len(dataMatches) == 0 { continue } // Skippable because no primary key on record // Make sure we are getting changes on valid tables schemaAndTable := fmt.Sprintf("%v.%v", dataMatches[1], dataMatches[2]) if !filterFn(schemaAndTable) { continue } if dataMatches[4] == "(no-tuple-data)" { log.With("op", dataMatches[3]).With("schema", schemaAndTable).Infoln("no tuple data") continue } // normalize the action var action ops.Op switch dataMatches[3] { case "INSERT": action = ops.Insert case "DELETE": action = ops.Delete case "UPDATE": action = ops.Update default: return result, fmt.Errorf("Error processing action from string: %v", d) } log.With("op", action).With("table", schemaAndTable).Debugln("received") docMap := parseLogicalDecodingData(dataMatches[4]) result = append(result, client.MessageSet{ Msg: message.From(action, schemaAndTable, docMap), Mode: commitlog.Sync, }) } return result, err }
[ "func", "(", "t", "*", "Tailer", ")", "pluckFromLogicalDecoding", "(", "s", "*", "Session", ",", "filterFn", "client", ".", "NsFilterFunc", ")", "(", "[", "]", "client", ".", "MessageSet", ",", "error", ")", "{", "var", "result", "[", "]", "client", "....
// Use Postgres logical decoding to retrieve the latest changes
[ "Use", "Postgres", "logical", "decoding", "to", "retrieve", "the", "latest", "changes" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/postgres/tailer.go#L75-L137
14,013
compose/transporter
pipeline/pipeline.go
Stop
func (pipeline *Pipeline) Stop() { endpoints := pipeline.source.Endpoints() pipeline.source.Stop() // pipeline has stopped, emit one last round of metrics and send the exit event close(pipeline.done) pipeline.emitMetrics() pipeline.source.pipe.Event <- events.NewExitEvent(time.Now().UnixNano(), pipeline.version, endpoints) pipeline.emitter.Stop() }
go
func (pipeline *Pipeline) Stop() { endpoints := pipeline.source.Endpoints() pipeline.source.Stop() // pipeline has stopped, emit one last round of metrics and send the exit event close(pipeline.done) pipeline.emitMetrics() pipeline.source.pipe.Event <- events.NewExitEvent(time.Now().UnixNano(), pipeline.version, endpoints) pipeline.emitter.Stop() }
[ "func", "(", "pipeline", "*", "Pipeline", ")", "Stop", "(", ")", "{", "endpoints", ":=", "pipeline", ".", "source", ".", "Endpoints", "(", ")", "\n", "pipeline", ".", "source", ".", "Stop", "(", ")", "\n\n", "// pipeline has stopped, emit one last round of met...
// Stop sends a stop signal to the emitter and all the nodes, whether they are running or not. // the node's database adaptors are expected to clean up after themselves, and stop will block until // all nodes have stopped successfully
[ "Stop", "sends", "a", "stop", "signal", "to", "the", "emitter", "and", "all", "the", "nodes", "whether", "they", "are", "running", "or", "not", ".", "the", "node", "s", "database", "adaptors", "are", "expected", "to", "clean", "up", "after", "themselves", ...
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/pipeline.go#L105-L114
14,014
compose/transporter
pipeline/pipeline.go
Run
func (pipeline *Pipeline) Run() error { endpoints := pipeline.source.Endpoints() // send a boot event pipeline.source.pipe.Event <- events.NewBootEvent(time.Now().UnixNano(), pipeline.version, endpoints) errors := make(chan error, 2) go func() { errors <- pipeline.startErrorListener() }() go func() { errors <- pipeline.source.Start() }() return <-errors }
go
func (pipeline *Pipeline) Run() error { endpoints := pipeline.source.Endpoints() // send a boot event pipeline.source.pipe.Event <- events.NewBootEvent(time.Now().UnixNano(), pipeline.version, endpoints) errors := make(chan error, 2) go func() { errors <- pipeline.startErrorListener() }() go func() { errors <- pipeline.source.Start() }() return <-errors }
[ "func", "(", "pipeline", "*", "Pipeline", ")", "Run", "(", ")", "error", "{", "endpoints", ":=", "pipeline", ".", "source", ".", "Endpoints", "(", ")", "\n", "// send a boot event", "pipeline", ".", "source", ".", "pipe", ".", "Event", "<-", "events", "....
// Run the pipeline
[ "Run", "the", "pipeline" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/pipeline.go#L117-L131
14,015
compose/transporter
pipeline/pipeline.go
startErrorListener
func (pipeline *Pipeline) startErrorListener() error { for { select { case err := <-pipeline.source.pipe.Err: return err case <-pipeline.done: return nil } } }
go
func (pipeline *Pipeline) startErrorListener() error { for { select { case err := <-pipeline.source.pipe.Err: return err case <-pipeline.done: return nil } } }
[ "func", "(", "pipeline", "*", "Pipeline", ")", "startErrorListener", "(", ")", "error", "{", "for", "{", "select", "{", "case", "err", ":=", "<-", "pipeline", ".", "source", ".", "pipe", ".", "Err", ":", "return", "err", "\n", "case", "<-", "pipeline",...
// start error listener consumes all the events on the pipe's Err channel, and stops the pipeline // when it receives one
[ "start", "error", "listener", "consumes", "all", "the", "events", "on", "the", "pipe", "s", "Err", "channel", "and", "stops", "the", "pipeline", "when", "it", "receives", "one" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/pipeline.go#L135-L144
14,016
compose/transporter
pipeline/pipeline.go
emitMetrics
func (pipeline *Pipeline) emitMetrics() { pipeline.apply(func(node *Node) { pipeline.source.pipe.Event <- events.NewMetricsEvent(time.Now().UnixNano(), node.path, node.pipe.MessageCount) }) }
go
func (pipeline *Pipeline) emitMetrics() { pipeline.apply(func(node *Node) { pipeline.source.pipe.Event <- events.NewMetricsEvent(time.Now().UnixNano(), node.path, node.pipe.MessageCount) }) }
[ "func", "(", "pipeline", "*", "Pipeline", ")", "emitMetrics", "(", ")", "{", "pipeline", ".", "apply", "(", "func", "(", "node", "*", "Node", ")", "{", "pipeline", ".", "source", ".", "pipe", ".", "Event", "<-", "events", ".", "NewMetricsEvent", "(", ...
// emit the metrics
[ "emit", "the", "metrics" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/pipeline.go#L158-L162
14,017
compose/transporter
pipeline/pipeline.go
apply
func (pipeline *Pipeline) apply(f func(*Node)) { head := pipeline.source nodes := []*Node{head} for len(nodes) > 0 { head, nodes = nodes[0], nodes[1:] f(head) nodes = append(nodes, head.children...) } }
go
func (pipeline *Pipeline) apply(f func(*Node)) { head := pipeline.source nodes := []*Node{head} for len(nodes) > 0 { head, nodes = nodes[0], nodes[1:] f(head) nodes = append(nodes, head.children...) } }
[ "func", "(", "pipeline", "*", "Pipeline", ")", "apply", "(", "f", "func", "(", "*", "Node", ")", ")", "{", "head", ":=", "pipeline", ".", "source", "\n", "nodes", ":=", "[", "]", "*", "Node", "{", "head", "}", "\n", "for", "len", "(", "nodes", ...
// apply maps a function f across all nodes of a pipeline
[ "apply", "maps", "a", "function", "f", "across", "all", "nodes", "of", "a", "pipeline" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/pipeline.go#L165-L173
14,018
compose/transporter
adaptor/file/file.go
Writer
func (f *File) Writer(done chan struct{}, wg *sync.WaitGroup) (client.Writer, error) { return newWriter(), nil }
go
func (f *File) Writer(done chan struct{}, wg *sync.WaitGroup) (client.Writer, error) { return newWriter(), nil }
[ "func", "(", "f", "*", "File", ")", "Writer", "(", "done", "chan", "struct", "{", "}", ",", "wg", "*", "sync", ".", "WaitGroup", ")", "(", "client", ".", "Writer", ",", "error", ")", "{", "return", "newWriter", "(", ")", ",", "nil", "\n", "}" ]
// Writer instantiates a Writer for use with working with the file.
[ "Writer", "instantiates", "a", "Writer", "for", "use", "with", "working", "with", "the", "file", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/file/file.go#L44-L46
14,019
compose/transporter
adaptor/adaptor.go
Construct
func (c *Config) Construct(conf interface{}) error { b, err := json.Marshal(c) if err != nil { return err } err = json.Unmarshal(b, conf) if err != nil { return err } return nil }
go
func (c *Config) Construct(conf interface{}) error { b, err := json.Marshal(c) if err != nil { return err } err = json.Unmarshal(b, conf) if err != nil { return err } return nil }
[ "func", "(", "c", "*", "Config", ")", "Construct", "(", "conf", "interface", "{", "}", ")", "error", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "er...
// Construct will Marshal the Config and then Unmarshal it into a // named struct the generic map into a proper struct
[ "Construct", "will", "Marshal", "the", "Config", "and", "then", "Unmarshal", "it", "into", "a", "named", "struct", "the", "generic", "map", "into", "a", "proper", "struct" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/adaptor.go#L64-L75
14,020
compose/transporter
adaptor/adaptor.go
GetString
func (c Config) GetString(key string) string { i, ok := c[key] if !ok { return "" } s, ok := i.(string) if !ok { return "" } return s }
go
func (c Config) GetString(key string) string { i, ok := c[key] if !ok { return "" } s, ok := i.(string) if !ok { return "" } return s }
[ "func", "(", "c", "Config", ")", "GetString", "(", "key", "string", ")", "string", "{", "i", ",", "ok", ":=", "c", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "s", ",", "ok", ":=", "i", ".", "(", "str...
// GetString returns value stored in the config under the given key, or // an empty string if the key doesn't exist, or isn't a string value
[ "GetString", "returns", "value", "stored", "in", "the", "config", "under", "the", "given", "key", "or", "an", "empty", "string", "if", "the", "key", "doesn", "t", "exist", "or", "isn", "t", "a", "string", "value" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/adaptor.go#L79-L89
14,021
compose/transporter
adaptor/elasticsearch/clients/registry.go
Add
func Add(v string, constraint version.Constraints, creator Creator) { Clients[v] = &VersionedClient{constraint, creator} }
go
func Add(v string, constraint version.Constraints, creator Creator) { Clients[v] = &VersionedClient{constraint, creator} }
[ "func", "Add", "(", "v", "string", ",", "constraint", "version", ".", "Constraints", ",", "creator", "Creator", ")", "{", "Clients", "[", "v", "]", "=", "&", "VersionedClient", "{", "constraint", ",", "creator", "}", "\n", "}" ]
// Add exposes the ability for each versioned client to register itself for use
[ "Add", "exposes", "the", "ability", "for", "each", "versioned", "client", "to", "register", "itself", "for", "use" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/elasticsearch/clients/registry.go#L25-L27
14,022
compose/transporter
offset/logmanager.go
NewLogManager
func NewLogManager(path, name string) (*LogManager, error) { m := &LogManager{ name: name, nsMap: make(map[string]uint64), } l, err := commitlog.New( commitlog.WithPath(filepath.Join(path, fmt.Sprintf("%s-%s", offsetPrefixDir, name))), commitlog.WithMaxSegmentBytes(1024*1024*1024), ) if err != nil { return nil, err } m.log = l err = m.buildMap() if err == io.EOF { return m, nil } return m, err }
go
func NewLogManager(path, name string) (*LogManager, error) { m := &LogManager{ name: name, nsMap: make(map[string]uint64), } l, err := commitlog.New( commitlog.WithPath(filepath.Join(path, fmt.Sprintf("%s-%s", offsetPrefixDir, name))), commitlog.WithMaxSegmentBytes(1024*1024*1024), ) if err != nil { return nil, err } m.log = l err = m.buildMap() if err == io.EOF { return m, nil } return m, err }
[ "func", "NewLogManager", "(", "path", ",", "name", "string", ")", "(", "*", "LogManager", ",", "error", ")", "{", "m", ":=", "&", "LogManager", "{", "name", ":", "name", ",", "nsMap", ":", "make", "(", "map", "[", "string", "]", "uint64", ")", ",",...
// NewLogManager creates a new instance of LogManager and initializes its namespace map by reading any // existing log files.
[ "NewLogManager", "creates", "a", "new", "instance", "of", "LogManager", "and", "initializes", "its", "namespace", "map", "by", "reading", "any", "existing", "log", "files", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/offset/logmanager.go#L31-L52
14,023
compose/transporter
offset/logmanager.go
CommitOffset
func (m *LogManager) CommitOffset(o Offset, override bool) error { m.Lock() defer m.Unlock() if currentOffset, ok := m.nsMap[o.Namespace]; !override && ok && currentOffset >= o.LogOffset { log.With("currentOffest", currentOffset). With("providedOffset", o.LogOffset). Debugln("refusing to commit offset") return nil } _, err := m.log.Append(o.Bytes()) if err != nil { return err } m.nsMap[o.Namespace] = o.LogOffset return nil }
go
func (m *LogManager) CommitOffset(o Offset, override bool) error { m.Lock() defer m.Unlock() if currentOffset, ok := m.nsMap[o.Namespace]; !override && ok && currentOffset >= o.LogOffset { log.With("currentOffest", currentOffset). With("providedOffset", o.LogOffset). Debugln("refusing to commit offset") return nil } _, err := m.log.Append(o.Bytes()) if err != nil { return err } m.nsMap[o.Namespace] = o.LogOffset return nil }
[ "func", "(", "m", "*", "LogManager", ")", "CommitOffset", "(", "o", "Offset", ",", "override", "bool", ")", "error", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "if", "currentOffset", ",", "ok", ":=", "m", ...
// CommitOffset verifies it does not contain an offset older than the current offset // and persists to the log.
[ "CommitOffset", "verifies", "it", "does", "not", "contain", "an", "offset", "older", "than", "the", "current", "offset", "and", "persists", "to", "the", "log", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/offset/logmanager.go#L96-L111
14,024
compose/transporter
offset/logmanager.go
OffsetMap
func (m *LogManager) OffsetMap() map[string]uint64 { m.Lock() defer m.Unlock() return m.nsMap }
go
func (m *LogManager) OffsetMap() map[string]uint64 { m.Lock() defer m.Unlock() return m.nsMap }
[ "func", "(", "m", "*", "LogManager", ")", "OffsetMap", "(", ")", "map", "[", "string", "]", "uint64", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "return", "m", ".", "nsMap", "\n", "}" ]
// OffsetMap provides access to the underlying map containing the newest offset for every // namespace.
[ "OffsetMap", "provides", "access", "to", "the", "underlying", "map", "containing", "the", "newest", "offset", "for", "every", "namespace", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/offset/logmanager.go#L115-L119
14,025
compose/transporter
offset/logmanager.go
NewestOffset
func (m *LogManager) NewestOffset() int64 { m.Lock() defer m.Unlock() if len(m.nsMap) == 0 { return -1 } var newestOffset uint64 for _, v := range m.nsMap { if newestOffset < v { newestOffset = v } } return int64(newestOffset) }
go
func (m *LogManager) NewestOffset() int64 { m.Lock() defer m.Unlock() if len(m.nsMap) == 0 { return -1 } var newestOffset uint64 for _, v := range m.nsMap { if newestOffset < v { newestOffset = v } } return int64(newestOffset) }
[ "func", "(", "m", "*", "LogManager", ")", "NewestOffset", "(", ")", "int64", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n", "if", "len", "(", "m", ".", "nsMap", ")", "==", "0", "{", "return", "-", "1", "\n...
// NewestOffset loops over every offset and returns the highest one.
[ "NewestOffset", "loops", "over", "every", "offset", "and", "returns", "the", "highest", "one", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/offset/logmanager.go#L122-L135
14,026
compose/transporter
adaptor/rabbitmq/client.go
WithURI
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { if _, err := amqp.ParseURI(uri); err != nil { return client.InvalidURIError{URI: uri, Err: err.Error()} } c.uri = uri return nil } }
go
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { if _, err := amqp.ParseURI(uri); err != nil { return client.InvalidURIError{URI: uri, Err: err.Error()} } c.uri = uri return nil } }
[ "func", "WithURI", "(", "uri", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "_", ",", "err", ":=", "amqp", ".", "ParseURI", "(", "uri", ")", ";", "err", "!=", "nil", "{", "return", "cli...
// WithURI defines the full connection string for the RabbitMQ connection
[ "WithURI", "defines", "the", "full", "connection", "string", "for", "the", "RabbitMQ", "connection" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rabbitmq/client.go#L67-L75
14,027
compose/transporter
adaptor/rabbitmq/client.go
WithSSL
func WithSSL(ssl bool) ClientOptionFunc { return func(c *Client) error { if ssl { tlsConfig := &tls.Config{InsecureSkipVerify: true} tlsConfig.RootCAs = x509.NewCertPool() c.tlsConfig = tlsConfig } return nil } }
go
func WithSSL(ssl bool) ClientOptionFunc { return func(c *Client) error { if ssl { tlsConfig := &tls.Config{InsecureSkipVerify: true} tlsConfig.RootCAs = x509.NewCertPool() c.tlsConfig = tlsConfig } return nil } }
[ "func", "WithSSL", "(", "ssl", "bool", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "ssl", "{", "tlsConfig", ":=", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "true", "}", "\n", "tlsCo...
// WithSSL configures the database connection to connect via TLS.
[ "WithSSL", "configures", "the", "database", "connection", "to", "connect", "via", "TLS", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rabbitmq/client.go#L78-L87
14,028
compose/transporter
adaptor/rabbitmq/client.go
WithCACerts
func WithCACerts(certs []string) ClientOptionFunc { return func(c *Client) error { if len(certs) > 0 { roots := x509.NewCertPool() for _, cert := range certs { if _, err := os.Stat(cert); err == nil { filepath.Abs(cert) c, err := ioutil.ReadFile(cert) if err != nil { return err } cert = string(c) } if ok := roots.AppendCertsFromPEM([]byte(cert)); !ok { return client.ErrInvalidCert } } if c.tlsConfig != nil { c.tlsConfig.RootCAs = roots } else { c.tlsConfig = &tls.Config{RootCAs: roots} } c.tlsConfig.InsecureSkipVerify = false } return nil } }
go
func WithCACerts(certs []string) ClientOptionFunc { return func(c *Client) error { if len(certs) > 0 { roots := x509.NewCertPool() for _, cert := range certs { if _, err := os.Stat(cert); err == nil { filepath.Abs(cert) c, err := ioutil.ReadFile(cert) if err != nil { return err } cert = string(c) } if ok := roots.AppendCertsFromPEM([]byte(cert)); !ok { return client.ErrInvalidCert } } if c.tlsConfig != nil { c.tlsConfig.RootCAs = roots } else { c.tlsConfig = &tls.Config{RootCAs: roots} } c.tlsConfig.InsecureSkipVerify = false } return nil } }
[ "func", "WithCACerts", "(", "certs", "[", "]", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "len", "(", "certs", ")", ">", "0", "{", "roots", ":=", "x509", ".", "NewCertPool", "(", ")", ...
// WithCACerts configures the RootCAs for the underlying TLS connection
[ "WithCACerts", "configures", "the", "RootCAs", "for", "the", "underlying", "TLS", "connection" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rabbitmq/client.go#L90-L116
14,029
compose/transporter
adaptor/rabbitmq/client.go
Connect
func (c *Client) Connect() (client.Session, error) { if c.conn == nil { if err := c.initConnection(); err != nil { return nil, err } } return &Session{c.conn, c.ch}, nil }
go
func (c *Client) Connect() (client.Session, error) { if c.conn == nil { if err := c.initConnection(); err != nil { return nil, err } } return &Session{c.conn, c.ch}, nil }
[ "func", "(", "c", "*", "Client", ")", "Connect", "(", ")", "(", "client", ".", "Session", ",", "error", ")", "{", "if", "c", ".", "conn", "==", "nil", "{", "if", "err", ":=", "c", ".", "initConnection", "(", ")", ";", "err", "!=", "nil", "{", ...
// Connect satisfies the client.Client interface.
[ "Connect", "satisfies", "the", "client", ".", "Client", "interface", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rabbitmq/client.go#L119-L126
14,030
compose/transporter
cmd/transporter/goja_builder.go
String
func (t *Transporter) String() string { out := "Transporter:\n" out += fmt.Sprintf("%s", t.sourceNode.String()) return out }
go
func (t *Transporter) String() string { out := "Transporter:\n" out += fmt.Sprintf("%s", t.sourceNode.String()) return out }
[ "func", "(", "t", "*", "Transporter", ")", "String", "(", ")", "string", "{", "out", ":=", "\"", "\\n", "\"", "\n", "out", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t", ".", "sourceNode", ".", "String", "(", ")", ")", "\n", "return", ...
// String represents the pipelines as a string
[ "String", "represents", "the", "pipelines", "as", "a", "string" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/cmd/transporter/goja_builder.go#L148-L152
14,031
compose/transporter
cmd/transporter/goja_builder.go
Config
func (t *Transporter) Config(call goja.FunctionCall) goja.Value { if cfg, ok := call.Argument(0).Export().(map[string]interface{}); ok { b, err := json.Marshal(cfg) if err != nil { panic(err) } var c config if err = json.Unmarshal(b, &c); err != nil { panic(err) } t.config = &c } return t.vm.ToValue(t) }
go
func (t *Transporter) Config(call goja.FunctionCall) goja.Value { if cfg, ok := call.Argument(0).Export().(map[string]interface{}); ok { b, err := json.Marshal(cfg) if err != nil { panic(err) } var c config if err = json.Unmarshal(b, &c); err != nil { panic(err) } t.config = &c } return t.vm.ToValue(t) }
[ "func", "(", "t", "*", "Transporter", ")", "Config", "(", "call", "goja", ".", "FunctionCall", ")", "goja", ".", "Value", "{", "if", "cfg", ",", "ok", ":=", "call", ".", "Argument", "(", "0", ")", ".", "Export", "(", ")", ".", "(", "map", "[", ...
// Config parses the provided configuration object and associates it with the // JS VM.
[ "Config", "parses", "the", "provided", "configuration", "object", "and", "associates", "it", "with", "the", "JS", "VM", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/cmd/transporter/goja_builder.go#L176-L190
14,032
compose/transporter
adaptor/elasticsearch/elasticsearch.go
Reader
func (e *Elasticsearch) Reader() (client.Reader, error) { return nil, adaptor.ErrFuncNotSupported{Name: "Reader()", Func: "elasticsearch"} }
go
func (e *Elasticsearch) Reader() (client.Reader, error) { return nil, adaptor.ErrFuncNotSupported{Name: "Reader()", Func: "elasticsearch"} }
[ "func", "(", "e", "*", "Elasticsearch", ")", "Reader", "(", ")", "(", "client", ".", "Reader", ",", "error", ")", "{", "return", "nil", ",", "adaptor", ".", "ErrFuncNotSupported", "{", "Name", ":", "\"", "\"", ",", "Func", ":", "\"", "\"", "}", "\n...
// Reader returns an error because this adaptor is currently not supported as a Source.
[ "Reader", "returns", "an", "error", "because", "this", "adaptor", "is", "currently", "not", "supported", "as", "a", "Source", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/elasticsearch/elasticsearch.go#L75-L77
14,033
compose/transporter
adaptor/elasticsearch/elasticsearch.go
Writer
func (e *Elasticsearch) Writer(done chan struct{}, wg *sync.WaitGroup) (client.Writer, error) { return setupWriter(e) }
go
func (e *Elasticsearch) Writer(done chan struct{}, wg *sync.WaitGroup) (client.Writer, error) { return setupWriter(e) }
[ "func", "(", "e", "*", "Elasticsearch", ")", "Writer", "(", "done", "chan", "struct", "{", "}", ",", "wg", "*", "sync", ".", "WaitGroup", ")", "(", "client", ".", "Writer", ",", "error", ")", "{", "return", "setupWriter", "(", "e", ")", "\n", "}" ]
// Writer determines the which underlying writer to used based on the cluster's version.
[ "Writer", "determines", "the", "which", "underlying", "writer", "to", "used", "based", "on", "the", "cluster", "s", "version", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/elasticsearch/elasticsearch.go#L80-L82
14,034
compose/transporter
message/data/data.go
Has
func (d Data) Has(key string) (interface{}, bool) { val, ok := d[key] return val, ok }
go
func (d Data) Has(key string) (interface{}, bool) { val, ok := d[key] return val, ok }
[ "func", "(", "d", "Data", ")", "Has", "(", "key", "string", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "val", ",", "ok", ":=", "d", "[", "key", "]", "\n", "return", "val", ",", "ok", "\n", "}" ]
// Has returns to two value from of the key lookup on a map.
[ "Has", "returns", "to", "two", "value", "from", "of", "the", "key", "lookup", "on", "a", "map", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/message/data/data.go#L17-L20
14,035
compose/transporter
commitlog/log.go
PutOffset
func (l Log) PutOffset(offset int64) { encoding.PutUint64(l[offsetPos:sizePos], uint64(offset)) }
go
func (l Log) PutOffset(offset int64) { encoding.PutUint64(l[offsetPos:sizePos], uint64(offset)) }
[ "func", "(", "l", "Log", ")", "PutOffset", "(", "offset", "int64", ")", "{", "encoding", ".", "PutUint64", "(", "l", "[", "offsetPos", ":", "sizePos", "]", ",", "uint64", "(", "offset", ")", ")", "\n", "}" ]
// PutOffset sets the provided offset for the given Log.
[ "PutOffset", "sets", "the", "provided", "offset", "for", "the", "given", "Log", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/log.go#L7-L9
14,036
compose/transporter
commitlog/commitlog.go
WithPath
func WithPath(path string) OptionFunc { return func(c *CommitLog) error { if path == "" { return ErrEmptyPath } c.path = path return nil } }
go
func WithPath(path string) OptionFunc { return func(c *CommitLog) error { if path == "" { return ErrEmptyPath } c.path = path return nil } }
[ "func", "WithPath", "(", "path", "string", ")", "OptionFunc", "{", "return", "func", "(", "c", "*", "CommitLog", ")", "error", "{", "if", "path", "==", "\"", "\"", "{", "return", "ErrEmptyPath", "\n", "}", "\n", "c", ".", "path", "=", "path", "\n", ...
// WithPath defines the directory where all data will be stored.
[ "WithPath", "defines", "the", "directory", "where", "all", "data", "will", "be", "stored", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/commitlog.go#L92-L100
14,037
compose/transporter
commitlog/commitlog.go
WithMaxSegmentBytes
func WithMaxSegmentBytes(max int64) OptionFunc { return func(c *CommitLog) error { if max > 0 { c.maxSegmentBytes = max } return nil } }
go
func WithMaxSegmentBytes(max int64) OptionFunc { return func(c *CommitLog) error { if max > 0 { c.maxSegmentBytes = max } return nil } }
[ "func", "WithMaxSegmentBytes", "(", "max", "int64", ")", "OptionFunc", "{", "return", "func", "(", "c", "*", "CommitLog", ")", "error", "{", "if", "max", ">", "0", "{", "c", ".", "maxSegmentBytes", "=", "max", "\n", "}", "\n", "return", "nil", "\n", ...
// WithMaxSegmentBytes defines the maximum limit a log segment can reach before needing // to create a new one.
[ "WithMaxSegmentBytes", "defines", "the", "maximum", "limit", "a", "log", "segment", "can", "reach", "before", "needing", "to", "create", "a", "new", "one", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/commitlog.go#L104-L111
14,038
compose/transporter
commitlog/commitlog.go
OldestOffset
func (c *CommitLog) OldestOffset() int64 { c.mu.RLock() defer c.mu.RUnlock() return c.segments[0].BaseOffset }
go
func (c *CommitLog) OldestOffset() int64 { c.mu.RLock() defer c.mu.RUnlock() return c.segments[0].BaseOffset }
[ "func", "(", "c", "*", "CommitLog", ")", "OldestOffset", "(", ")", "int64", "{", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "c", ".", "segments", "[", "0", "]", ".", "BaseOff...
// OldestOffset obtains the BaseOffset from the oldest segment on disk.
[ "OldestOffset", "obtains", "the", "BaseOffset", "from", "the", "oldest", "segment", "on", "disk", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/commitlog.go#L203-L207
14,039
compose/transporter
commitlog/commitlog.go
Segments
func (c *CommitLog) Segments() []*Segment { c.mu.Lock() defer c.mu.Unlock() return c.segments }
go
func (c *CommitLog) Segments() []*Segment { c.mu.Lock() defer c.mu.Unlock() return c.segments }
[ "func", "(", "c", "*", "CommitLog", ")", "Segments", "(", ")", "[", "]", "*", "Segment", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "c", ".", "segments", "\n", "}" ]
// Segments provides access to the underlying segments stored on disk.
[ "Segments", "provides", "access", "to", "the", "underlying", "segments", "stored", "on", "disk", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/commitlog.go#L210-L214
14,040
compose/transporter
commitlog/commitlog.go
DeleteAll
func (c *CommitLog) DeleteAll() error { if err := c.Close(); err != nil { return err } return os.RemoveAll(c.path) }
go
func (c *CommitLog) DeleteAll() error { if err := c.Close(); err != nil { return err } return os.RemoveAll(c.path) }
[ "func", "(", "c", "*", "CommitLog", ")", "DeleteAll", "(", ")", "error", "{", "if", "err", ":=", "c", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "os", ".", "RemoveAll", "(", "c", ".", "path...
// DeleteAll cleans out all data in the path.
[ "DeleteAll", "cleans", "out", "all", "data", "in", "the", "path", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/commitlog.go#L217-L222
14,041
compose/transporter
commitlog/commitlog.go
NewReader
func (c *CommitLog) NewReader(offset int64) (io.Reader, error) { c.mu.RLock() defer c.mu.RUnlock() log.With("num_segments", len(c.segments)). With("offset", offset). Infoln("searching segments") // in the event there has been data committed to the segment but no offset for a path, // then we need to create a reader that starts from the very beginning if offset < 0 && len(c.segments) > 0 { // if err := c.segments[0].Open(); err != nil { // log.Errorf("unable to open segment, %s", err) // } return &Reader{commitlog: c, idx: 0, position: 0}, nil } var idx int for i := 0; i < len(c.segments); i++ { idx = i if (i + 1) != len(c.segments) { lowerOffset := c.segments[i].BaseOffset upperOffset := c.segments[i+1].BaseOffset log.With("lower_offset", lowerOffset). With("upper_offset", upperOffset). With("offset", offset). With("segment", idx). Debugln("checking if offset in segment") if offset >= lowerOffset && offset < upperOffset { break } } } log.With("offset", offset).With("segment_index", idx).Debugln("finding offset in segment") // if err := c.segments[idx].Open(); err != nil { // log.Errorf("unable to open segment, %s", err) // } position, err := c.segments[idx].FindOffsetPosition(uint64(offset)) if err != nil { return nil, err } return &Reader{ commitlog: c, idx: idx, position: position, }, nil }
go
func (c *CommitLog) NewReader(offset int64) (io.Reader, error) { c.mu.RLock() defer c.mu.RUnlock() log.With("num_segments", len(c.segments)). With("offset", offset). Infoln("searching segments") // in the event there has been data committed to the segment but no offset for a path, // then we need to create a reader that starts from the very beginning if offset < 0 && len(c.segments) > 0 { // if err := c.segments[0].Open(); err != nil { // log.Errorf("unable to open segment, %s", err) // } return &Reader{commitlog: c, idx: 0, position: 0}, nil } var idx int for i := 0; i < len(c.segments); i++ { idx = i if (i + 1) != len(c.segments) { lowerOffset := c.segments[i].BaseOffset upperOffset := c.segments[i+1].BaseOffset log.With("lower_offset", lowerOffset). With("upper_offset", upperOffset). With("offset", offset). With("segment", idx). Debugln("checking if offset in segment") if offset >= lowerOffset && offset < upperOffset { break } } } log.With("offset", offset).With("segment_index", idx).Debugln("finding offset in segment") // if err := c.segments[idx].Open(); err != nil { // log.Errorf("unable to open segment, %s", err) // } position, err := c.segments[idx].FindOffsetPosition(uint64(offset)) if err != nil { return nil, err } return &Reader{ commitlog: c, idx: idx, position: position, }, nil }
[ "func", "(", "c", "*", "CommitLog", ")", "NewReader", "(", "offset", "int64", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "c", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "RUnlock", "(", ")", "\n", "log", ...
// NewReader returns an io.Reader based on the provider offset.
[ "NewReader", "returns", "an", "io", ".", "Reader", "based", "on", "the", "provider", "offset", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/commitlog.go#L225-L272
14,042
compose/transporter
pipe/pipe.go
NewPipe
func NewPipe(pipe *Pipe, path string) *Pipe { p := &Pipe{ Out: make([]messageChan, 0), path: path, chStop: make(chan struct{}), } if pipe != nil { pipe.Out = append(pipe.Out, newMessageChan()) p.In = pipe.Out[len(pipe.Out)-1] // use the last out channel p.Err = pipe.Err p.Event = pipe.Event } else { p.Err = make(chan error) p.Event = make(chan events.Event, 10) // buffer the event channel } return p }
go
func NewPipe(pipe *Pipe, path string) *Pipe { p := &Pipe{ Out: make([]messageChan, 0), path: path, chStop: make(chan struct{}), } if pipe != nil { pipe.Out = append(pipe.Out, newMessageChan()) p.In = pipe.Out[len(pipe.Out)-1] // use the last out channel p.Err = pipe.Err p.Event = pipe.Event } else { p.Err = make(chan error) p.Event = make(chan events.Event, 10) // buffer the event channel } return p }
[ "func", "NewPipe", "(", "pipe", "*", "Pipe", ",", "path", "string", ")", "*", "Pipe", "{", "p", ":=", "&", "Pipe", "{", "Out", ":", "make", "(", "[", "]", "messageChan", ",", "0", ")", ",", "path", ":", "path", ",", "chStop", ":", "make", "(", ...
// NewPipe creates a new Pipe. If the pipe that is passed in is nil, then this pipe will be treated as a source pipe that just serves to emit messages. // Otherwise, the pipe returned will be created and chained from the last member of the Out slice of the parent. This function has side effects, and will add // an Out channel to the pipe that is passed in
[ "NewPipe", "creates", "a", "new", "Pipe", ".", "If", "the", "pipe", "that", "is", "passed", "in", "is", "nil", "then", "this", "pipe", "will", "be", "treated", "as", "a", "source", "pipe", "that", "just", "serves", "to", "emit", "messages", ".", "Other...
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipe/pipe.go#L61-L80
14,043
compose/transporter
pipe/pipe.go
Stop
func (p *Pipe) Stop() { if !p.Stopped { p.Stopped = true // we only worry about the stop channel if we're in a listening loop if p.listening { close(p.chStop) p.wg.Wait() return } timeout := time.After(10 * time.Second) for { select { case <-timeout: log.With("path", p.path).Errorln("timeout reached waiting for Out channels to clear") return default: } if p.empty() { return } time.Sleep(1 * time.Second) } } }
go
func (p *Pipe) Stop() { if !p.Stopped { p.Stopped = true // we only worry about the stop channel if we're in a listening loop if p.listening { close(p.chStop) p.wg.Wait() return } timeout := time.After(10 * time.Second) for { select { case <-timeout: log.With("path", p.path).Errorln("timeout reached waiting for Out channels to clear") return default: } if p.empty() { return } time.Sleep(1 * time.Second) } } }
[ "func", "(", "p", "*", "Pipe", ")", "Stop", "(", ")", "{", "if", "!", "p", ".", "Stopped", "{", "p", ".", "Stopped", "=", "true", "\n\n", "// we only worry about the stop channel if we're in a listening loop", "if", "p", ".", "listening", "{", "close", "(", ...
// Stop terminates the channels listening loop, and allows any timeouts in send to fail
[ "Stop", "terminates", "the", "channels", "listening", "loop", "and", "allows", "any", "timeouts", "in", "send", "to", "fail" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipe/pipe.go#L122-L147
14,044
compose/transporter
pipe/pipe.go
Send
func (p *Pipe) Send(msg message.Msg, off offset.Offset) { p.MessageCount++ for _, ch := range p.Out { A: for { select { case ch <- TrackedMessage{msg, off}: break A } } } }
go
func (p *Pipe) Send(msg message.Msg, off offset.Offset) { p.MessageCount++ for _, ch := range p.Out { A: for { select { case ch <- TrackedMessage{msg, off}: break A } } } }
[ "func", "(", "p", "*", "Pipe", ")", "Send", "(", "msg", "message", ".", "Msg", ",", "off", "offset", ".", "Offset", ")", "{", "p", ".", "MessageCount", "++", "\n", "for", "_", ",", "ch", ":=", "range", "p", ".", "Out", "{", "A", ":", "for", "...
// Send emits the given message on the 'Out' channel. the send Timesout after 100 ms in order to chaeck of the Pipe has stopped and we've been asked to exit. // If the Pipe has been stopped, the send will fail and there is no guarantee of either success or failure
[ "Send", "emits", "the", "given", "message", "on", "the", "Out", "channel", ".", "the", "send", "Timesout", "after", "100", "ms", "in", "order", "to", "chaeck", "of", "the", "Pipe", "has", "stopped", "and", "we", "ve", "been", "asked", "to", "exit", "."...
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipe/pipe.go#L160-L172
14,045
compose/transporter
adaptor/mongodb/reader.go
getOriginalDoc
func (r *Reader) getOriginalDoc(doc bson.M, c string, s *mgo.Session) (result bson.M, err error) { id, exists := doc["_id"] if !exists { return result, fmt.Errorf("can't get _id from document") } query := bson.M{} if f, ok := r.collectionFilters[c]; ok { query = bson.M(f) } query["_id"] = id err = s.DB("").C(c).Find(query).One(&result) if err != nil { err = fmt.Errorf("%s.%s %v %v", s.DB("").Name, c, id, err) } return }
go
func (r *Reader) getOriginalDoc(doc bson.M, c string, s *mgo.Session) (result bson.M, err error) { id, exists := doc["_id"] if !exists { return result, fmt.Errorf("can't get _id from document") } query := bson.M{} if f, ok := r.collectionFilters[c]; ok { query = bson.M(f) } query["_id"] = id err = s.DB("").C(c).Find(query).One(&result) if err != nil { err = fmt.Errorf("%s.%s %v %v", s.DB("").Name, c, id, err) } return }
[ "func", "(", "r", "*", "Reader", ")", "getOriginalDoc", "(", "doc", "bson", ".", "M", ",", "c", "string", ",", "s", "*", "mgo", ".", "Session", ")", "(", "result", "bson", ".", "M", ",", "err", "error", ")", "{", "id", ",", "exists", ":=", "doc...
// getOriginalDoc retrieves the original document from the database. // transporter has no knowledge of update operations, all updates work as wholesale document replaces
[ "getOriginalDoc", "retrieves", "the", "original", "document", "from", "the", "database", ".", "transporter", "has", "no", "knowledge", "of", "update", "operations", "all", "updates", "work", "as", "wholesale", "document", "replaces" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/mongodb/reader.go#L309-L326
14,046
compose/transporter
adaptor/mongodb/reader.go
validOp
func (o *oplogDoc) validOp(ns string) bool { return ns == o.Ns && (o.Op == "i" || o.Op == "d" || o.Op == "u") }
go
func (o *oplogDoc) validOp(ns string) bool { return ns == o.Ns && (o.Op == "i" || o.Op == "d" || o.Op == "u") }
[ "func", "(", "o", "*", "oplogDoc", ")", "validOp", "(", "ns", "string", ")", "bool", "{", "return", "ns", "==", "o", ".", "Ns", "&&", "(", "o", ".", "Op", "==", "\"", "\"", "||", "o", ".", "Op", "==", "\"", "\"", "||", "o", ".", "Op", "==",...
// validOp checks to see if we're an insert, delete, or update, otherwise the // document is skilled.
[ "validOp", "checks", "to", "see", "if", "we", "re", "an", "insert", "delete", "or", "update", "otherwise", "the", "document", "is", "skilled", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/mongodb/reader.go#L342-L344
14,047
compose/transporter
adaptor/mongodb/client.go
WithURI
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { _, err := mgo.ParseURL(uri) if err != nil { return client.InvalidURIError{URI: uri, Err: err.Error()} } c.uri = uri return nil } }
go
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { _, err := mgo.ParseURL(uri) if err != nil { return client.InvalidURIError{URI: uri, Err: err.Error()} } c.uri = uri return nil } }
[ "func", "WithURI", "(", "uri", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "_", ",", "err", ":=", "mgo", ".", "ParseURL", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli...
// WithURI defines the full connection string of the MongoDB database.
[ "WithURI", "defines", "the", "full", "connection", "string", "of", "the", "MongoDB", "database", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/mongodb/client.go#L112-L121
14,048
compose/transporter
adaptor/mongodb/client.go
WithTimeout
func WithTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.sessionTimeout = DefaultSessionTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.sessionTimeout = t return nil } }
go
func WithTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.sessionTimeout = DefaultSessionTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.sessionTimeout = t return nil } }
[ "func", "WithTimeout", "(", "timeout", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "timeout", "==", "\"", "\"", "{", "c", ".", "sessionTimeout", "=", "DefaultSessionTimeout", "\n", "return", "...
// WithTimeout overrides the DefaultSessionTimeout and should be parseable by time.ParseDuration
[ "WithTimeout", "overrides", "the", "DefaultSessionTimeout", "and", "should", "be", "parseable", "by", "time", ".", "ParseDuration" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/mongodb/client.go#L124-L138
14,049
compose/transporter
adaptor/mongodb/client.go
WithReadPreference
func WithReadPreference(readPreference string) ClientOptionFunc { return func(c *Client) error { if readPreference == "" { c.readPreference = DefaultReadPreference return nil } switch strings.ToLower(readPreference) { case "primary": c.readPreference = mgo.Primary case "primarypreferred": c.readPreference = mgo.PrimaryPreferred case "secondary": c.readPreference = mgo.Secondary case "secondarypreferred": c.readPreference = mgo.SecondaryPreferred case "nearest": c.readPreference = mgo.Nearest default: return InvalidReadPreferenceError{ReadPreference: readPreference} } return nil } }
go
func WithReadPreference(readPreference string) ClientOptionFunc { return func(c *Client) error { if readPreference == "" { c.readPreference = DefaultReadPreference return nil } switch strings.ToLower(readPreference) { case "primary": c.readPreference = mgo.Primary case "primarypreferred": c.readPreference = mgo.PrimaryPreferred case "secondary": c.readPreference = mgo.Secondary case "secondarypreferred": c.readPreference = mgo.SecondaryPreferred case "nearest": c.readPreference = mgo.Nearest default: return InvalidReadPreferenceError{ReadPreference: readPreference} } return nil } }
[ "func", "WithReadPreference", "(", "readPreference", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "readPreference", "==", "\"", "\"", "{", "c", ".", "readPreference", "=", "DefaultReadPreference", ...
// WithReadPreference sets the MongoDB read preference based on the provided string.
[ "WithReadPreference", "sets", "the", "MongoDB", "read", "preference", "based", "on", "the", "provided", "string", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/mongodb/client.go#L211-L233
14,050
compose/transporter
adaptor/mongodb/client.go
Connect
func (c *Client) Connect() (client.Session, error) { if c.mgoSession == nil { if err := c.initConnection(); err != nil { return nil, err } } return c.session(), nil }
go
func (c *Client) Connect() (client.Session, error) { if c.mgoSession == nil { if err := c.initConnection(); err != nil { return nil, err } } return c.session(), nil }
[ "func", "(", "c", "*", "Client", ")", "Connect", "(", ")", "(", "client", ".", "Session", ",", "error", ")", "{", "if", "c", ".", "mgoSession", "==", "nil", "{", "if", "err", ":=", "c", ".", "initConnection", "(", ")", ";", "err", "!=", "nil", ...
// Connect tests the mongodb connection and initializes the mongo session
[ "Connect", "tests", "the", "mongodb", "connection", "and", "initializes", "the", "mongo", "session" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/mongodb/client.go#L236-L243
14,051
compose/transporter
adaptor/mongodb/client.go
session
func (c *Client) session() client.Session { sess := c.mgoSession.Copy() return &Session{sess} }
go
func (c *Client) session() client.Session { sess := c.mgoSession.Copy() return &Session{sess} }
[ "func", "(", "c", "*", "Client", ")", "session", "(", ")", "client", ".", "Session", "{", "sess", ":=", "c", ".", "mgoSession", ".", "Copy", "(", ")", "\n", "return", "&", "Session", "{", "sess", "}", "\n", "}" ]
// Session fulfills the client.Client interface by providing a copy of the main mgoSession
[ "Session", "fulfills", "the", "client", ".", "Client", "interface", "by", "providing", "a", "copy", "of", "the", "main", "mgoSession" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/mongodb/client.go#L304-L307
14,052
compose/transporter
adaptor/file/client.go
Connect
func (c *Client) Connect() (client.Session, error) { if c.file == nil { if err := c.initFile(); err != nil { return nil, err } } return &Session{c.file}, nil }
go
func (c *Client) Connect() (client.Session, error) { if c.file == nil { if err := c.initFile(); err != nil { return nil, err } } return &Session{c.file}, nil }
[ "func", "(", "c", "*", "Client", ")", "Connect", "(", ")", "(", "client", ".", "Session", ",", "error", ")", "{", "if", "c", ".", "file", "==", "nil", "{", "if", "err", ":=", "c", ".", "initFile", "(", ")", ";", "err", "!=", "nil", "{", "retu...
// Connect initializes the file for IO
[ "Connect", "initializes", "the", "file", "for", "IO" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/file/client.go#L55-L62
14,053
compose/transporter
adaptor/file/client.go
Close
func (c *Client) Close() { if c.file != nil && c.file != os.Stdout { c.file.Close() } }
go
func (c *Client) Close() { if c.file != nil && c.file != os.Stdout { c.file.Close() } }
[ "func", "(", "c", "*", "Client", ")", "Close", "(", ")", "{", "if", "c", ".", "file", "!=", "nil", "&&", "c", ".", "file", "!=", "os", ".", "Stdout", "{", "c", ".", "file", ".", "Close", "(", ")", "\n", "}", "\n", "}" ]
// Close closes the underlying file
[ "Close", "closes", "the", "underlying", "file" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/file/client.go#L65-L69
14,054
compose/transporter
events/events.go
NewMetricsEvent
func NewMetricsEvent(ts int64, path string, records int) Event { e := &metricsEvent{ Ts: ts, Kind: "metrics", Path: path, Records: records, } return e }
go
func NewMetricsEvent(ts int64, path string, records int) Event { e := &metricsEvent{ Ts: ts, Kind: "metrics", Path: path, Records: records, } return e }
[ "func", "NewMetricsEvent", "(", "ts", "int64", ",", "path", "string", ",", "records", "int", ")", "Event", "{", "e", ":=", "&", "metricsEvent", "{", "Ts", ":", "ts", ",", "Kind", ":", "\"", "\"", ",", "Path", ":", "path", ",", "Records", ":", "reco...
// NewMetricsEvent creates a new metrics event
[ "NewMetricsEvent", "creates", "a", "new", "metrics", "event" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/events/events.go#L75-L83
14,055
compose/transporter
events/events.go
NewErrorEvent
func NewErrorEvent(ts int64, path string, record interface{}, message string) Event { e := &errorEvent{ Ts: ts, Kind: "error", Path: path, Record: record, Message: message, } return e }
go
func NewErrorEvent(ts int64, path string, record interface{}, message string) Event { e := &errorEvent{ Ts: ts, Kind: "error", Path: path, Record: record, Message: message, } return e }
[ "func", "NewErrorEvent", "(", "ts", "int64", ",", "path", "string", ",", "record", "interface", "{", "}", ",", "message", "string", ")", "Event", "{", "e", ":=", "&", "errorEvent", "{", "Ts", ":", "ts", ",", "Kind", ":", "\"", "\"", ",", "Path", ":...
// NewErrorEvent are events sent to indicate a problem processing on one of the nodes
[ "NewErrorEvent", "are", "events", "sent", "to", "indicate", "a", "problem", "processing", "on", "one", "of", "the", "nodes" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/events/events.go#L113-L122
14,056
compose/transporter
pipeline/node.go
NewNodeWithOptions
func NewNodeWithOptions(name, kind, ns string, options ...OptionFunc) (*Node, error) { compiledNs, err := regexp.Compile(strings.Trim(ns, "/")) if err != nil { return nil, err } n := &Node{ Name: name, Type: kind, path: name, depth: 1, nsFilter: compiledNs, pipe: pipe.NewPipe(nil, name), children: make([]*Node, 0), transforms: make([]*Transform, 0), done: make(chan struct{}), c: &client.Mock{}, reader: &client.MockReader{}, writer: &client.MockWriter{}, resumeTimeout: 60 * time.Second, writeTimeout: defaultWriteTimeout, compactionInterval: defaultCompactionInterval, } // Run the options on it for _, option := range options { if err := option(n); err != nil { return nil, err } } return n, nil }
go
func NewNodeWithOptions(name, kind, ns string, options ...OptionFunc) (*Node, error) { compiledNs, err := regexp.Compile(strings.Trim(ns, "/")) if err != nil { return nil, err } n := &Node{ Name: name, Type: kind, path: name, depth: 1, nsFilter: compiledNs, pipe: pipe.NewPipe(nil, name), children: make([]*Node, 0), transforms: make([]*Transform, 0), done: make(chan struct{}), c: &client.Mock{}, reader: &client.MockReader{}, writer: &client.MockWriter{}, resumeTimeout: 60 * time.Second, writeTimeout: defaultWriteTimeout, compactionInterval: defaultCompactionInterval, } // Run the options on it for _, option := range options { if err := option(n); err != nil { return nil, err } } return n, nil }
[ "func", "NewNodeWithOptions", "(", "name", ",", "kind", ",", "ns", "string", ",", "options", "...", "OptionFunc", ")", "(", "*", "Node", ",", "error", ")", "{", "compiledNs", ",", "err", ":=", "regexp", ".", "Compile", "(", "strings", ".", "Trim", "(",...
// NewNodeWithOptions initializes a Node with the required parameters and then applies // each OptionFunc provided.
[ "NewNodeWithOptions", "initializes", "a", "Node", "with", "the", "required", "parameters", "and", "then", "applies", "each", "OptionFunc", "provided", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L96-L125
14,057
compose/transporter
pipeline/node.go
WithReader
func WithReader(a adaptor.Adaptor) OptionFunc { return func(n *Node) error { r, err := a.Reader() n.reader = r return err } }
go
func WithReader(a adaptor.Adaptor) OptionFunc { return func(n *Node) error { r, err := a.Reader() n.reader = r return err } }
[ "func", "WithReader", "(", "a", "adaptor", ".", "Adaptor", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "r", ",", "err", ":=", "a", ".", "Reader", "(", ")", "\n", "n", ".", "reader", "=", "r", "\n", "return"...
// WithReader sets the client.Reader to be used to source data from.
[ "WithReader", "sets", "the", "client", ".", "Reader", "to", "be", "used", "to", "source", "data", "from", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L138-L144
14,058
compose/transporter
pipeline/node.go
WithWriter
func WithWriter(a adaptor.Adaptor) OptionFunc { return func(n *Node) error { w, err := a.Writer(n.done, &n.wg) n.writer = w return err } }
go
func WithWriter(a adaptor.Adaptor) OptionFunc { return func(n *Node) error { w, err := a.Writer(n.done, &n.wg) n.writer = w return err } }
[ "func", "WithWriter", "(", "a", "adaptor", ".", "Adaptor", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "w", ",", "err", ":=", "a", ".", "Writer", "(", "n", ".", "done", ",", "&", "n", ".", "wg", ")", "\n"...
// WithWriter sets the client.Writer to be used to send data to.
[ "WithWriter", "sets", "the", "client", ".", "Writer", "to", "be", "used", "to", "send", "data", "to", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L147-L153
14,059
compose/transporter
pipeline/node.go
WithParent
func WithParent(parent *Node) OptionFunc { return func(n *Node) error { n.parent = parent parent.children = append(parent.children, n) n.path = parent.path + "/" + n.Name n.depth = parent.depth + 1 n.pipe = pipe.NewPipe(parent.pipe, n.path) return nil } }
go
func WithParent(parent *Node) OptionFunc { return func(n *Node) error { n.parent = parent parent.children = append(parent.children, n) n.path = parent.path + "/" + n.Name n.depth = parent.depth + 1 n.pipe = pipe.NewPipe(parent.pipe, n.path) return nil } }
[ "func", "WithParent", "(", "parent", "*", "Node", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "n", ".", "parent", "=", "parent", "\n", "parent", ".", "children", "=", "append", "(", "parent", ".", "children", "...
// WithParent sets the parent node and reconfigures the pipe.
[ "WithParent", "sets", "the", "parent", "node", "and", "reconfigures", "the", "pipe", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L156-L165
14,060
compose/transporter
pipeline/node.go
WithTransforms
func WithTransforms(t []*Transform) OptionFunc { return func(n *Node) error { n.transforms = t return nil } }
go
func WithTransforms(t []*Transform) OptionFunc { return func(n *Node) error { n.transforms = t return nil } }
[ "func", "WithTransforms", "(", "t", "[", "]", "*", "Transform", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "n", ".", "transforms", "=", "t", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithTransforms adds the provided transforms to be applied in the pipeline.
[ "WithTransforms", "adds", "the", "provided", "transforms", "to", "be", "applied", "in", "the", "pipeline", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L168-L173
14,061
compose/transporter
pipeline/node.go
WithCommitLog
func WithCommitLog(options ...commitlog.OptionFunc) OptionFunc { return func(n *Node) error { clog, err := commitlog.New(options...) n.clog = clog return err } }
go
func WithCommitLog(options ...commitlog.OptionFunc) OptionFunc { return func(n *Node) error { clog, err := commitlog.New(options...) n.clog = clog return err } }
[ "func", "WithCommitLog", "(", "options", "...", "commitlog", ".", "OptionFunc", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "clog", ",", "err", ":=", "commitlog", ".", "New", "(", "options", "...", ")", "\n", "n"...
// WithCommitLog configures a CommitLog for the reader to persist messages.
[ "WithCommitLog", "configures", "a", "CommitLog", "for", "the", "reader", "to", "persist", "messages", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L176-L182
14,062
compose/transporter
pipeline/node.go
WithResumeTimeout
func WithResumeTimeout(timeout time.Duration) OptionFunc { return func(n *Node) error { n.resumeTimeout = timeout return nil } }
go
func WithResumeTimeout(timeout time.Duration) OptionFunc { return func(n *Node) error { n.resumeTimeout = timeout return nil } }
[ "func", "WithResumeTimeout", "(", "timeout", "time", ".", "Duration", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "n", ".", "resumeTimeout", "=", "timeout", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithResumeTimeout configures how long to wait before all sink offsets match the // newest offset.
[ "WithResumeTimeout", "configures", "how", "long", "to", "wait", "before", "all", "sink", "offsets", "match", "the", "newest", "offset", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L186-L191
14,063
compose/transporter
pipeline/node.go
WithWriteTimeout
func WithWriteTimeout(timeout string) OptionFunc { return func(n *Node) error { if timeout == "" { n.writeTimeout = defaultWriteTimeout return nil } wt, err := time.ParseDuration(timeout) if err != nil { return err } n.writeTimeout = wt return nil } }
go
func WithWriteTimeout(timeout string) OptionFunc { return func(n *Node) error { if timeout == "" { n.writeTimeout = defaultWriteTimeout return nil } wt, err := time.ParseDuration(timeout) if err != nil { return err } n.writeTimeout = wt return nil } }
[ "func", "WithWriteTimeout", "(", "timeout", "string", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "if", "timeout", "==", "\"", "\"", "{", "n", ".", "writeTimeout", "=", "defaultWriteTimeout", "\n", "return", "nil", ...
// WithWriteTimeout configures the timeout duration for a writer to return.
[ "WithWriteTimeout", "configures", "the", "timeout", "duration", "for", "a", "writer", "to", "return", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L194-L207
14,064
compose/transporter
pipeline/node.go
WithOffsetManager
func WithOffsetManager(om offset.Manager) OptionFunc { return func(n *Node) error { n.om = om return nil } }
go
func WithOffsetManager(om offset.Manager) OptionFunc { return func(n *Node) error { n.om = om return nil } }
[ "func", "WithOffsetManager", "(", "om", "offset", ".", "Manager", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "n", ".", "om", "=", "om", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithOffsetManager configures an offset.Manager to track message offsets.
[ "WithOffsetManager", "configures", "an", "offset", ".", "Manager", "to", "track", "message", "offsets", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L210-L215
14,065
compose/transporter
pipeline/node.go
WithCompactionInterval
func WithCompactionInterval(interval string) OptionFunc { return func(n *Node) error { if interval == "" { n.compactionInterval = defaultCompactionInterval return nil } ci, err := time.ParseDuration(interval) if err != nil { return err } n.compactionInterval = ci return nil } }
go
func WithCompactionInterval(interval string) OptionFunc { return func(n *Node) error { if interval == "" { n.compactionInterval = defaultCompactionInterval return nil } ci, err := time.ParseDuration(interval) if err != nil { return err } n.compactionInterval = ci return nil } }
[ "func", "WithCompactionInterval", "(", "interval", "string", ")", "OptionFunc", "{", "return", "func", "(", "n", "*", "Node", ")", "error", "{", "if", "interval", "==", "\"", "\"", "{", "n", ".", "compactionInterval", "=", "defaultCompactionInterval", "\n", ...
// WithCompactionInterval configures the duration for running log compaction.
[ "WithCompactionInterval", "configures", "the", "duration", "for", "running", "log", "compaction", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L218-L231
14,066
compose/transporter
pipeline/node.go
start
func (n *Node) start(nsMap map[string]client.MessageSet) error { n.l.Infoln("adaptor Starting...") s, err := n.c.Connect() if err != nil { return err } if closer, ok := s.(client.Closer); ok { defer func() { n.l.Debugln("closing session...") closer.Close() n.l.Debugln("session closed...") }() } readFunc := n.reader.Read(nsMap, func(check string) bool { return n.nsFilter.MatchString(check) }) msgChan, err := readFunc(s, n.done) if err != nil { return err } var logOffset int64 for msg := range msgChan { if n.clog != nil { d, _ := mejson.Marshal(msg.Msg.Data().AsMap()) b, _ := json.Marshal(d) o, err := n.clog.Append( commitlog.NewLogFromEntry( commitlog.LogEntry{ Key: []byte(msg.Msg.Namespace()), Mode: msg.Mode, Op: msg.Msg.OP(), Timestamp: uint64(msg.Timestamp), Value: b, })) if err != nil { return err } logOffset = o n.l.With("offset", logOffset).Debugln("attaching offset to message") } n.pipe.Send(msg.Msg, offset.Offset{ Namespace: msg.Msg.Namespace(), LogOffset: uint64(logOffset), Timestamp: time.Now().Unix(), }) } n.l.Infoln("adaptor Start finished...") return nil }
go
func (n *Node) start(nsMap map[string]client.MessageSet) error { n.l.Infoln("adaptor Starting...") s, err := n.c.Connect() if err != nil { return err } if closer, ok := s.(client.Closer); ok { defer func() { n.l.Debugln("closing session...") closer.Close() n.l.Debugln("session closed...") }() } readFunc := n.reader.Read(nsMap, func(check string) bool { return n.nsFilter.MatchString(check) }) msgChan, err := readFunc(s, n.done) if err != nil { return err } var logOffset int64 for msg := range msgChan { if n.clog != nil { d, _ := mejson.Marshal(msg.Msg.Data().AsMap()) b, _ := json.Marshal(d) o, err := n.clog.Append( commitlog.NewLogFromEntry( commitlog.LogEntry{ Key: []byte(msg.Msg.Namespace()), Mode: msg.Mode, Op: msg.Msg.OP(), Timestamp: uint64(msg.Timestamp), Value: b, })) if err != nil { return err } logOffset = o n.l.With("offset", logOffset).Debugln("attaching offset to message") } n.pipe.Send(msg.Msg, offset.Offset{ Namespace: msg.Msg.Namespace(), LogOffset: uint64(logOffset), Timestamp: time.Now().Unix(), }) } n.l.Infoln("adaptor Start finished...") return nil }
[ "func", "(", "n", "*", "Node", ")", "start", "(", "nsMap", "map", "[", "string", "]", "client", ".", "MessageSet", ")", "error", "{", "n", ".", "l", ".", "Infoln", "(", "\"", "\"", ")", "\n\n", "s", ",", "err", ":=", "n", ".", "c", ".", "Conn...
// Start the adaptor as a source
[ "Start", "the", "adaptor", "as", "a", "source" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L439-L487
14,067
compose/transporter
pipeline/node.go
Stop
func (n *Node) Stop() { n.stop() for _, node := range n.children { node.Stop() } }
go
func (n *Node) Stop() { n.stop() for _, node := range n.children { node.Stop() } }
[ "func", "(", "n", "*", "Node", ")", "Stop", "(", ")", "{", "n", ".", "stop", "(", ")", "\n", "for", "_", ",", "node", ":=", "range", "n", ".", "children", "{", "node", ".", "Stop", "(", ")", "\n", "}", "\n", "}" ]
// Stop this node's adaptor, and sends a stop to each child of this node
[ "Stop", "this", "node", "s", "adaptor", "and", "sends", "a", "stop", "to", "each", "child", "of", "this", "node" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L622-L627
14,068
compose/transporter
pipeline/node.go
Validate
func (n *Node) Validate() bool { if n.parent == nil && len(n.children) == 0 { // the root node should have children return false } for _, child := range n.children { if !child.Validate() { return false } } return true }
go
func (n *Node) Validate() bool { if n.parent == nil && len(n.children) == 0 { // the root node should have children return false } for _, child := range n.children { if !child.Validate() { return false } } return true }
[ "func", "(", "n", "*", "Node", ")", "Validate", "(", ")", "bool", "{", "if", "n", ".", "parent", "==", "nil", "&&", "len", "(", "n", ".", "children", ")", "==", "0", "{", "// the root node should have children", "return", "false", "\n", "}", "\n\n", ...
// Validate ensures that the node tree conforms to a proper structure. // Node trees must have at least one source, and one sink. // dangling transformers are forbidden. Validate only knows about default adaptors // in the adaptor package, it can't validate any custom adaptors
[ "Validate", "ensures", "that", "the", "node", "tree", "conforms", "to", "a", "proper", "structure", ".", "Node", "trees", "must", "have", "at", "least", "one", "source", "and", "one", "sink", ".", "dangling", "transformers", "are", "forbidden", ".", "Validat...
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L658-L669
14,069
compose/transporter
pipeline/node.go
Endpoints
func (n *Node) Endpoints() map[string]string { m := map[string]string{n.Name: n.Type} for _, child := range n.children { childMap := child.Endpoints() for k, v := range childMap { m[k] = v } } return m }
go
func (n *Node) Endpoints() map[string]string { m := map[string]string{n.Name: n.Type} for _, child := range n.children { childMap := child.Endpoints() for k, v := range childMap { m[k] = v } } return m }
[ "func", "(", "n", "*", "Node", ")", "Endpoints", "(", ")", "map", "[", "string", "]", "string", "{", "m", ":=", "map", "[", "string", "]", "string", "{", "n", ".", "Name", ":", "n", ".", "Type", "}", "\n", "for", "_", ",", "child", ":=", "ran...
// Endpoints recurses down the node tree and accumulates a map associating node name with node type // this is primarily used with the boot event
[ "Endpoints", "recurses", "down", "the", "node", "tree", "and", "accumulates", "a", "map", "associating", "node", "name", "with", "node", "type", "this", "is", "primarily", "used", "with", "the", "boot", "event" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/pipeline/node.go#L673-L682
14,070
compose/transporter
adaptor/rethinkdb/client.go
WithURI
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { _, err := url.Parse(c.uri) if err != nil { return client.InvalidURIError{URI: uri, Err: err.Error()} } c.uri = uri return nil } }
go
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { _, err := url.Parse(c.uri) if err != nil { return client.InvalidURIError{URI: uri, Err: err.Error()} } c.uri = uri return nil } }
[ "func", "WithURI", "(", "uri", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "_", ",", "err", ":=", "url", ".", "Parse", "(", "c", ".", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// WithURI defines the full connection string of the RethinkDB database.
[ "WithURI", "defines", "the", "full", "connection", "string", "of", "the", "RethinkDB", "database", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rethinkdb/client.go#L92-L101
14,071
compose/transporter
adaptor/rethinkdb/client.go
WithSessionTimeout
func WithSessionTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.sessionTimeout = DefaultTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.sessionTimeout = t return nil } }
go
func WithSessionTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.sessionTimeout = DefaultTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.sessionTimeout = t return nil } }
[ "func", "WithSessionTimeout", "(", "timeout", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "timeout", "==", "\"", "\"", "{", "c", ".", "sessionTimeout", "=", "DefaultTimeout", "\n", "return", "...
// WithSessionTimeout overrides the DefaultTimeout and should be parseable by time.ParseDuration
[ "WithSessionTimeout", "overrides", "the", "DefaultTimeout", "and", "should", "be", "parseable", "by", "time", ".", "ParseDuration" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rethinkdb/client.go#L104-L118
14,072
compose/transporter
adaptor/rethinkdb/client.go
WithWriteTimeout
func WithWriteTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.writeTimeout = DefaultTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.writeTimeout = t return nil } }
go
func WithWriteTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.writeTimeout = DefaultTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.writeTimeout = t return nil } }
[ "func", "WithWriteTimeout", "(", "timeout", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "timeout", "==", "\"", "\"", "{", "c", ".", "writeTimeout", "=", "DefaultTimeout", "\n", "return", "nil"...
// WithWriteTimeout overrides the DefaultTimeout and should be parseable by time.ParseDuration
[ "WithWriteTimeout", "overrides", "the", "DefaultTimeout", "and", "should", "be", "parseable", "by", "time", ".", "ParseDuration" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rethinkdb/client.go#L121-L135
14,073
compose/transporter
adaptor/rethinkdb/client.go
WithReadTimeout
func WithReadTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.readTimeout = DefaultTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.readTimeout = t return nil } }
go
func WithReadTimeout(timeout string) ClientOptionFunc { return func(c *Client) error { if timeout == "" { c.readTimeout = DefaultTimeout return nil } t, err := time.ParseDuration(timeout) if err != nil { return client.InvalidTimeoutError{Timeout: timeout} } c.readTimeout = t return nil } }
[ "func", "WithReadTimeout", "(", "timeout", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "timeout", "==", "\"", "\"", "{", "c", ".", "readTimeout", "=", "DefaultTimeout", "\n", "return", "nil", ...
// WithReadTimeout overrides the DefaultTimeout and should be parseable by time.ParseDuration
[ "WithReadTimeout", "overrides", "the", "DefaultTimeout", "and", "should", "be", "parseable", "by", "time", ".", "ParseDuration" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rethinkdb/client.go#L138-L152
14,074
compose/transporter
adaptor/rethinkdb/client.go
Close
func (c *Client) Close() { if c.session != nil { c.session.Close(r.CloseOpts{NoReplyWait: false}) } }
go
func (c *Client) Close() { if c.session != nil { c.session.Close(r.CloseOpts{NoReplyWait: false}) } }
[ "func", "(", "c", "*", "Client", ")", "Close", "(", ")", "{", "if", "c", ".", "session", "!=", "nil", "{", "c", ".", "session", ".", "Close", "(", "r", ".", "CloseOpts", "{", "NoReplyWait", ":", "false", "}", ")", "\n", "}", "\n", "}" ]
// Close fulfills the Closer interface and takes care of cleaning up the rethink.Session
[ "Close", "fulfills", "the", "Closer", "interface", "and", "takes", "care", "of", "cleaning", "up", "the", "rethink", ".", "Session" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rethinkdb/client.go#L206-L210
14,075
compose/transporter
message/message.go
From
func From(op ops.Op, namespace string, d data.Data) Msg { return &Base{ Operation: op, TS: time.Now().Unix(), NS: namespace, MapData: d, confirm: nil, } }
go
func From(op ops.Op, namespace string, d data.Data) Msg { return &Base{ Operation: op, TS: time.Now().Unix(), NS: namespace, MapData: d, confirm: nil, } }
[ "func", "From", "(", "op", "ops", ".", "Op", ",", "namespace", "string", ",", "d", "data", ".", "Data", ")", "Msg", "{", "return", "&", "Base", "{", "Operation", ":", "op", ",", "TS", ":", "time", ".", "Now", "(", ")", ".", "Unix", "(", ")", ...
// From builds a message.Msg specific to an elasticsearch document
[ "From", "builds", "a", "message", ".", "Msg", "specific", "to", "an", "elasticsearch", "document" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/message/message.go#L33-L41
14,076
compose/transporter
message/message.go
WithConfirms
func WithConfirms(confirm chan struct{}, msg Msg) Msg { switch m := msg.(type) { case *Base: m.confirm = confirm } return msg }
go
func WithConfirms(confirm chan struct{}, msg Msg) Msg { switch m := msg.(type) { case *Base: m.confirm = confirm } return msg }
[ "func", "WithConfirms", "(", "confirm", "chan", "struct", "{", "}", ",", "msg", "Msg", ")", "Msg", "{", "switch", "m", ":=", "msg", ".", "(", "type", ")", "{", "case", "*", "Base", ":", "m", ".", "confirm", "=", "confirm", "\n", "}", "\n", "retur...
// WithConfirms attaches a channel to be able to acknowledge message processing.
[ "WithConfirms", "attaches", "a", "channel", "to", "be", "able", "to", "acknowledge", "message", "processing", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/message/message.go#L44-L50
14,077
compose/transporter
message/message.go
ID
func (m *Base) ID() string { if _, ok := m.MapData["_id"]; !ok { return "" } switch id := m.MapData["_id"].(type) { case string: return id case bson.ObjectId: return id.Hex() default: return fmt.Sprintf("%v", id) } }
go
func (m *Base) ID() string { if _, ok := m.MapData["_id"]; !ok { return "" } switch id := m.MapData["_id"].(type) { case string: return id case bson.ObjectId: return id.Hex() default: return fmt.Sprintf("%v", id) } }
[ "func", "(", "m", "*", "Base", ")", "ID", "(", ")", "string", "{", "if", "_", ",", "ok", ":=", "m", ".", "MapData", "[", "\"", "\"", "]", ";", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "switch", "id", ":=", "m", ".", "MapData",...
// ID will attempt to convert the _id field into a string representation
[ "ID", "will", "attempt", "to", "convert", "the", "_id", "field", "into", "a", "string", "representation" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/message/message.go#L90-L102
14,078
compose/transporter
adaptor/rethinkdb/writer.go
prepareDocument
func prepareDocument(msg message.Msg) map[string]interface{} { if _, ok := msg.Data()["id"]; ok { return msg.Data() } if _, ok := msg.Data()["_id"]; ok { msg.Data().Set("id", msg.ID()) msg.Data().Delete("_id") } return msg.Data() }
go
func prepareDocument(msg message.Msg) map[string]interface{} { if _, ok := msg.Data()["id"]; ok { return msg.Data() } if _, ok := msg.Data()["_id"]; ok { msg.Data().Set("id", msg.ID()) msg.Data().Delete("_id") } return msg.Data() }
[ "func", "prepareDocument", "(", "msg", "message", ".", "Msg", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "if", "_", ",", "ok", ":=", "msg", ".", "Data", "(", ")", "[", "\"", "\"", "]", ";", "ok", "{", "return", "msg", ".", "Dat...
// prepareDocument checks for an `_id` field and moves it to `id`.
[ "prepareDocument", "checks", "for", "an", "_id", "field", "and", "moves", "it", "to", "id", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rethinkdb/writer.go#L96-L106
14,079
compose/transporter
adaptor/rethinkdb/writer.go
handleResponse
func handleResponse(resp *r.WriteResponse, confirms chan struct{}) error { if resp.Errors != 0 { if !strings.Contains(resp.FirstError, "Duplicate primary key") { // we don't care about this error return fmt.Errorf("%s\n%s", "problem inserting docs", resp.FirstError) } } if confirms != nil { confirms <- struct{}{} } return nil }
go
func handleResponse(resp *r.WriteResponse, confirms chan struct{}) error { if resp.Errors != 0 { if !strings.Contains(resp.FirstError, "Duplicate primary key") { // we don't care about this error return fmt.Errorf("%s\n%s", "problem inserting docs", resp.FirstError) } } if confirms != nil { confirms <- struct{}{} } return nil }
[ "func", "handleResponse", "(", "resp", "*", "r", ".", "WriteResponse", ",", "confirms", "chan", "struct", "{", "}", ")", "error", "{", "if", "resp", ".", "Errors", "!=", "0", "{", "if", "!", "strings", ".", "Contains", "(", "resp", ".", "FirstError", ...
// handleresponse takes the rethink response and turn it into something we can consume elsewhere
[ "handleresponse", "takes", "the", "rethink", "response", "and", "turn", "it", "into", "something", "we", "can", "consume", "elsewhere" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/rethinkdb/writer.go#L156-L166
14,080
compose/transporter
events/emitter.go
NewEmitter
func NewEmitter(listen chan Event, emit EmitFunc) Emitter { return &emitter{ listenChan: listen, emit: emit, stop: make(chan struct{}), started: false, } }
go
func NewEmitter(listen chan Event, emit EmitFunc) Emitter { return &emitter{ listenChan: listen, emit: emit, stop: make(chan struct{}), started: false, } }
[ "func", "NewEmitter", "(", "listen", "chan", "Event", ",", "emit", "EmitFunc", ")", "Emitter", "{", "return", "&", "emitter", "{", "listenChan", ":", "listen", ",", "emit", ":", "emit", ",", "stop", ":", "make", "(", "chan", "struct", "{", "}", ")", ...
// NewEmitter creates a new emitter that will listen on the listen channel and use the emit EmitFunc // to process events
[ "NewEmitter", "creates", "a", "new", "emitter", "that", "will", "listen", "on", "the", "listen", "channel", "and", "use", "the", "emit", "EmitFunc", "to", "process", "events" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/events/emitter.go#L36-L43
14,081
compose/transporter
events/emitter.go
Start
func (e *emitter) Start() { if !e.started { e.started = true e.wg.Add(1) go e.startEventListener(&e.wg) } }
go
func (e *emitter) Start() { if !e.started { e.started = true e.wg.Add(1) go e.startEventListener(&e.wg) } }
[ "func", "(", "e", "*", "emitter", ")", "Start", "(", ")", "{", "if", "!", "e", ".", "started", "{", "e", ".", "started", "=", "true", "\n", "e", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "e", ".", "startEventListener", "(", "&", "e", ...
// Start the emitter
[ "Start", "the", "emitter" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/events/emitter.go#L46-L52
14,082
compose/transporter
events/emitter.go
Stop
func (e *emitter) Stop() { close(e.stop) e.wg.Wait() e.started = false }
go
func (e *emitter) Stop() { close(e.stop) e.wg.Wait() e.started = false }
[ "func", "(", "e", "*", "emitter", ")", "Stop", "(", ")", "{", "close", "(", "e", ".", "stop", ")", "\n", "e", ".", "wg", ".", "Wait", "(", ")", "\n", "e", ".", "started", "=", "false", "\n", "}" ]
// Stop sends a stop signal and waits for the inflight posts to complete before exiting
[ "Stop", "sends", "a", "stop", "signal", "and", "waits", "for", "the", "inflight", "posts", "to", "complete", "before", "exiting" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/events/emitter.go#L55-L59
14,083
compose/transporter
events/emitter.go
HTTPPostEmitter
func HTTPPostEmitter(uri, key, pid string) EmitFunc { return EmitFunc(func(event Event) error { ba, err := event.Emit() if err != nil { return err } req, err := http.NewRequest("POST", uri, bytes.NewBuffer(ba)) if err != nil { return err } req.Header.Set("Content-Type", "application/json") if len(pid) > 0 && len(key) > 0 { req.SetBasicAuth(pid, key) } resp, err := http.DefaultClient.Do(req) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != 200 && resp.StatusCode != 201 { return BadStatusError{resp.StatusCode} } return nil }) }
go
func HTTPPostEmitter(uri, key, pid string) EmitFunc { return EmitFunc(func(event Event) error { ba, err := event.Emit() if err != nil { return err } req, err := http.NewRequest("POST", uri, bytes.NewBuffer(ba)) if err != nil { return err } req.Header.Set("Content-Type", "application/json") if len(pid) > 0 && len(key) > 0 { req.SetBasicAuth(pid, key) } resp, err := http.DefaultClient.Do(req) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != 200 && resp.StatusCode != 201 { return BadStatusError{resp.StatusCode} } return nil }) }
[ "func", "HTTPPostEmitter", "(", "uri", ",", "key", ",", "pid", "string", ")", "EmitFunc", "{", "return", "EmitFunc", "(", "func", "(", "event", "Event", ")", "error", "{", "ba", ",", "err", ":=", "event", ".", "Emit", "(", ")", "\n", "if", "err", "...
// HTTPPostEmitter listens on the event channel and posts the events to an http server // Events are serialized into json, and sent via a POST request to the given Uri // http errors are logged as warnings to the console, and won't stop the Emitter
[ "HTTPPostEmitter", "listens", "on", "the", "event", "channel", "and", "posts", "the", "events", "to", "an", "http", "server", "Events", "are", "serialized", "into", "json", "and", "sent", "via", "a", "POST", "request", "to", "the", "given", "Uri", "http", ...
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/events/emitter.go#L91-L117
14,084
compose/transporter
adaptor/registry.go
GetAdaptor
func GetAdaptor(name string, conf Config) (Adaptor, error) { creator, ok := adaptors[name] if ok { a := creator() err := conf.Construct(a) return a, err } return nil, ErrNotFound{name} }
go
func GetAdaptor(name string, conf Config) (Adaptor, error) { creator, ok := adaptors[name] if ok { a := creator() err := conf.Construct(a) return a, err } return nil, ErrNotFound{name} }
[ "func", "GetAdaptor", "(", "name", "string", ",", "conf", "Config", ")", "(", "Adaptor", ",", "error", ")", "{", "creator", ",", "ok", ":=", "adaptors", "[", "name", "]", "\n", "if", "ok", "{", "a", ":=", "creator", "(", ")", "\n", "err", ":=", "...
// GetAdaptor looks up an adaptor by name and then init's it with the provided Config. // returns ErrNotFound if the provided name was not registered.
[ "GetAdaptor", "looks", "up", "an", "adaptor", "by", "name", "and", "then", "init", "s", "it", "with", "the", "provided", "Config", ".", "returns", "ErrNotFound", "if", "the", "provided", "name", "was", "not", "registered", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/registry.go#L16-L24
14,085
compose/transporter
adaptor/registry.go
RegisteredAdaptors
func RegisteredAdaptors() []string { all := make([]string, 0) for i := range adaptors { all = append(all, i) } return all }
go
func RegisteredAdaptors() []string { all := make([]string, 0) for i := range adaptors { all = append(all, i) } return all }
[ "func", "RegisteredAdaptors", "(", ")", "[", "]", "string", "{", "all", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "for", "i", ":=", "range", "adaptors", "{", "all", "=", "append", "(", "all", ",", "i", ")", "\n", "}", "\n", "r...
// RegisteredAdaptors returns a slice of the names of every adaptor registered.
[ "RegisteredAdaptors", "returns", "a", "slice", "of", "the", "names", "of", "every", "adaptor", "registered", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/registry.go#L27-L33
14,086
compose/transporter
adaptor/registry.go
Adaptors
func Adaptors() map[string]Adaptor { all := make(map[string]Adaptor) for name, c := range adaptors { a := c() all[name] = a } return all }
go
func Adaptors() map[string]Adaptor { all := make(map[string]Adaptor) for name, c := range adaptors { a := c() all[name] = a } return all }
[ "func", "Adaptors", "(", ")", "map", "[", "string", "]", "Adaptor", "{", "all", ":=", "make", "(", "map", "[", "string", "]", "Adaptor", ")", "\n", "for", "name", ",", "c", ":=", "range", "adaptors", "{", "a", ":=", "c", "(", ")", "\n", "all", ...
// Adaptors returns an non-initialized adaptor and is best used for doing assertions to see if // the Adaptor supports other interfaces
[ "Adaptors", "returns", "an", "non", "-", "initialized", "adaptor", "and", "is", "best", "used", "for", "doing", "assertions", "to", "see", "if", "the", "Adaptor", "supports", "other", "interfaces" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/registry.go#L37-L44
14,087
compose/transporter
commitlog/segment.go
NewSegment
func NewSegment(path, format string, baseOffset int64, maxBytes int64) (*Segment, error) { logPath := filepath.Join(path, fmt.Sprintf(format, baseOffset)) log, err := os.OpenFile(logPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { return nil, err } s := &Segment{ log: log, path: logPath, writer: log, reader: log, maxBytes: maxBytes, BaseOffset: baseOffset, NextOffset: baseOffset, } err = s.init() if err == io.EOF { return s, nil } return s, err }
go
func NewSegment(path, format string, baseOffset int64, maxBytes int64) (*Segment, error) { logPath := filepath.Join(path, fmt.Sprintf(format, baseOffset)) log, err := os.OpenFile(logPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { return nil, err } s := &Segment{ log: log, path: logPath, writer: log, reader: log, maxBytes: maxBytes, BaseOffset: baseOffset, NextOffset: baseOffset, } err = s.init() if err == io.EOF { return s, nil } return s, err }
[ "func", "NewSegment", "(", "path", ",", "format", "string", ",", "baseOffset", "int64", ",", "maxBytes", "int64", ")", "(", "*", "Segment", ",", "error", ")", "{", "logPath", ":=", "filepath", ".", "Join", "(", "path", ",", "fmt", ".", "Sprintf", "(", ...
// NewSegment creates a new instance of Segment with the provided parameters // and initializes its NextOffset and Position should the file be non-empty.
[ "NewSegment", "creates", "a", "new", "instance", "of", "Segment", "with", "the", "provided", "parameters", "and", "initializes", "its", "NextOffset", "and", "Position", "should", "the", "file", "be", "non", "-", "empty", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/segment.go#L48-L71
14,088
compose/transporter
commitlog/segment.go
IsFull
func (s *Segment) IsFull() bool { s.Lock() defer s.Unlock() return s.Position >= s.maxBytes }
go
func (s *Segment) IsFull() bool { s.Lock() defer s.Unlock() return s.Position >= s.maxBytes }
[ "func", "(", "s", "*", "Segment", ")", "IsFull", "(", ")", "bool", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "Position", ">=", "s", ".", "maxBytes", "\n", "}" ]
// IsFull determines whether the current size of the segment is greater than or equal to the // maxBytes configured.
[ "IsFull", "determines", "whether", "the", "current", "size", "of", "the", "segment", "is", "greater", "than", "or", "equal", "to", "the", "maxBytes", "configured", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/segment.go#L125-L129
14,089
compose/transporter
commitlog/segment.go
ReadAt
func (s *Segment) ReadAt(p []byte, off int64) (n int, err error) { s.Lock() defer s.Unlock() return s.log.ReadAt(p, off) }
go
func (s *Segment) ReadAt(p []byte, off int64) (n int, err error) { s.Lock() defer s.Unlock() return s.log.ReadAt(p, off) }
[ "func", "(", "s", "*", "Segment", ")", "ReadAt", "(", "p", "[", "]", "byte", ",", "off", "int64", ")", "(", "n", "int", ",", "err", "error", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "return", ...
// ReadAt calls ReadAt on the underlying log.
[ "ReadAt", "calls", "ReadAt", "on", "the", "underlying", "log", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/segment.go#L144-L148
14,090
compose/transporter
commitlog/segment.go
FindOffsetPosition
func (s *Segment) FindOffsetPosition(offset uint64) (int64, error) { if _, err := s.log.Seek(0, 0); err != nil { return 0, err } var position int64 for { b := new(bytes.Buffer) // get offset and size _, err := io.CopyN(b, s.log, 8) if err != nil { return position, ErrOffsetNotFound } o := encoding.Uint64(b.Bytes()[offsetPos:8]) _, err = io.CopyN(b, s.log, 4) if err != nil { return position, ErrOffsetNotFound } size := int64(encoding.Uint32(b.Bytes()[sizePos:12])) if offset == o { log.With("position", position).With("offset", o).Infoln("found offset position") return position, nil } position += size + logEntryHeaderLen // add 9 to size to include the timestamp and attribute _, err = s.log.Seek(size+9, 1) if err != nil { return 0, err } } }
go
func (s *Segment) FindOffsetPosition(offset uint64) (int64, error) { if _, err := s.log.Seek(0, 0); err != nil { return 0, err } var position int64 for { b := new(bytes.Buffer) // get offset and size _, err := io.CopyN(b, s.log, 8) if err != nil { return position, ErrOffsetNotFound } o := encoding.Uint64(b.Bytes()[offsetPos:8]) _, err = io.CopyN(b, s.log, 4) if err != nil { return position, ErrOffsetNotFound } size := int64(encoding.Uint32(b.Bytes()[sizePos:12])) if offset == o { log.With("position", position).With("offset", o).Infoln("found offset position") return position, nil } position += size + logEntryHeaderLen // add 9 to size to include the timestamp and attribute _, err = s.log.Seek(size+9, 1) if err != nil { return 0, err } } }
[ "func", "(", "s", "*", "Segment", ")", "FindOffsetPosition", "(", "offset", "uint64", ")", "(", "int64", ",", "error", ")", "{", "if", "_", ",", "err", ":=", "s", ".", "log", ".", "Seek", "(", "0", ",", "0", ")", ";", "err", "!=", "nil", "{", ...
// FindOffsetPosition attempts to find the provided offset position in the // Segment.
[ "FindOffsetPosition", "attempts", "to", "find", "the", "provided", "offset", "position", "in", "the", "Segment", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/segment.go#L172-L205
14,091
compose/transporter
offset/offset.go
Bytes
func (o Offset) Bytes() []byte { valBytes := make([]byte, 8) encoding.PutUint64(valBytes, o.LogOffset) l := commitlog.NewLogFromEntry(commitlog.LogEntry{ Key: []byte(o.Namespace), Value: valBytes, Timestamp: uint64(o.Timestamp), }) return l }
go
func (o Offset) Bytes() []byte { valBytes := make([]byte, 8) encoding.PutUint64(valBytes, o.LogOffset) l := commitlog.NewLogFromEntry(commitlog.LogEntry{ Key: []byte(o.Namespace), Value: valBytes, Timestamp: uint64(o.Timestamp), }) return l }
[ "func", "(", "o", "Offset", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "valBytes", ":=", "make", "(", "[", "]", "byte", ",", "8", ")", "\n", "encoding", ".", "PutUint64", "(", "valBytes", ",", "o", ".", "LogOffset", ")", "\n\n", "l", ":=", ...
// Bytes converts Offset to the binary format to be stored on disk.
[ "Bytes", "converts", "Offset", "to", "the", "binary", "format", "to", "be", "stored", "on", "disk", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/offset/offset.go#L28-L38
14,092
compose/transporter
adaptor/postgres/client.go
WithURI
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { _, err := url.Parse(uri) c.uri = uri return err } }
go
func WithURI(uri string) ClientOptionFunc { return func(c *Client) error { _, err := url.Parse(uri) c.uri = uri return err } }
[ "func", "WithURI", "(", "uri", "string", ")", "ClientOptionFunc", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "_", ",", "err", ":=", "url", ".", "Parse", "(", "uri", ")", "\n", "c", ".", "uri", "=", "uri", "\n", "return", "...
// WithURI defines the full connection string for the Postgres connection
[ "WithURI", "defines", "the", "full", "connection", "string", "for", "the", "Postgres", "connection" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/postgres/client.go#L51-L57
14,093
compose/transporter
adaptor/postgres/client.go
Connect
func (c *Client) Connect() (client.Session, error) { if c.pqSession == nil { // there's really no way for this to error because we know the driver we're passing is // available. c.pqSession, _ = sql.Open("postgres", c.uri) uri, _ := url.Parse(c.uri) if uri.Path != "" { c.db = uri.Path[1:] } } err := c.pqSession.Ping() return &Session{c.pqSession, c.db}, err }
go
func (c *Client) Connect() (client.Session, error) { if c.pqSession == nil { // there's really no way for this to error because we know the driver we're passing is // available. c.pqSession, _ = sql.Open("postgres", c.uri) uri, _ := url.Parse(c.uri) if uri.Path != "" { c.db = uri.Path[1:] } } err := c.pqSession.Ping() return &Session{c.pqSession, c.db}, err }
[ "func", "(", "c", "*", "Client", ")", "Connect", "(", ")", "(", "client", ".", "Session", ",", "error", ")", "{", "if", "c", ".", "pqSession", "==", "nil", "{", "// there's really no way for this to error because we know the driver we're passing is", "// available."...
// Connect initializes the Postgres connection
[ "Connect", "initializes", "the", "Postgres", "connection" ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/adaptor/postgres/client.go#L67-L79
14,094
compose/transporter
commitlog/logentry.go
ModeOpToByte
func (le LogEntry) ModeOpToByte() byte { return byte(int(le.Mode) | (int(le.Op) << opShift)) }
go
func (le LogEntry) ModeOpToByte() byte { return byte(int(le.Mode) | (int(le.Op) << opShift)) }
[ "func", "(", "le", "LogEntry", ")", "ModeOpToByte", "(", ")", "byte", "{", "return", "byte", "(", "int", "(", "le", ".", "Mode", ")", "|", "(", "int", "(", "le", ".", "Op", ")", "<<", "opShift", ")", ")", "\n", "}" ]
// ModeOpToByte converts the Mode and Op values into a single byte by performing bitwise operations. // Mode is stored in bits 0 - 1 // Op is stored in bits 2 - 4 // bits 5 - 7 are currently unused
[ "ModeOpToByte", "converts", "the", "Mode", "and", "Op", "values", "into", "a", "single", "byte", "by", "performing", "bitwise", "operations", ".", "Mode", "is", "stored", "in", "bits", "0", "-", "1", "Op", "is", "stored", "in", "bits", "2", "-", "4", "...
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/logentry.go#L34-L36
14,095
compose/transporter
commitlog/logentry.go
ReadEntry
func ReadEntry(r io.Reader) (uint64, LogEntry, error) { header := make([]byte, logEntryHeaderLen) if _, err := r.Read(header); err != nil { return 0, LogEntry{}, err } k, v, err := readKeyValue(encoding.Uint32(header[sizePos:tsPos]), r) if err != nil { return 0, LogEntry{}, err } l := LogEntry{ Key: k, Value: v, Timestamp: encoding.Uint64(header[tsPos:attrPos]), Mode: modeFromBytes(header), Op: opFromBytes(header), } return encoding.Uint64(header[offsetPos:sizePos]), l, nil }
go
func ReadEntry(r io.Reader) (uint64, LogEntry, error) { header := make([]byte, logEntryHeaderLen) if _, err := r.Read(header); err != nil { return 0, LogEntry{}, err } k, v, err := readKeyValue(encoding.Uint32(header[sizePos:tsPos]), r) if err != nil { return 0, LogEntry{}, err } l := LogEntry{ Key: k, Value: v, Timestamp: encoding.Uint64(header[tsPos:attrPos]), Mode: modeFromBytes(header), Op: opFromBytes(header), } return encoding.Uint64(header[offsetPos:sizePos]), l, nil }
[ "func", "ReadEntry", "(", "r", "io", ".", "Reader", ")", "(", "uint64", ",", "LogEntry", ",", "error", ")", "{", "header", ":=", "make", "(", "[", "]", "byte", ",", "logEntryHeaderLen", ")", "\n", "if", "_", ",", "err", ":=", "r", ".", "Read", "(...
// ReadEntry takes an io.Reader and returns a LogEntry.
[ "ReadEntry", "takes", "an", "io", ".", "Reader", "and", "returns", "a", "LogEntry", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/logentry.go#L39-L56
14,096
compose/transporter
commitlog/logentry.go
readKeyValue
func readKeyValue(size uint32, r io.Reader) ([]byte, []byte, error) { kvBytes := make([]byte, size) if _, err := r.Read(kvBytes); err != nil { return nil, nil, err } keyLen := encoding.Uint32(kvBytes[0:4]) // we can grab the key from keyLen and the we know the value is stored // after the keyLen + 8 (4 byte size of key and value) return kvBytes[4 : keyLen+4], kvBytes[keyLen+8:], nil }
go
func readKeyValue(size uint32, r io.Reader) ([]byte, []byte, error) { kvBytes := make([]byte, size) if _, err := r.Read(kvBytes); err != nil { return nil, nil, err } keyLen := encoding.Uint32(kvBytes[0:4]) // we can grab the key from keyLen and the we know the value is stored // after the keyLen + 8 (4 byte size of key and value) return kvBytes[4 : keyLen+4], kvBytes[keyLen+8:], nil }
[ "func", "readKeyValue", "(", "size", "uint32", ",", "r", "io", ".", "Reader", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "error", ")", "{", "kvBytes", ":=", "make", "(", "[", "]", "byte", ",", "size", ")", "\n", "if", "_", ",", "...
// readKeyValue returns the key and value stored given the size and io.Reader.
[ "readKeyValue", "returns", "the", "key", "and", "value", "stored", "given", "the", "size", "and", "io", ".", "Reader", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/commitlog/logentry.go#L59-L68
14,097
compose/transporter
function/gojajs/goja.go
Apply
func (g *goja) Apply(msg message.Msg) (message.Msg, error) { if g.vm == nil { if err := g.initVM(); err != nil { return nil, err } } return g.transformOne(msg) }
go
func (g *goja) Apply(msg message.Msg) (message.Msg, error) { if g.vm == nil { if err := g.initVM(); err != nil { return nil, err } } return g.transformOne(msg) }
[ "func", "(", "g", "*", "goja", ")", "Apply", "(", "msg", "message", ".", "Msg", ")", "(", "message", ".", "Msg", ",", "error", ")", "{", "if", "g", ".", "vm", "==", "nil", "{", "if", "err", ":=", "g", ".", "initVM", "(", ")", ";", "err", "!...
// Apply fulfills the function.Function interface by transforming the incoming message with the configured // JavaScript function.
[ "Apply", "fulfills", "the", "function", ".", "Function", "interface", "by", "transforming", "the", "incoming", "message", "with", "the", "configured", "JavaScript", "function", "." ]
9e154e76b7d2977d9ac7756660779b512cace87f
https://github.com/compose/transporter/blob/9e154e76b7d2977d9ac7756660779b512cace87f/function/gojajs/goja.go#L53-L60
14,098
ktrysmt/go-bitbucket
user.go
Profile
func (u *User) Profile() (interface{}, error) { urlStr := GetApiBaseURL() + "/user/" return u.c.execute("GET", urlStr, "") }
go
func (u *User) Profile() (interface{}, error) { urlStr := GetApiBaseURL() + "/user/" return u.c.execute("GET", urlStr, "") }
[ "func", "(", "u", "*", "User", ")", "Profile", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "urlStr", ":=", "GetApiBaseURL", "(", ")", "+", "\"", "\"", "\n", "return", "u", ".", "c", ".", "execute", "(", "\"", "\"", ",", "urlSt...
// Profile is getting the user data
[ "Profile", "is", "getting", "the", "user", "data" ]
1f1c5e77687102cc8f6baa9f79276178be6f0ea3
https://github.com/ktrysmt/go-bitbucket/blob/1f1c5e77687102cc8f6baa9f79276178be6f0ea3/user.go#L9-L12
14,099
ktrysmt/go-bitbucket
user.go
Emails
func (u *User) Emails() (interface{}, error) { urlStr := GetApiBaseURL() + "/user/emails" return u.c.execute("GET", urlStr, "") }
go
func (u *User) Emails() (interface{}, error) { urlStr := GetApiBaseURL() + "/user/emails" return u.c.execute("GET", urlStr, "") }
[ "func", "(", "u", "*", "User", ")", "Emails", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "urlStr", ":=", "GetApiBaseURL", "(", ")", "+", "\"", "\"", "\n", "return", "u", ".", "c", ".", "execute", "(", "\"", "\"", ",", "urlStr...
// Emails is getting user's emails
[ "Emails", "is", "getting", "user", "s", "emails" ]
1f1c5e77687102cc8f6baa9f79276178be6f0ea3
https://github.com/ktrysmt/go-bitbucket/blob/1f1c5e77687102cc8f6baa9f79276178be6f0ea3/user.go#L15-L18