Skip to content

Commit

Permalink
fix: refactor example structure (alibaba#78)
Browse files Browse the repository at this point in the history
* fix: refactor example structure, rename debug to aop

* fix: ci, remove unused readme

* Fix: sleep loger time

* temperiorly remove nacos config client
  • Loading branch information
LaurenceLiZhixin authored Jul 6, 2022
1 parent 8ed0852 commit f3d57c2
Show file tree
Hide file tree
Showing 165 changed files with 1,327 additions and 729 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
proto-gen:
protoc --go_out=./debug/api --go-grpc_out=./debug/api ./debug/api/ioc_golang/debug/debug.proto
protoc --go_out=./aop/api --go-grpc_out=./aop/api ./aop/api/ioc_golang/aop/debug.proto

tidy-all:
cd extension && go mod tidy -compat=1.17
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ IOC-golang is a powerful golang dependency injection framework that provides a c

Can take over object creation, parameter injection, factory methods. Customizable object parameter source.

- [Struct Proxy Layer](https://ioc-golang.github.io/docs/examples/debug/)
- [Struct Proxy Layer](https://ioc-golang.github.io/docs/examples/aop/)

Based on the idea of AOP, we provide struct proxy layer for all struct registered to ioc-golang. In the scene of interface oriented development, we can use many devlops features based on the extenablility of this proxy AOP layer. Such as interface listing, param value watching, method level tracing, performance badpoint analysis, fault injection, method level tracing in distributed system and so on.

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ IOC-golang 是一款强大的 Go 语言依赖注入框架,提供了一套完

可以接管对象的创建、参数注入、工厂方法。可定制化对象参数来源。

- [结构代理层](https://ioc-golang.github.io/cn/docs/examples/debug/)
- [结构代理层](https://ioc-golang.github.io/cn/docs/examples/aop/)

基于 AOP 的思路,为由框架接管的对象提供默认的结构代理层,在面向接口编程的情景下,可以使用基于结构代理 AOP 层扩展的丰富运维能力。例如接口查询,参数动态监听,方法粒度链路追踪,性能瓶颈分析,分布式场景下全链路方法粒度追踪等。

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions debug/boot.go → aop/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
* limitations under the License.
*/

package debug
package aop

import (
"github.com/fatih/color"

"github.com/alibaba/ioc-golang/aop/common"
"github.com/alibaba/ioc-golang/aop/interceptor"
"github.com/alibaba/ioc-golang/aop/interceptor/server"
tracer "github.com/alibaba/ioc-golang/aop/interceptor/trace"
"github.com/alibaba/ioc-golang/aop/interceptor/transaction"
"github.com/alibaba/ioc-golang/aop/interceptor/watch"
"github.com/alibaba/ioc-golang/config"
"github.com/alibaba/ioc-golang/debug/common"
"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/debug/interceptor/server"
tracer "github.com/alibaba/ioc-golang/debug/interceptor/trace"
"github.com/alibaba/ioc-golang/debug/interceptor/transaction"
"github.com/alibaba/ioc-golang/debug/interceptor/watch"
)

var interceptors = make([]interceptor.Interceptor, 0)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package common
import "runtime"

const (
ProxyMethod = "github.com/alibaba/ioc-golang/debug.makeProxyFunction.func1"
ProxyMethod = "github.com/alibaba/ioc-golang/aop.makeProxyFunction.func1"
)

func CurrentCallingMethodName() string {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ package server
import (
"net"

"github.com/alibaba/ioc-golang/aop/api/ioc_golang/debug"

"github.com/fatih/color"
"google.golang.org/grpc"

"github.com/alibaba/ioc-golang/common"
"github.com/alibaba/ioc-golang/debug/api/ioc_golang/debug"

debugCommon "github.com/alibaba/ioc-golang/debug/common"
"github.com/alibaba/ioc-golang/debug/interceptor/trace"
"github.com/alibaba/ioc-golang/debug/interceptor/watch"
debugCommon "github.com/alibaba/ioc-golang/aop/common"
"github.com/alibaba/ioc-golang/aop/interceptor/trace"
"github.com/alibaba/ioc-golang/aop/interceptor/watch"
)

func Start(debugConfig *debugCommon.Config, allInterfaceMetadataMap map[string]*debugCommon.StructMetadata) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import (
"context"
"sort"

"github.com/alibaba/ioc-golang/aop/api/ioc_golang/debug"

"github.com/fatih/color"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/alibaba/ioc-golang/debug/api/ioc_golang/debug"

debugCommon "github.com/alibaba/ioc-golang/debug/common"
"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/debug/interceptor/common"
"github.com/alibaba/ioc-golang/debug/interceptor/trace"
"github.com/alibaba/ioc-golang/debug/interceptor/watch"
debugCommon "github.com/alibaba/ioc-golang/aop/common"
"github.com/alibaba/ioc-golang/aop/interceptor"
"github.com/alibaba/ioc-golang/aop/interceptor/common"
"github.com/alibaba/ioc-golang/aop/interceptor/trace"
"github.com/alibaba/ioc-golang/aop/interceptor/watch"
)

type DebugServerImpl struct {
Expand Down
4 changes: 1 addition & 3 deletions debug/interceptor/sorter.go → aop/interceptor/sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

package interceptor

import (
"github.com/alibaba/ioc-golang/debug/api/ioc_golang/debug"
)
import "github.com/alibaba/ioc-golang/aop/api/ioc_golang/debug"

type MetadataSorter []*debug.ServiceMetadata

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ package trace
import (
"sync"

"github.com/alibaba/ioc-golang/aop/api/ioc_golang/debug"

"github.com/petermattis/goid"

"github.com/opentracing/opentracing-go"

"github.com/alibaba/ioc-golang/debug/api/ioc_golang/debug"
"github.com/alibaba/ioc-golang/debug/interceptor/common"
"github.com/alibaba/ioc-golang/aop/interceptor/common"
)

type methodTracingContext struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/petermattis/goid"

"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/debug/interceptor/common"
"github.com/alibaba/ioc-golang/aop/interceptor"
"github.com/alibaba/ioc-golang/aop/interceptor/common"
)

type goRoutineTraceInterceptor struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/opentracing/opentracing-go"

"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/debug/interceptor/common"
"github.com/alibaba/ioc-golang/aop/interceptor"
"github.com/alibaba/ioc-golang/aop/interceptor/common"
)

type MethodTraceInterceptor struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/opentracing/opentracing-go"

"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/aop/interceptor"
)

type rpcInterceptor struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package transaction
import (
"reflect"

"github.com/alibaba/ioc-golang/aop/interceptor"
"github.com/alibaba/ioc-golang/autowire"
"github.com/alibaba/ioc-golang/debug/interceptor"
)

type context struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
"reflect"
"sync"

"github.com/alibaba/ioc-golang/aop/interceptor"
"github.com/alibaba/ioc-golang/autowire"
"github.com/alibaba/ioc-golang/debug/interceptor"

"github.com/petermattis/goid"

"github.com/alibaba/ioc-golang/debug/interceptor/common"
"github.com/alibaba/ioc-golang/aop/interceptor/common"
)

type Interceptor struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
"reflect"
"sync"

"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/aop/interceptor"

"github.com/petermattis/goid"

debugPB "github.com/alibaba/ioc-golang/debug/api/ioc_golang/debug"
"github.com/alibaba/ioc-golang/debug/interceptor/common"
debugPB "github.com/alibaba/ioc-golang/aop/api/ioc_golang/debug"
"github.com/alibaba/ioc-golang/aop/interceptor/common"
)

type Interceptor struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
"testing"
"time"

"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/aop/api/ioc_golang/debug"

"github.com/alibaba/ioc-golang/aop/interceptor"

"github.com/stretchr/testify/assert"

"github.com/alibaba/ioc-golang/aop/interceptor/common"
"github.com/alibaba/ioc-golang/autowire/util"
"github.com/alibaba/ioc-golang/debug/api/ioc_golang/debug"
"github.com/alibaba/ioc-golang/debug/interceptor/common"
)

func TestWatchInterceptor(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions debug/monkey.go → aop/monkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* limitations under the License.
*/

package debug
package aop

import (
"reflect"

"github.com/alibaba/ioc-golang/debug/interceptor"
"github.com/alibaba/ioc-golang/aop/interceptor"

"github.com/glory-go/monkey"

"github.com/alibaba/ioc-golang/aop/common"
"github.com/alibaba/ioc-golang/autowire"
"github.com/alibaba/ioc-golang/autowire/util"
"github.com/alibaba/ioc-golang/debug/common"
)

func init() {
Expand Down
6 changes: 3 additions & 3 deletions debug/proxy.go → aop/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* limitations under the License.
*/

package debug
package aop

import (
"fmt"
"reflect"
"strings"

"github.com/alibaba/ioc-golang/aop/common"
"github.com/alibaba/ioc-golang/aop/interceptor"
"github.com/alibaba/ioc-golang/autowire"
"github.com/alibaba/ioc-golang/autowire/normal"
"github.com/alibaba/ioc-golang/autowire/util"
"github.com/alibaba/ioc-golang/debug/common"
"github.com/alibaba/ioc-golang/debug/interceptor"
)

func init() {
Expand Down
5 changes: 3 additions & 2 deletions boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package ioc
import (
"github.com/fatih/color"

"github.com/alibaba/ioc-golang/aop"

"github.com/alibaba/ioc-golang/autowire"
"github.com/alibaba/ioc-golang/config"
"github.com/alibaba/ioc-golang/debug"
)

func Load(opts ...config.Option) error {
Expand All @@ -35,7 +36,7 @@ func Load(opts ...config.Option) error {

// 2. load debug
color.Blue("[Boot] Start to load debug")
if err := debug.Load(); err != nil {
if err := aop.Load(); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion config/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type Options struct {

// default: config
ConfigName string
// default: yml,yaml
// default: yaml
ConfigType string
// Search path of config files
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 使用调试功能
# 使用接口方法、参数的可视化功能

### 简介

本示例展示了 ioc-golang 框架提供的代码调试能力。代码调试能力以及其他运维能力,都是基于代理层实现的
本示例展示了 ioc-golang 框架提供的接口方法、参数的可视化功能

所有在调用中流量经过代理层的结构,都具备调试能力,我们可以通过 iocli 工具,动态监听所有包含代理层的接口、方法、以及实时的参数/返回值内容。

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"

"github.com/alibaba/ioc-golang"
"github.com/alibaba/ioc-golang/example/transaction_rpc/server/pkg/service/api"
"github.com/alibaba/ioc-golang/example/aop/transaction/distributed/server/pkg/service/api"
)

// +ioc:autowire=true
Expand All @@ -29,7 +29,7 @@ import (
// +ioc:tx:func=DoTradeWithTxSuccess

type TradeService struct {
BankRPCService api.BankServiceIOCRPCClient `rpc-client:",address=localhost:2022""`
BankRPCService api.BankServiceIOCRPCClient `rpc-client:",address=localhost:2022"`
}

func (b *TradeService) DoTradeWithTxFinallyFailed(id1, id2, num int) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/alibaba/ioc-golang"

_ "github.com/alibaba/ioc-golang/example/transaction_rpc/server/pkg/service"
_ "github.com/alibaba/ioc-golang/example/aop/transaction/distributed/server/pkg/service"
)

func (a *App) TestRun(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package main

import (
"github.com/alibaba/ioc-golang"
_ "github.com/alibaba/ioc-golang/example/transaction_rpc/server/pkg/service"
_ "github.com/alibaba/ioc-golang/example/aop/transaction/distributed/server/pkg/service"
)

func main() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f3d57c2

Please sign in to comment.