// Main should be invoked directly by main function. // It will only return if there was no error. If an error // was encountered it is printed to standard error and the // application exits with an exit code of 2. public static void Main(context.Context ctx, Application app, slice <@string> args) { var s = flag.NewFlagSet(app.Name(), flag.ExitOnError); s.Usage = () => { fmt.Fprint(s.Output(), app.ShortHelp()); fmt.Fprintf(s.Output(), "\n\nUsage: %v [flags] %v\n", app.Name(), app.Usage()); app.DetailedHelp(s); } ; { var err = Run(ctx, app, args); if (err != null) { fmt.Fprintf(s.Output(), "%s: %v\n", app.Name(), err); { commandLineError(_, printHelp) = err._ <commandLineError>(); if (printHelp) { s.Usage(); } } os.Exit(2L); } } }
// deliver is called to deliver an event to the supplied exporter. // it will fill in the time. private static context.Context deliver(context.Context ctx, Exporter exporter, Event ev) { // add the current time to the event ev.at = time.Now(); // hand the event off to the current exporter return(exporter(ctx, ev, ev)); }
// Start2 sends a span start event with the supplied label list to the exporter. // It also returns a function that will end the span, which should normally be // deferred. public static (context.Context, Action) Start2(context.Context ctx, @string name, label.Label t1, label.Label t2) { context.Context _p0 = default; Action _p0 = default; return(ExportPair(ctx, MakeEvent(new array <label.Label>(new label.Label[] { keys.Start.Of(name), t1, t2 }), null), MakeEvent(new array <label.Label>(new label.Label[] { keys.End.New() }), null))); }
private static labelMap labelValue(context.Context ctx) { ptr <labelMap> (labels, _) = ctx.Value(new labelContextKey())._ <ptr <labelMap> >(); if (labels == null) { return(labelMap(null)); } return(labels.val); }
public static ptr <Span> GetSpan(context.Context ctx) { var v = ctx.Value(spanContextKey); if (v == null) { return(_addr_null !); } return(v._ <ptr <Span> >()); }
// Export is called to deliver an event to the global exporter if set. public static context.Context Export(context.Context ctx, Event ev) { // get the global exporter and abort early if there is not one var exporterPtr = (Exporter.val)(atomic.LoadPointer(_addr_exporter)); if (exporterPtr == null) { return(ctx); } return(deliver(ctx, exporterPtr.val, ev)); }
public golistState(ref ptr <Config> cfg = default, context.Context ctx = default, sync.Once envOnce = default, error goEnvError = default, map <@string, @string> goEnv = default, sync.Once rootsOnce = default, error rootDirsError = default, map <@string, @string> rootDirs = default, map <@string, bool> vendorDirs = default) { this.cfg = cfg; this.ctx = ctx; this.envOnce = envOnce; this.goEnvError = goEnvError; this.goEnv = goEnv; this.rootsOnce = rootsOnce; this.rootDirsError = rootDirsError; this.rootDirs = rootDirs; this.vendorDirs = vendorDirs; }
// ExportPair is called to deliver a start event to the supplied exporter. // It also returns a function that will deliver the end event to the same // exporter. // It will fill in the time. public static (context.Context, Action) ExportPair(context.Context ctx, Event begin, Event end) { context.Context _p0 = default; Action _p0 = default; // get the global exporter and abort early if there is not one var exporterPtr = (Exporter.val)(atomic.LoadPointer(_addr_exporter)); if (exporterPtr == null) { return(ctx, () => { }); } ctx = deliver(ctx, exporterPtr.val, begin); return(ctx, () => { deliver(ctx, exporterPtr.val, end); }); }
// socket returns a network file descriptor that is ready for // asynchronous I/O using the network poller. private static (ptr <netFD>, error) socket(context.Context ctx, @string net, long family, long sotype, long proto, bool ipv6only, sockaddr laddr, sockaddr raddr, Func <@string, @string, syscall.RawConn, error> ctrlFn) { ptr <netFD> _p0 = default !;
public http2stream(ref ptr <http2serverConn> sc = default, uint id = default, ref ptr <http2pipe> body = default, http2closeWaiter cw = default, context.Context ctx = default, Action cancelCtx = default, long bodyBytes = default, long declBodyBytes = default, http2flow flow = default, http2flow inflow = default, http2streamState state = default, bool resetQueued = default, bool gotTrailerHeader = default, bool wroteHeaders = default, ref ptr <time.Timer> writeDeadline = default, Header trailer = default, Header reqTrailer = default) { this.sc = sc; this.id = id; this.body = body; this.cw = cw; this.ctx = ctx; this.cancelCtx = cancelCtx; this.bodyBytes = bodyBytes; this.declBodyBytes = declBodyBytes; this.flow = flow; this.inflow = inflow; this.state = state; this.resetQueued = resetQueued; this.gotTrailerHeader = gotTrailerHeader; this.wroteHeaders = wroteHeaders; this.writeDeadline = writeDeadline; this.trailer = trailer; this.reqTrailer = reqTrailer; }
// ReadOnly runs f in a read-only transaction. private static error ReadOnly(this ptr <Mem> _addr_m, context.Context ctx, Func <context.Context, Transaction, error> f) => func((defer, _, __) =>
private static (slice <@string>, error) query(context.Context ctx, @string filename, @string query, long bufSize) => func((defer, _, __) =>
private static context.Context ProcessEvent(this ptr <logWriter> _addr_w, context.Context ctx, core.Event ev, label.Map lm) => func((defer, _, __) =>
// Run calls Runner.RunRaw, serializing requests if they fight over // go.mod changes. private static (ptr <bytes.Buffer>, error) Run(this ptr <Runner> _addr_runner, context.Context ctx, Invocation inv) { ptr <bytes.Buffer> _p0 = default !;
private static (net.Addr, error) connect(this ptr <socksDialer> _addr_d, context.Context ctx, net.Conn c, @string address) => func((defer, _, __) =>
private static (driver.Stmt, error) ctxDriverPrepare(context.Context ctx, driver.Conn ci, @string query) { driver.Stmt _p0 = default; error _p0 = default !;
public static (types.Sizes, error) GetSizes(context.Context ctx, slice <@string> buildFlags, slice <@string> env, ptr <gocommand.Runner> _addr_gocmdRunner, @string dir) { types.Sizes _p0 = default; error _p0 = default !;
public timeoutHandler(Handler handler = default, @string body = default, time.Duration dt = default, context.Context testContext = default) { this.handler = handler; this.body = body; this.dt = dt; this.testContext = testContext; }
// NewTask creates a task instance with the type taskType and returns // it along with a Context that carries the task. // If the input context contains a task, the new task is its subtask. // // The taskType is used to classify task instances. Analysis tools // like the Go execution tracer may assume there are only a bounded // number of unique task types in the system. // // The returned end function is used to mark the task's end. // The trace tool measures task latency as the time between task creation // and when the end function is called, and provides the latency // distribution per task type. // If the end function is called multiple times, only the first // call is used in the latency measurement. // // ctx, task := trace.NewTask(ctx, "awesomeTask") // trace.WithRegion(ctx, "preparation", prepWork) // // preparation of the task // go func() { // continue processing the task in a separate goroutine. // defer task.End() // trace.WithRegion(ctx, "remainingWork", remainingWork) // }() public static (context.Context, ptr <Task>) NewTask(context.Context pctx, @string taskType) { context.Context ctx = default; ptr <Task> task = default !;
// Run is the inner loop for Main; invoked by Main, recursively by // Run, and by various tests. It runs the application and returns an // error. public static error Run(context.Context ctx, Application app, slice <@string> args) => func((defer, _, __) =>
public Server(ref ptr <FooServer> FooServer = default, @string user = default, context.Context ctx = default) { this.FooServer = FooServer; this.user = user; this.ctx = ctx; }
// ContextClientTrace returns the ClientTrace associated with the // provided context. If none, it returns nil. public static ptr <ClientTrace> ContextClientTrace(context.Context ctx) { ptr <ClientTrace> (trace, _) = ctx.Value(new clientEventContextKey())._ <ptr <ClientTrace> >(); return(_addr_trace !); }
public Tx(ref ptr <DB> db = default, sync.RWMutex closemu = default, ref ptr <driverConn> dc = default, driver.Tx txi = default, Action <error> releaseConn = default, int done = default, bool keepConnOnRollback = default, Action cancel = default, context.Context ctx = default) { this.db = db; this.closemu = closemu; this.dc = dc; this.txi = txi; this.releaseConn = releaseConn; this.done = done; this.keepConnOnRollback = keepConnOnRollback; this.cancel = cancel; this.ctx = ctx; }
private static (long, error) lookupProtocol(context.Context ctx, @string name) { long proto = default; error err = default !;
// WithClientTrace returns a new context based on the provided parent // ctx. HTTP client requests made with the returned context will use // the provided trace hooks, in addition to any previous hooks // registered with ctx. Any hooks defined in the provided trace will // be called first. public static context.Context WithClientTrace(context.Context ctx, ptr <ClientTrace> _addr_trace) => func((_, panic, __) =>
public http2serverConn(ref ptr <http2Server> srv = default, ref ptr <Server> hs = default, net.Conn conn = default, ref ptr <http2bufferedWriter> bw = default, Handler handler = default, context.Context baseCtx = default, ref ptr <http2Framer> framer = default, channel <object> doneServing = default, channel <http2readFrameResult> readFrameCh = default, channel <http2FrameWriteRequest> wantWriteFrameCh = default, channel <http2frameWriteResult> wroteFrameCh = default, channel <http2bodyReadMsg> bodyReadCh = default, channel <object> serveMsgCh = default, http2flow flow = default, http2flow inflow = default, ref ptr <tls.ConnectionState> tlsState = default, @string remoteAddrStr = default, http2WriteScheduler writeSched = default, http2goroutineLock serveG = default, bool pushEnabled = default, bool sawFirstSettings = default, bool needToSendSettingsAck = default, long unackedSettings = default, long queuedControlFrames = default, uint clientMaxStreams = default, uint advMaxStreams = default, uint curClientStreams = default, uint curPushedStreams = default, uint maxClientStreamID = default, uint maxPushPromiseID = default, map <uint, ptr <http2stream> > streams = default, int initialStreamSendWindowSize = default, int maxFrameSize = default, uint headerTableSize = default, uint peerMaxHeaderListSize = default, map <@string, @string> canonHeader = default, bool writingFrame = default, bool writingFrameAsync = default, bool needsFrameFlush = default, bool inGoAway = default, bool inFrameScheduleLoop = default, bool needToSendGoAway = default, http2ErrCode goAwayCode = default, ref ptr <time.Timer> shutdownTimer = default, ref ptr <time.Timer> idleTimer = default, bytes.Buffer headerWriteBuf = default, ref ptr <hpack.Encoder> hpackEncoder = default, sync.Once shutdownOnce = default) { this.srv = srv; this.hs = hs; this.conn = conn; this.bw = bw; this.handler = handler; this.baseCtx = baseCtx; this.framer = framer; this.doneServing = doneServing; this.readFrameCh = readFrameCh; this.wantWriteFrameCh = wantWriteFrameCh; this.wroteFrameCh = wroteFrameCh; this.bodyReadCh = bodyReadCh; this.serveMsgCh = serveMsgCh; this.flow = flow; this.inflow = inflow; this.tlsState = tlsState; this.remoteAddrStr = remoteAddrStr; this.writeSched = writeSched; this.serveG = serveG; this.pushEnabled = pushEnabled; this.sawFirstSettings = sawFirstSettings; this.needToSendSettingsAck = needToSendSettingsAck; this.unackedSettings = unackedSettings; this.queuedControlFrames = queuedControlFrames; this.clientMaxStreams = clientMaxStreams; this.advMaxStreams = advMaxStreams; this.curClientStreams = curClientStreams; this.curPushedStreams = curPushedStreams; this.maxClientStreamID = maxClientStreamID; this.maxPushPromiseID = maxPushPromiseID; this.streams = streams; this.initialStreamSendWindowSize = initialStreamSendWindowSize; this.maxFrameSize = maxFrameSize; this.headerTableSize = headerTableSize; this.peerMaxHeaderListSize = peerMaxHeaderListSize; this.canonHeader = canonHeader; this.writingFrame = writingFrame; this.writingFrameAsync = writingFrameAsync; this.needsFrameFlush = needsFrameFlush; this.inGoAway = inGoAway; this.inFrameScheduleLoop = inFrameScheduleLoop; this.needToSendGoAway = needToSendGoAway; this.goAwayCode = goAwayCode; this.shutdownTimer = shutdownTimer; this.idleTimer = idleTimer; this.headerWriteBuf = headerWriteBuf; this.hpackEncoder = hpackEncoder; this.shutdownOnce = shutdownOnce; }
public onlyValuesCtx(context.Context Context = default, context.Context lookupValues = default) { this.Context = Context; this.lookupValues = lookupValues; }
// Log2 takes a message and two labels and delivers a log event to the exporter. // It is a customized version of Print that is faster and does no allocation. public static void Log2(context.Context ctx, @string message, label.Label t1, label.Label t2) { Export(ctx, MakeEvent(new array <label.Label>(new label.Label[] { keys.Msg.Of(message), t1, t2 }), null)); }
// TestStorage tests a Storage implementation. public static void TestStorage(ptr <testing.T> _addr_t, context.Context ctx, Storage storage) { ref testing.T t = ref _addr_t.val;
// Metric2 sends a label event to the exporter with the supplied labels. public static context.Context Metric2(context.Context ctx, label.Label t1, label.Label t2) { return(Export(ctx, MakeEvent(new array <label.Label>(new label.Label[] { keys.Metric.New(), t1, t2 }), null))); }