Browse Source

instance manager: create instance with API

Shelikhoo 4 years ago
parent
commit
3940b6f156

+ 62 - 0
app/instman/command/command.go

@@ -0,0 +1,62 @@
+package command
+
+import (
+	"context"
+	"encoding/base64"
+	core "github.com/v2fly/v2ray-core/v4"
+	"github.com/v2fly/v2ray-core/v4/common"
+	"github.com/v2fly/v2ray-core/v4/features/extension"
+	"google.golang.org/grpc"
+)
+
+type service struct {
+	UnimplementedInstanceManagementServiceServer
+
+	instman extension.InstanceManagement
+}
+
+func (s service) ListInstance(ctx context.Context, req *ListInstanceReq) (*ListInstanceResp, error) {
+	instanceNames, err := s.instman.ListInstance(ctx)
+	if err != nil {
+		return nil, err
+	}
+	return &ListInstanceResp{Name: instanceNames}, nil
+}
+
+func (s service) AddInstance(ctx context.Context, req *AddInstanceReq) (*AddInstanceResp, error) {
+	configContent, err := base64.StdEncoding.DecodeString(req.ConfigContentB64)
+	if err != nil {
+		return nil, err
+	}
+	err = s.instman.AddInstance(ctx, req.Name, configContent, req.ConfigType)
+	if err != nil {
+		return nil, err
+	}
+	return &AddInstanceResp{}, nil
+}
+
+func (s service) StartInstance(ctx context.Context, req *StartInstanceReq) (*StartInstanceResp, error) {
+	err := s.instman.StartInstance(ctx, req.Name)
+	if err != nil {
+		return nil, err
+	}
+	return &StartInstanceResp{}, nil
+}
+
+func (s service) Register(server *grpc.Server) {
+	RegisterInstanceManagementServiceServer(server, s)
+}
+
+func init() {
+	common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, cfg interface{}) (interface{}, error) {
+		s := core.MustFromContext(ctx)
+		sv := &service{}
+		err := s.RequireFeatures(func(instman extension.InstanceManagement) {
+			sv.instman = instman
+		})
+		if err != nil {
+			return nil, err
+		}
+		return sv, nil
+	}))
+}

+ 535 - 0
app/instman/command/command.pb.go

