micro

command
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

Command micro

A deployment tools for TP-Micro micro service framework.

Feature

  • Quickly create a tp-micro project
  • Run tp-micro project with hot compilation

Install

go install

Generate project

micro gen command help:

NAME:
     micro gen - Generate a tp-micro project

USAGE:
     micro gen [command options] [arguments...]

OPTIONS:
     --template value, -t value    The template for code generation(relative/absolute)
     --app_path value, -p value  The path(relative/absolute) of the project

example: micro gen -t ./__tp-micro__tpl__.go -p ./myant or default micro gen myant

  • template file __tp-micro__tpl__.go demo:
// package __TPL__ is the project template
package __TPL__

// __API__PULL__ register PULL router:
//  /home
//  /math/divide
type __API__PULL__ interface {
	Home(*struct{}) *HomeResult
	Math
}

// __API__PUSH__ register PUSH router:
//  /stat
type __API__PUSH__ interface {
	Stat(*StatArg)
}

// MODEL create model
type __MODEL__ struct {
	DivideArg
	User
}

// Math controller
type Math interface {
	// Divide handler
	Divide(*DivideArg) *DivideResult
}

// HomeResult home result
type HomeResult struct {
	Content string // text
}

type (
	// DivideArg divide api arg
	DivideArg struct {
		// dividend
		A float64
		// divisor
		B float64 `param:"<range: 0.01:100000>"`
	}
	// DivideResult divide api result
	DivideResult struct {
		// quotient
		C float64
	}
)

// StatArg stat handler arg
type StatArg struct {
	Ts int64 // timestamps
}

// User user info
type User struct {
	Id   int64
	Name string
	Age  int32
}
  • The template generated by micro gen command.
├── __tp-micro__gen__.lock
├── .gitignore
├── README.md
├── __tp-micro__tpl__.go
├── api
│   ├── handler.gen.go
│   ├── handler.go
│   ├── router.gen.go
│   └── router.go
├── args
│   ├── const.go
│   ├── type.gen.go
│   ├── type.go
│   └── var.go
├── config
│   └── config.yaml
├── config.go
├── demo
├── log
│   └── PID
├── logic
│   ├── model
│   │   ├── divide_arg.gen.go
│   │   ├── init.go
│   │   └── user.gen.go
│   └── tmp_code.gen.go
├── main.go
├── rerrs
│   └── rerrs.go
└── sdk
    ├── rpc.gen.go
    ├── rpc.gen_test.go
    ├── rpc.go
    └── rpc_test.go

Desc:

  • This micro gen command only covers files with the ".gen.go" suffix if the __tp-micro__gen__.lock file exists
  • Add .gen suffix to the file name of the automatically generated file
  • tmp_code.gen.go is temporary code used to ensure successful compilation!
    When the project is completed, it should be removed!

Generated Default Sample

Run project

micro run command help:

NAME:
     micro run - Compile and run gracefully (monitor changes) an any existing go project

USAGE:
     micro run [options] [arguments...]
 or
     micro run [options except -app_path] [arguments...] {app_path}

OPTIONS:
     --watch_exts value, -x value  Specified to increase the listening file suffix (default: ".go", ".ini", ".yaml", ".toml", ".xml")
     --notwatch value, -n value    Not watch files or directories
     --app_path value, -p value    The path(relative/absolute) of the project

example: micro run -x .yaml -p myant or micro run

Documentation

Overview

Command micro is a deployment tools of tp-micro frameware.

Copyright 2018 HenryLee. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis
tpl
run
fsnotify
Package fsnotify implements file system notification.
Package fsnotify implements file system notification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL