Code Monkey home page Code Monkey logo

commander's Introduction

Tracegen

Generates interface decorators with opentracing support.

Installation

go get github.com/gojuno/tracegen

Example

type Cache interface {
	Set(ctx context.Context, key, value []byte) error
	Get(ctx context.Context, key []byte) (value []byte, err error)
}
tracegen -i Cache -o example/cache_trace.go ./example

Will generate:

type CacheTracer struct {
	next   Cache
	prefix string
}

func NewCacheTracer(next Cache, prefix string) *CacheTracer {
	return &CacheTracer{
		next:   next,
		prefix: prefix,
	}
}

func (t *CacheTracer) Get(in context.Context, in1 []byte) (out []byte, out1 error) {
	span, in := opentracing.StartSpanFromContext(in, t.prefix+".Cache.Get")
	defer func() {
		if out1 != nil {
			ext.Error.Set(span, true)
			span.LogFields(
				log.String("event", "error"),
				log.String("message", out1.Error()),
			)
		}
		span.Finish()
	}()

	return t.next.Get(in, in1)
}

func (t *CacheTracer) Set(in context.Context, in1 []byte, in2 []byte) (out error) {
	span, in := opentracing.StartSpanFromContext(in, t.prefix+".Cache.Set")
	defer func() {
		if out != nil {
			ext.Error.Set(span, true)
			span.LogFields(
				log.String("event", "error"),
				log.String("message", out.Error()),
			)
		}
		span.Finish()
	}()

	return t.next.Set(in, in1, in2)
}

commander's People

Contributors

artem-zinnatullin avatar arturdryomov avatar dsvoronin avatar koral-- avatar yunikkk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

commander's Issues

Why you decided to use `script` and get all output through file?

I would like to ask this question because we found strange things with this part of commander.

script have a different behaviour depends on version. For example, script from unix-utils 2.27.1 saves placeholder about started time like this:

Script started on Tue 24 Apr 2018 04:22:21 AM MSK

even we have --quiet flag.

Also, we had a flaky experience with composer, that uses this implementation of commander and getting output from the command using tail.

We fixed this using common approach for running subprocesses.

But now it has a little bit different interface, then current implementation. For example, Notification class looks like this for supporting real-time output parsing (instead of tail):

sealed class Notification {
    object Start : Notification()
    data class Exit(val output: String) : Notification()
    data class Output(val line: String) : Notification()
}

Would you like to have this changes in commander or it is important to have current behaviour or you don't want to merge breaking changes?

Emulator.kt should be called AdbDevice.kt

I was trying to find the AdbDevice class implementation from Composer, and I couldn't find it on Composer or Commander navigating through GitHub. It took me a (pathetically) long time to find that the class is located in the Emulator.kt file.

I know it's a small detail, but since it only contains the AdbDevice class which includes both emulators and physical devices, I think it would be best to rename it. That way nobody else will feel as stupid as I did just now ๐Ÿ˜…

I'd like to submit the PR, but just wanted to ask first in case I'm missing some reason not to. I think Composer wouldn't be affected because the class is imported with import com.gojuno.commander.android.*.

Add support for Windows

Nothing more to add really: Windows is not supported today. I'd like it to be.

I can contribute if it's of interest.

Increase ADB install timeout or make it configurable

Timeout for APK installation is set to only 5 minutes:

I have a ~200 MB APK and a device connected remotely and 5 minutes is not enough.
In ddmlib (so also in spoon) there is a deafult timeout set to 5 s, in case of installation it seems to refer to a single 64 KB chunk of data. Additionally default value can be increased using com.android.ddmlib.DdmPreferences#setTimeOut.

adb install constantly prints percentage during installation. Maybe installation timeout should occur when no new output is received within some time period e.g. 30 s?

ANDROID_HOME is deprecated

Google has changed ANDROID_HOME to ANDROID_SDK_ROOT https://developer.android.com/studio/command-line/variables#envar and at least brew users are encouraged to set the former.

https://github.com/Homebrew/homebrew-cask/blob/ff2606786cd5e4249fd7b53d1a388f016b9fcb42/Casks/android-sdk.rb#L38

Currently, ANDROID_HOME is forced by commander.

val androidHome: String by lazy { requireNotNull(System.getenv("ANDROID_HOME")) { "Please specify ANDROID_HOME env variable" } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.