@@ -0,0 +1,535 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.27.1
+// 	protoc        v3.15.6
+// source: app/instman/command/command.proto
+
+package command
+
+import (
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
+)
+
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type ListInstanceReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *ListInstanceReq) Reset() {
+	*x = ListInstanceReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_command_command_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ListInstanceReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ListInstanceReq) ProtoMessage() {}
+
+func (x *ListInstanceReq) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_command_command_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ListInstanceReq.ProtoReflect.Descriptor instead.
+func (*ListInstanceReq) Descriptor() ([]byte, []int) {
+	return file_app_instman_command_command_proto_rawDescGZIP(), []int{0}
+}
+
+type ListInstanceResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Name []string `protobuf:"bytes,1,rep,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *ListInstanceResp) Reset() {
+	*x = ListInstanceResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_command_command_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ListInstanceResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ListInstanceResp) ProtoMessage() {}
+
+func (x *ListInstanceResp) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_command_command_proto_msgTypes[1]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ListInstanceResp.ProtoReflect.Descriptor instead.
+func (*ListInstanceResp) Descriptor() ([]byte, []int) {
+	return file_app_instman_command_command_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *ListInstanceResp) GetName() []string {
+	if x != nil {
+		return x.Name
+	}
+	return nil
+}
+
+type AddInstanceReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Name             string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+	ConfigType       string `protobuf:"bytes,2,opt,name=configType,proto3" json:"configType,omitempty"`
+	ConfigContentB64 string `protobuf:"bytes,3,opt,name=configContentB64,proto3" json:"configContentB64,omitempty"`
+}
+
+func (x *AddInstanceReq) Reset() {
+	*x = AddInstanceReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_command_command_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *AddInstanceReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AddInstanceReq) ProtoMessage() {}
+
+func (x *AddInstanceReq) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_command_command_proto_msgTypes[2]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use AddInstanceReq.ProtoReflect.Descriptor instead.
+func (*AddInstanceReq) Descriptor() ([]byte, []int) {
+	return file_app_instman_command_command_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *AddInstanceReq) GetName() string {
+	if x != nil {
+		return x.Name
+	}
+	return ""
+}
+
+func (x *AddInstanceReq) GetConfigType() string {
+	if x != nil {
+		return x.ConfigType
+	}
+	return ""
+}
+
+func (x *AddInstanceReq) GetConfigContentB64() string {
+	if x != nil {
+		return x.ConfigContentB64
+	}
+	return ""
+}
+
+type AddInstanceResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *AddInstanceResp) Reset() {
+	*x = AddInstanceResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_command_command_proto_msgTypes[3]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *AddInstanceResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AddInstanceResp) ProtoMessage() {}
+
+func (x *AddInstanceResp) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_command_command_proto_msgTypes[3]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use AddInstanceResp.ProtoReflect.Descriptor instead.
+func (*AddInstanceResp) Descriptor() ([]byte, []int) {
+	return file_app_instman_command_command_proto_rawDescGZIP(), []int{3}
+}
+
+type StartInstanceReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *StartInstanceReq) Reset() {
+	*x = StartInstanceReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_command_command_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *StartInstanceReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*StartInstanceReq) ProtoMessage() {}
+
+func (x *StartInstanceReq) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_command_command_proto_msgTypes[4]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use StartInstanceReq.ProtoReflect.Descriptor instead.
+func (*StartInstanceReq) Descriptor() ([]byte, []int) {
+	return file_app_instman_command_command_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *StartInstanceReq) GetName() string {
+	if x != nil {
+		return x.Name
+	}
+	return ""
+}
+
+type StartInstanceResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *StartInstanceResp) Reset() {
+	*x = StartInstanceResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_command_command_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *StartInstanceResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*StartInstanceResp) ProtoMessage() {}
+
+func (x *StartInstanceResp) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_command_command_proto_msgTypes[5]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use StartInstanceResp.ProtoReflect.Descriptor instead.
+func (*StartInstanceResp) Descriptor() ([]byte, []int) {
+	return file_app_instman_command_command_proto_rawDescGZIP(), []int{5}
+}
+
+type Config struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *Config) Reset() {
+	*x = Config{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_command_command_proto_msgTypes[6]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Config) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Config) ProtoMessage() {}
+
+func (x *Config) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_command_command_proto_msgTypes[6]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Config.ProtoReflect.Descriptor instead.
+func (*Config) Descriptor() ([]byte, []int) {
+	return file_app_instman_command_command_proto_rawDescGZIP(), []int{6}
+}
+
+var File_app_instman_command_command_proto protoreflect.FileDescriptor
+
+var file_app_instman_command_command_proto_rawDesc = []byte{
+	0x0a, 0x21, 0x61, 0x70, 0x70, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x2f, 0x63, 0x6f,
+	0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e,
+	0x61, 0x70, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d,
+	0x61, 0x6e, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61,
+	0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x22, 0x26, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e,
+	0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
+	0x6d, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x70,
+	0x0a, 0x0e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71,
+	0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
+	0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x54, 0x79,
+	0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
+	0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x43, 0x6f,
+	0x6e, 0x74, 0x65, 0x6e, 0x74, 0x42, 0x36, 0x34, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10,
+	0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x42, 0x36, 0x34,
+	0x22, 0x11, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52,
+	0x65, 0x73, 0x70, 0x22, 0x26, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74,
+	0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
+	0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x53,
+	0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70,
+	0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xf4, 0x02, 0x0a, 0x19, 0x49,
+	0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e,
+	0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74,
+	0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x2f, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79,
+	0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61,
+	0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e,
+	0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x30, 0x2e, 0x76, 0x32, 0x72, 0x61,
+	0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x6d,
+	0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49,
+	0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x6e, 0x0a, 0x0b, 0x41,
+	0x64, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x2e, 0x2e, 0x76, 0x32, 0x72,
+	0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x74,
+	0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49,
+	0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x2f, 0x2e, 0x76, 0x32, 0x72,
+	0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x74,
+	0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49,
+	0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x74, 0x0a, 0x0d, 0x53,
+	0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x30, 0x2e, 0x76,
+	0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x69, 0x6e,
+	0x73, 0x74, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x74,
+	0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x31,
+	0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e,
+	0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e,
+	0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73,
+	0x70, 0x42, 0x7f, 0x0a, 0x26, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63,
+	0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74,
+	0x6f, 0x72, 0x79, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x32, 0x67,
+	0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x32, 0x66, 0x6c, 0x79, 0x2f,
+	0x76, 0x32, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x34, 0x2f, 0x61, 0x70,
+	0x70, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
+	0x64, 0xaa, 0x02, 0x1e, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41,
+	0x70, 0x70, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61,
+	0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_app_instman_command_command_proto_rawDescOnce sync.Once
+	file_app_instman_command_command_proto_rawDescData = file_app_instman_command_command_proto_rawDesc
+)
+
+func file_app_instman_command_command_proto_rawDescGZIP() []byte {
+	file_app_instman_command_command_proto_rawDescOnce.Do(func() {
+		file_app_instman_command_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_instman_command_command_proto_rawDescData)
+	})
+	return file_app_instman_command_command_proto_rawDescData
+}
+
+var file_app_instman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
+var file_app_instman_command_command_proto_goTypes = []interface{}{
+	(*ListInstanceReq)(nil),   // 0: v2ray.core.app.instman.command.ListInstanceReq
+	(*ListInstanceResp)(nil),  // 1: v2ray.core.app.instman.command.ListInstanceResp
+	(*AddInstanceReq)(nil),    // 2: v2ray.core.app.instman.command.AddInstanceReq
+	(*AddInstanceResp)(nil),   // 3: v2ray.core.app.instman.command.AddInstanceResp
+	(*StartInstanceReq)(nil),  // 4: v2ray.core.app.instman.command.StartInstanceReq
+	(*StartInstanceResp)(nil), // 5: v2ray.core.app.instman.command.StartInstanceResp
+	(*Config)(nil),            // 6: v2ray.core.app.instman.command.Config
+}
+var file_app_instman_command_command_proto_depIdxs = []int32{
+	0, // 0: v2ray.core.app.instman.command.InstanceManagementService.ListInstance:input_type -> v2ray.core.app.instman.command.ListInstanceReq
+	2, // 1: v2ray.core.app.instman.command.InstanceManagementService.AddInstance:input_type -> v2ray.core.app.instman.command.AddInstanceReq
+	4, // 2: v2ray.core.app.instman.command.InstanceManagementService.StartInstance:input_type -> v2ray.core.app.instman.command.StartInstanceReq
+	1, // 3: v2ray.core.app.instman.command.InstanceManagementService.ListInstance:output_type -> v2ray.core.app.instman.command.ListInstanceResp
+	3, // 4: v2ray.core.app.instman.command.InstanceManagementService.AddInstance:output_type -> v2ray.core.app.instman.command.AddInstanceResp
+	5, // 5: v2ray.core.app.instman.command.InstanceManagementService.StartInstance:output_type -> v2ray.core.app.instman.command.StartInstanceResp
+	3, // [3:6] is the sub-list for method output_type
+	0, // [0:3] is the sub-list for method input_type
+	0, // [0:0] is the sub-list for extension type_name
+	0, // [0:0] is the sub-list for extension extendee
+	0, // [0:0] is the sub-list for field type_name
+}
+
+func init() { file_app_instman_command_command_proto_init() }
+func file_app_instman_command_command_proto_init() {
+	if File_app_instman_command_command_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_app_instman_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ListInstanceReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_app_instman_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ListInstanceResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_app_instman_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*AddInstanceReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_app_instman_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*AddInstanceResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_app_instman_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*StartInstanceReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_app_instman_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*StartInstanceResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_app_instman_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Config); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_app_instman_command_command_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   7,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_app_instman_command_command_proto_goTypes,
+		DependencyIndexes: file_app_instman_command_command_proto_depIdxs,
+		MessageInfos:      file_app_instman_command_command_proto_msgTypes,
+	}.Build()
+	File_app_instman_command_command_proto = out.File
+	file_app_instman_command_command_proto_rawDesc = nil
+	file_app_instman_command_command_proto_goTypes = nil
+	file_app_instman_command_command_proto_depIdxs = nil
+}

+ 35 - 0
app/instman/command/command.proto

@@ -0,0 +1,35 @@
+syntax = "proto3";
+
+package v2ray.core.app.instman.command;
+option csharp_namespace = "V2Ray.Core.App.Instman.Command";
+option go_package = "github.com/v2fly/v2ray-core/v4/app/instman/command";
+option java_package = "com.v2ray.core.app.observatory.instman";
+option java_multiple_files = true;
+
+message ListInstanceReq{}
+message ListInstanceResp{
+  repeated string name = 1;
+}
+
+message AddInstanceReq{
+  string name = 1;
+  string configType = 2;
+  string configContentB64 = 3;
+}
+
+message AddInstanceResp{}
+
+message StartInstanceReq{
+  string name = 1;
+}
+
+message StartInstanceResp{
+}
+
+service InstanceManagementService {
+  rpc ListInstance(ListInstanceReq) returns (ListInstanceResp);
+  rpc AddInstance(AddInstanceReq) returns (AddInstanceResp);
+  rpc StartInstance(StartInstanceReq) returns (StartInstanceResp);
+}
+
+message Config {}

+ 174 - 0
app/instman/command/command_grpc.pb.go

@@ -0,0 +1,174 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+
+package command
+
+import (
+	context "context"
+	grpc "google.golang.org/grpc"
+	codes "google.golang.org/grpc/codes"
+	status "google.golang.org/grpc/status"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
+const _ = grpc.SupportPackageIsVersion7
+
+// InstanceManagementServiceClient is the client API for InstanceManagementService service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type InstanceManagementServiceClient interface {
+	ListInstance(ctx context.Context, in *ListInstanceReq, opts ...grpc.CallOption) (*ListInstanceResp, error)
+	AddInstance(ctx context.Context, in *AddInstanceReq, opts ...grpc.CallOption) (*AddInstanceResp, error)
+	StartInstance(ctx context.Context, in *StartInstanceReq, opts ...grpc.CallOption) (*StartInstanceResp, error)
+}
+
+type instanceManagementServiceClient struct {
+	cc grpc.ClientConnInterface
+}
+
+func NewInstanceManagementServiceClient(cc grpc.ClientConnInterface) InstanceManagementServiceClient {
+	return &instanceManagementServiceClient{cc}
+}
+
+func (c *instanceManagementServiceClient) ListInstance(ctx context.Context, in *ListInstanceReq, opts ...grpc.CallOption) (*ListInstanceResp, error) {
+	out := new(ListInstanceResp)
+	err := c.cc.Invoke(ctx, "/v2ray.core.app.instman.command.InstanceManagementService/ListInstance", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *instanceManagementServiceClient) AddInstance(ctx context.Context, in *AddInstanceReq, opts ...grpc.CallOption) (*AddInstanceResp, error) {
+	out := new(AddInstanceResp)
+	err := c.cc.Invoke(ctx, "/v2ray.core.app.instman.command.InstanceManagementService/AddInstance", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *instanceManagementServiceClient) StartInstance(ctx context.Context, in *StartInstanceReq, opts ...grpc.CallOption) (*StartInstanceResp, error) {
+	out := new(StartInstanceResp)
+	err := c.cc.Invoke(ctx, "/v2ray.core.app.instman.command.InstanceManagementService/StartInstance", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+// InstanceManagementServiceServer is the server API for InstanceManagementService service.
+// All implementations must embed UnimplementedInstanceManagementServiceServer
+// for forward compatibility
+type InstanceManagementServiceServer interface {
+	ListInstance(context.Context, *ListInstanceReq) (*ListInstanceResp, error)
+	AddInstance(context.Context, *AddInstanceReq) (*AddInstanceResp, error)
+	StartInstance(context.Context, *StartInstanceReq) (*StartInstanceResp, error)
+	mustEmbedUnimplementedInstanceManagementServiceServer()
+}
+
+// UnimplementedInstanceManagementServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedInstanceManagementServiceServer struct {
+}
+
+func (UnimplementedInstanceManagementServiceServer) ListInstance(context.Context, *ListInstanceReq) (*ListInstanceResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ListInstance not implemented")
+}
+func (UnimplementedInstanceManagementServiceServer) AddInstance(context.Context, *AddInstanceReq) (*AddInstanceResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method AddInstance not implemented")
+}
+func (UnimplementedInstanceManagementServiceServer) StartInstance(context.Context, *StartInstanceReq) (*StartInstanceResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method StartInstance not implemented")
+}
+func (UnimplementedInstanceManagementServiceServer) mustEmbedUnimplementedInstanceManagementServiceServer() {
+}
+
+// UnsafeInstanceManagementServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to InstanceManagementServiceServer will
+// result in compilation errors.
+type UnsafeInstanceManagementServiceServer interface {
+	mustEmbedUnimplementedInstanceManagementServiceServer()
+}
+
+func RegisterInstanceManagementServiceServer(s grpc.ServiceRegistrar, srv InstanceManagementServiceServer) {
+	s.RegisterService(&InstanceManagementService_ServiceDesc, srv)
+}
+
+func _InstanceManagementService_ListInstance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ListInstanceReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(InstanceManagementServiceServer).ListInstance(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/v2ray.core.app.instman.command.InstanceManagementService/ListInstance",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(InstanceManagementServiceServer).ListInstance(ctx, req.(*ListInstanceReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _InstanceManagementService_AddInstance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(AddInstanceReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(InstanceManagementServiceServer).AddInstance(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/v2ray.core.app.instman.command.InstanceManagementService/AddInstance",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(InstanceManagementServiceServer).AddInstance(ctx, req.(*AddInstanceReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _InstanceManagementService_StartInstance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(StartInstanceReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(InstanceManagementServiceServer).StartInstance(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/v2ray.core.app.instman.command.InstanceManagementService/StartInstance",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(InstanceManagementServiceServer).StartInstance(ctx, req.(*StartInstanceReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+// InstanceManagementService_ServiceDesc is the grpc.ServiceDesc for InstanceManagementService service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var InstanceManagementService_ServiceDesc = grpc.ServiceDesc{
+	ServiceName: "v2ray.core.app.instman.command.InstanceManagementService",
+	HandlerType: (*InstanceManagementServiceServer)(nil),
+	Methods: []grpc.MethodDesc{
+		{
+			MethodName: "ListInstance",
+			Handler:    _InstanceManagementService_ListInstance_Handler,
+		},
+		{
+			MethodName: "AddInstance",
+			Handler:    _InstanceManagementService_AddInstance_Handler,
+		},
+		{
+			MethodName: "StartInstance",
+			Handler:    _InstanceManagementService_StartInstance_Handler,
+		},
+	},
+	Streams:  []grpc.StreamDesc{},
+	Metadata: "app/instman/command/command.proto",
+}

+ 138 - 0
app/instman/config.pb.go

@@ -0,0 +1,138 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.27.1
+// 	protoc        v3.15.6
+// source: app/instman/config.proto
+
+package instman
+
+import (
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
+)
+
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type Config struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *Config) Reset() {
+	*x = Config{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_app_instman_config_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Config) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Config) ProtoMessage() {}
+
+func (x *Config) ProtoReflect() protoreflect.Message {
+	mi := &file_app_instman_config_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Config.ProtoReflect.Descriptor instead.
+func (*Config) Descriptor() ([]byte, []int) {
+	return file_app_instman_config_proto_rawDescGZIP(), []int{0}
+}
+
+var File_app_instman_config_proto protoreflect.FileDescriptor
+
+var file_app_instman_config_proto_rawDesc = []byte{
+	0x0a, 0x18, 0x61, 0x70, 0x70, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x2f, 0x63, 0x6f,
+	0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x76, 0x32, 0x72, 0x61,
+	0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x6d,
+	0x61, 0x6e, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0x63, 0x0a, 0x1a,
+	0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61,
+	0x70, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69,
+	0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x32, 0x66, 0x6c, 0x79, 0x2f, 0x76,
+	0x32, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x34, 0x2f, 0x61, 0x70, 0x70,
+	0x2f, 0x69, 0x6e, 0x73, 0x74, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x16, 0x56, 0x32, 0x52, 0x61, 0x79,
+	0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x6d, 0x61,
+	0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_app_instman_config_proto_rawDescOnce sync.Once
+	file_app_instman_config_proto_rawDescData = file_app_instman_config_proto_rawDesc
+)
+
+func file_app_instman_config_proto_rawDescGZIP() []byte {
+	file_app_instman_config_proto_rawDescOnce.Do(func() {
+		file_app_instman_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_instman_config_proto_rawDescData)
+	})
+	return file_app_instman_config_proto_rawDescData
+}
+
+var file_app_instman_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
+var file_app_instman_config_proto_goTypes = []interface{}{
+	(*Config)(nil), // 0: v2ray.core.app.instman.Config
+}
+var file_app_instman_config_proto_depIdxs = []int32{
+	0, // [0:0] is the sub-list for method output_type
+	0, // [0:0] is the sub-list for method input_type
+	0, // [0:0] is the sub-list for extension type_name
+	0, // [0:0] is the sub-list for extension extendee
+	0, // [0:0] is the sub-list for field type_name
+}
+
+func init() { file_app_instman_config_proto_init() }
+func file_app_instman_config_proto_init() {
+	if File_app_instman_config_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_app_instman_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Config); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_app_instman_config_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_app_instman_config_proto_goTypes,
+		DependencyIndexes: file_app_instman_config_proto_depIdxs,
+		MessageInfos:      file_app_instman_config_proto_msgTypes,
+	}.Build()
+	File_app_instman_config_proto = out.File
+	file_app_instman_config_proto_rawDesc = nil
+	file_app_instman_config_proto_goTypes = nil
+	file_app_instman_config_proto_depIdxs = nil
+}

+ 9 - 0
app/instman/config.proto

@@ -0,0 +1,9 @@
+syntax = "proto3";
+
+package v2ray.core.app.instman;
+option csharp_namespace = "V2Ray.Core.App.Instman";
+option go_package = "github.com/v2fly/v2ray-core/v4/app/instman";
+option java_package = "com.v2ray.core.app.instman";
+option java_multiple_files = true;
+
+message Config {}

+ 9 - 0
app/instman/errors.generated.go

@@ -0,0 +1,9 @@
+package instman
+
+import "github.com/v2fly/v2ray-core/v4/common/errors"
+
+type errPathObjHolder struct{}
+
+func newError(values ...interface{}) *errors.Error {
+	return errors.New(values...).WithPathObj(errPathObjHolder{})
+}

+ 68 - 0
app/instman/instman.go

@@ -0,0 +1,68 @@
+package instman
+
+import (
+	"context"
+	core "github.com/v2fly/v2ray-core/v4"
+	"github.com/v2fly/v2ray-core/v4/features/extension"
+)
+
+//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
+
+type InstanceMgr struct {
+	config    *Config
+	instances map[string]*core.Instance
+}
+
+func (i InstanceMgr) Type() interface{} {
+	return extension.InstanceManagementType()
+}
+
+func (i InstanceMgr) Start() error {
+	return nil
+}
+
+func (i InstanceMgr) Close() error {
+	return nil
+}
+
+func (i InstanceMgr) ListInstance(ctx context.Context) ([]string, error) {
+	var instanceNames []string
+	for k, _ := range i.instances {
+		instanceNames = append(instanceNames, k)
+	}
+	return instanceNames, nil
+}
+
+func (i InstanceMgr) AddInstance(ctx context.Context, name string, config []byte, configType string) error {
+	coreConfig, err := core.LoadConfig(configType, config)
+	if err != nil {
+		return newError("unable to load config").Base(err)
+	}
+	instance, err := core.New(coreConfig)
+	if err != nil {
+		return newError("unable to create instance").Base(err)
+	}
+	i.instances[name] = instance
+	return nil
+}
+
+func (i InstanceMgr) StartInstance(ctx context.Context, name string) error {
+	err := i.instances[name].Start()
+	if err != nil {
+		return newError("failed to start instance").Base(err)
+	}
+	return nil
+}
+
+func (i InstanceMgr) StopInstance(ctx context.Context, name string) error {
+	err := i.instances[name].Close()
+	if err != nil {
+		return newError("failed to stop instance").Base(err)
+	}
+	return nil
+}
+
+func (i InstanceMgr) UntrackInstance(ctx context.Context, name string) error {
+	delete(i.instances, name)
+	return nil
+}