Esempio n. 1
0
File: tool.cs Progetto: zjmit/go2cs
                        // 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);
                                }
                            }
                        }
Esempio n. 2
0
 // 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));
 }
Esempio n. 3
0
File: fast.cs Progetto: zjmit/go2cs
                            // 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)));
                            }
Esempio n. 4
0
File: label.cs Progetto: zjmit/go2cs
            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);
            }
Esempio n. 5
0
File: trace.cs Progetto: zjmit/go2cs
                            public static ptr <Span> GetSpan(context.Context ctx)
                            {
                                var v = ctx.Value(spanContextKey);

                                if (v == null)
                                {
                                    return(_addr_null !);
                                }

                                return(v._ <ptr <Span> >());
                            }
Esempio n. 6
0
                            // 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));
                            }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
                            // 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);
                                });
                            }
Esempio n. 9
0
 // 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 !;
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
 // 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, _, __) =>
Esempio n. 12
0
 private static (slice <@string>, error) query(context.Context ctx, @string filename, @string query, long bufSize) => func((defer, _, __) =>
Esempio n. 13
0
File: log.cs Progetto: zjmit/go2cs
 private static context.Context ProcessEvent(this ptr <logWriter> _addr_w, context.Context ctx, core.Event ev, label.Map lm) => func((defer, _, __) =>
Esempio n. 14
0
 // 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 !;
Esempio n. 15
0
 private static (net.Addr, error) connect(this ptr <socksDialer> _addr_d, context.Context ctx, net.Conn c, @string address) => func((defer, _, __) =>
Esempio n. 16
0
 private static (driver.Stmt, error) ctxDriverPrepare(context.Context ctx, driver.Conn ci, @string query)
 {
     driver.Stmt _p0 = default;
     error       _p0 = default !;
Esempio n. 17
0
File: sizes.cs Progetto: zjmit/go2cs
 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 !;
Esempio n. 18
0
 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;
 }
Esempio n. 19
0
 // 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 !;
Esempio n. 20
0
File: tool.cs Progetto: zjmit/go2cs
 // 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, _, __) =>
Esempio n. 21
0
 public Server(ref ptr <FooServer> FooServer = default, @string user = default, context.Context ctx = default)
 {
     this.FooServer = FooServer;
     this.user      = user;
     this.ctx       = ctx;
 }
Esempio n. 22
0
File: trace.cs Progetto: zjmit/go2cs
 // 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 !);
 }
Esempio n. 23
0
 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;
 }
Esempio n. 24
0
 private static (long, error) lookupProtocol(context.Context ctx, @string name)
 {
     long  proto = default;
     error err   = default !;
Esempio n. 25
0
File: trace.cs Progetto: zjmit/go2cs
 // 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, __) =>
Esempio n. 26
0
 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;
 }
Esempio n. 27
0
 public onlyValuesCtx(context.Context Context = default, context.Context lookupValues = default)
 {
     this.Context      = Context;
     this.lookupValues = lookupValues;
 }
Esempio n. 28
0
File: fast.cs Progetto: zjmit/go2cs
 // 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));
 }
Esempio n. 29
0
 // 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;
Esempio n. 30
0
File: fast.cs Progetto: zjmit/go2cs
 // 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)));
 }