Ejemplo n.º 1
0
func TestNewNoValueInstance(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	ownersWrong := auth.NewPlainTextCredentials()
	err = ownersWrong.Add(&auth.PlainText{"id2", "passssss"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	err = instances.NewNoValueInstance("1", "321", owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.NewNoValueInstance("1", "111", ownersWrong)
	if err != nil && !e.Equal(err, ErrOwnerNotMatch) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	err = instances.NewNoValueInstance("123", "1", owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.NewNoValueInstance("123", "1", owners)
	if err != nil && !e.Equal(err, ErrInstExists) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
}
Ejemplo n.º 2
0
func (s *Server) mkChServer(conn InstConn, args []reflect.Value, enc *msgpack.Encoder) (err error) {
	typeChanDesc := reflect.TypeOf(&ChannelDescriptor{})
	for i, arg := range args {
		if arg.Type() != typeChanDesc {
			continue
		}
		chd := arg.Interface().(*ChannelDescriptor)
		// criar channel. Value
		ch := chd.Make(true)
		// substituir o ChannelDescriptor pelo channel criado
		args[i] = ch
		// criar sessão/instância
		instname, err := rand.Chars(16, rand.NumberLetters, "go")
		if err != nil {
			return e.Forward(err)
		}
		owners := auth.NewPlainTextCredentials()
		err = owners.Add(conn.Auth())
		if err != nil {
			return e.Forward(err)
		}
		err = s.Insts.NewChValueInstance(conn.SessionName(), instname, ch, chd.Dir, owners)
		if err != nil {
			return e.Forward(err)
		}

		// envia-las
		err = enc.Encode(instname)
		if err != nil {
			return e.Forward(err)
		}
	}
	return nil
}
Ejemplo n.º 3
0
func BenchmarkLoad(b *testing.B) {
	instances := core.NewInstances()

	owners := auth.NewPlainTextCredentials()
	id = &auth.PlainText{Ident: "id", Pass: "******"}
	owners.Add(id)

	constructor := core.NewConstructor()

	server = &core.Server{
		Proto:       "tcp",
		Addr:        "localhost:0",
		ConnTimeout: 30 * time.Second,
		Insts:       instances,
		Cons:        constructor,
		FifoLength:  1,
		Ttl:         24 * time.Hour,
		Cleanup:     5 * time.Minute,
	}
	server.Start()

	err := instances.New("1", "3", reflect.ValueOf(&Load{}), owners)
	if err != nil {
		b.Error(e.Trace(e.Forward(err)))
	}

	l := &LoadClient{
		Net:         "tcp",
		Addrs:       server.Address().String(),
		Auth:        id,
		Session:     "1",
		Instance:    "3",
		PointerRecv: true,
	}

	err = l.Init(true)
	if err != nil {
		b.Error(e.Trace(e.Forward(err)))
	}

	in, err := rand.Bytes(1e6, "go")
	if err != nil {
		b.Error(e.Trace(e.Forward(err)))
	}

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		l.Load(in)
		b.SetBytes(int64(len(in)))
	}
}
Ejemplo n.º 4
0
func TestNewChValueInstance(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	ownersWrong := auth.NewPlainTextCredentials()
	err = ownersWrong.Add(&auth.PlainText{"id2", "passssss"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	ch := make(chan int)
	err = instances.NewChValueInstance("new", "1", reflect.ValueOf(ch), reflect.BothDir, owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.NewChValueInstance("new", "1", reflect.ValueOf(ch), reflect.BothDir, owners)
	if err != nil && !e.Equal(err, ErrInstExists) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	err = instances.NewChValueInstance("new", "2", reflect.ValueOf(ch), reflect.BothDir, ownersWrong)
	if err != nil && !e.Equal(err, ErrOwnerNotMatch) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}

	inst, err := instances.Get("new", "1")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	if inst.Instance().Type() != reflect.TypeOf(ch) {
		t.Fatal("get fail")
	}
}
Ejemplo n.º 5
0
func TestNew(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("1", "1", reflect.ValueOf(&teststruct{}), owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("1", "1", reflect.ValueOf(&teststruct{}), owners)
	if err != nil && !e.Equal(err, ErrInstExists) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	err = instances.New("1", "2", reflect.ValueOf(&structnomethods{}), owners)
	if err != nil && !e.Equal(err, ErrNoMethods) {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("1", "3", reflect.ValueOf(&teststruct{}), owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	ownersWrong := auth.NewPlainTextCredentials()
	err = ownersWrong.Add(&auth.PlainText{"id2", "passssss"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("1", "4", reflect.ValueOf(&teststruct{}), ownersWrong)
	if err != nil && !e.Equal(err, ErrOwnerNotMatch) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
}
Ejemplo n.º 6
0
func TestExportGet(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("sess", "testexport", reflect.ValueOf(&TestExport{}), owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.Export("sess", "testexport", &ToExport{
		Method:    "TestRetval",
		RetvalPos: 0,
		Export: &Export{
			Client: &TestExportClient{},
		},
	})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = instances.ExportGet("sess", "testexport", "TestRetval", 0)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = instances.ExportGet("invalid sess", "testexport", "TestRetval", 0)
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	_, err = instances.ExportGet("sess", "testexport__", "TestRetval", 0)
	if err != nil && !e.Equal(err, ErrInstanceNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	_, err = instances.ExportGet("sess", "testexport", "TestRetval__", 0)
	if err != nil && !e.Equal(err, ErrMethodNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
	_, err = instances.ExportGet("sess", "testexport", "TestRetval", 999)
	if err != nil && !e.Equal(err, ErrReturnValueNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}
}
Ejemplo n.º 7
0
func BenchmarkCall(b *testing.B) {

	instances := core.NewInstances()

	owners := auth.NewPlainTextCredentials()
	id = &auth.PlainText{Ident: "id", Pass: "******"}
	owners.Add(id)

	constructor := core.NewConstructor()

	server = &core.Server{
		Proto:       "tcp",
		Addr:        "localhost:0",
		ConnTimeout: 30 * time.Second,
		Insts:       instances,
		Cons:        constructor,
		FifoLength:  1,
		Ttl:         24 * time.Hour,
		Cleanup:     5 * time.Minute,
	}
	server.Start()

	err := instances.New("1", "2", reflect.ValueOf(&Struct1{}), owners)
	if err != nil {
		b.Error(e.Trace(e.Forward(err)))
	}

	s1 := &Struct1Client{
		Net:         "tcp",
		Addrs:       server.Address().String(),
		Auth:        &auth.PlainText{"id", "pass1234"},
		Session:     "1",
		Instance:    "2",
		PointerRecv: true,
	}
	err = s1.Init(true)
	if err != nil {
		b.Error(e.Trace(e.Forward(err)))
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		s1.Func1()
	}
}
Ejemplo n.º 8
0
func (p *protoServer) newInst(sess string, a auth.Auth, obj string, args ...interface{}) (string, error) {
	val, err := p.Cons.Construct(obj, args...)
	if err != nil {
		return "", e.Forward(err)
	}
	inst, err := rand.Chars(16, rand.NumberLetters, "go")
	if err != nil {
		return "", e.Forward(err)
	}
	owners := auth.NewPlainTextCredentials()
	err = owners.Add(a)
	if err != nil {
		return "", e.Forward(err)
	}
	err = p.Insts.New(sess, inst, val, owners)
	if err != nil {
		return "", e.Forward(err)
	}
	return inst, nil
}
Ejemplo n.º 9
0
func TestServer(t *testing.T) {
	instances = core.NewInstances()

	owners = auth.NewPlainTextCredentials()
	id = &auth.PlainText{Ident: "id", Pass: "******"}
	owners.Add(id)

	constructor = core.NewConstructor()

	server = &core.Server{
		Proto:       "tcp",
		Addr:        "localhost:0",
		ConnTimeout: 30 * time.Second,
		Insts:       instances,
		Cons:        constructor,
		FifoLength:  1,
		Ttl:         24 * time.Hour,
		Cleanup:     5 * time.Minute,
	}
	server.Start()
}
Ejemplo n.º 10
0
func TestMain(m *testing.M) {
	insts := NewInstances()
	owners := auth.NewPlainTextCredentials()
	id = &auth.PlainText{Ident: "dummy", Pass: "******"}
	owners.Add(id)
	err := insts.New("0", "0", reflect.ValueOf(Dummy{}), owners)
	if err != nil {
		log.Fatal(err)
	}
	cons := NewConstructor()
	server = &Server{
		Proto:       "tcp",
		Addr:        "localhost:0",
		ConnTimeout: 30 * time.Second,
		Insts:       insts,
		Cons:        cons,
		FifoLength:  1,
		Ttl:         24 * time.Hour,
		Cleanup:     5 * time.Minute,
	}
	server.Start()
	os.Exit(m.Run())
}
Ejemplo n.º 11
0
func TestServer(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	constructor := NewConstructor()
	instances := NewInstances()
	err = instances.New("1", "1", reflect.ValueOf(Calc{}), owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("1", "2", reflect.ValueOf(&TestExport{}), owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.Export("1", "2", &ToExport{Method: "TestRetval", RetvalPos: 0, Export: &Export{Client: &ResultClient{}}})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.New("1", "3", reflect.ValueOf(&TestChannel{}), owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	serverTest = &Server{
		Proto:       "tcp",
		Addr:        "localhost:0",
		ConnTimeout: 30 * time.Second,
		Insts:       instances,
		Cons:        constructor,
		FifoLength:  1000,
		Ttl:         24 * time.Hour,
		Cleanup:     5 * time.Minute,
	}
	serverTest.Start()
	t.Log(serverTest.Address())
}
Ejemplo n.º 12
0
func Example() {
	// Create a database of credentials
	owners := auth.NewPlainTextCredentials()
	// Authorize the user id
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		log.Error(err)
	}
	// Constructors
	constructor := core.NewConstructor()
	// Struct with the instances
	instances := core.NewInstances()
	// New instance of a calculator.
	err = instances.New("1", "1", reflect.ValueOf(dummy.Calculator{}), owners)
	if err != nil {
		log.Error(err)
	}
	// Export the return value 0 of BigAdd with the client ResultClient
	err = instances.Export("1", "1", &core.ToExport{Method: "BigAdd", RetvalPos: 0, Export: &core.Export{Client: &dummy.ResultClient{}}})
	if err != nil {
		log.Error(err)
	}

	// Create the server
	server := &core.Server{
		Proto:       "tcp",
		Addr:        "localhost:0",
		ConnTimeout: 30 * time.Second,
		Insts:       instances,
		Cons:        constructor,
		FifoLength:  1,
		Ttl:         24 * time.Hour,
		Cleanup:     5 * time.Minute,
	}

	// Start the server
	server.Start()
	defer server.Close()

	// Configure the client
	calc := &dummy.CalculatorClient{
		Net:         "tcp",
		Addrs:       server.Address().String(),
		Auth:        &auth.PlainText{"id", "pass1234"},
		Session:     "1",
		Instance:    "1",
		PointerRecv: true,
	}

	// Use the client API
	result := calc.Add(2, 40)
	err = calc.Error()
	if err != nil {
		log.Error(err)
	}
	fmt.Println(result)

	res := calc.BigAdd(2, 40)
	err = calc.Error()
	if err != nil {
		log.Error(err)
		return
	}
	fmt.Println(res.Get())

	err = calc.Destroy()
	if err != nil {
		log.Error(err)
	}
	//Output:
	//42
	//42
}
Ejemplo n.º 13
0
func TestOwner(t *testing.T) {
	owners := auth.NewPlainTextCredentials()
	err := owners.Add(&auth.PlainText{"id", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = owners.Add(&auth.PlainText{"id2", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}

	err = instances.SetOwner("1", owners)
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = instances.SetOwner("101", owners)
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("err is nil")
	}

	_, err = instances.Owners("69")
	if err != nil && !e.Equal(err, ErrSessionNotFound) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}

	o, err := instances.Owners("1")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = o.Get("id2")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	_, err = o.Get("id3")
	if err != nil && !e.Equal(err, auth.ErrCredNotExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}

	err = o.Delete("id2")
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = o.Delete("id2")
	if err != nil && !e.Equal(err, auth.ErrCredNotExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}

	err = o.Add(&auth.PlainText{"id3", "pass1234"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = o.Add(&auth.PlainText{"id3", "pass1234"})
	if err != nil && !e.Equal(err, auth.ErrCredExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}

	err = o.Edit(&auth.PlainText{"id3", "pass6969"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = o.Edit(&auth.PlainText{"id4", "pass4242"})
	if err != nil && !e.Equal(err, auth.ErrCredNotExist) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}

	err = auth.Validate(o, &auth.PlainText{"id3", "pass6969"})
	if err != nil {
		t.Fatal(e.Trace(e.Forward(err)))
	}
	err = auth.Validate(o, &auth.PlainText{"id3", "seilaseila"})
	if err != nil && !e.Equal(err, auth.ErrIdOrPasswdNotValid) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}
	err = auth.Validate(o, &auth.PlainText{"id4", "seilaseila"})
	if err != nil && !e.Equal(err, auth.ErrIdOrPasswdNotValid) {
		t.Fatal(e.Trace(e.Forward(err)))
	} else if err == nil {
		t.Fatal("error is nil")
	}
}
Ejemplo n.º 14
0
func main() {
	instances := core.NewInstances()

	owners := auth.NewPlainTextCredentials()
	id := &auth.PlainText{Ident: "id", Pass: "******"}
	owners.Add(id)

	constructor := core.NewConstructor()

	server := &core.Server{
		Proto:       "tcp",
		Addr:        "localhost:0",
		ConnTimeout: 30 * time.Second,
		Insts:       instances,
		Cons:        constructor,
		FifoLength:  1,
		Ttl:         24 * time.Hour,
		Cleanup:     5 * time.Minute,
	}
	server.Start()

	err := instances.New("1", "2", reflect.ValueOf(&dummy.Struct1{}), owners)
	if err != nil {
		log.Fatal(e.Trace(e.Forward(err)))
	}
	s1 := &dummy.Struct1Client{
		Net:         "tcp",
		Addrs:       server.Address().String(),
		Auth:        id,
		Session:     "1",
		Instance:    "2",
		PointerRecv: true,
	}

	str, err := s1.Func1()
	if err != nil {
		log.Fatal(e.Trace(e.Forward(err)))
	}
	if str == nil {
		log.Fatal("nil str")
	}
	if *str != "string" {
		log.Fatal("wrong string", *str)
	}

	log.Println("Destroy...")
	err = s1.Destroy()
	if err != nil {
		log.Fatal(e.Trace(e.Forward(err)))
	}
	log.Println("Close client...")
	err = s1.CloseClient()
	if err != nil {
		log.Fatal(e.Trace(e.Forward(err)))
	}
	log.Println("Close client...")
	err = server.Close()
	if err != nil {
		log.Fatal(e.Trace(e.Forward(err)))
	}

	panic("hi")
}
Ejemplo n.º 15
0
func (s *Server) protoCall(conn InstConn) (err error) {
	enc := conn.Encoder()
	dec := conn.Decoder()
	defer func() {
		if err != nil {
			err = enc.Encode(&respCall{Err: err})
			if err != nil {
				log.ProtoLevel().Tag("server", "gormethods").Printf("Encode %v -> %v (%v) error: %v", conn.RemoteAddr(), conn.LocalAddr(), conn.StreamNum(), err)
				err = e.Push(err, ErrWire)
			}
		}
	}()

	inst, err := s.Insts.Get(conn.SessionName(), conn.InstanceName())
	if err != nil {
		log.Tag("server", "gormethods").Errorf("Error getting the instance %v/%v: %v", conn.SessionName(), conn.InstanceName(), e.Forward(err))
		err = e.Forward(err)
		return
	}

	if inst.Type() != WithValue {
		log.Tag("server", "gormethods").Errorf("Instance %v/%v is of wrong type", conn.SessionName(), conn.InstanceName())
		return e.New("instance is of wrong type")
	}

	log.ProtoLevel().Tag("gormethods", "server", "call").Printf("Call %v %v %v", conn.SessionName(), conn.InstanceName(), types.NameOf(inst.Instance().Type()))

	var req reqCall
	err = dec.Decode(&req)
	if e.Find(err, io.EOF) >= 0 {
		return e.Push(err, ErrWire)
	} else if err != nil {
		log.ProtoLevel().Tag("server", "gormethods").Printf("Decode %v -> %v (%v) error: %v", conn.RemoteAddr(), conn.LocalAddr(), conn.StreamNum(), err)
		err = e.Push(err, ErrWire)
		return
	}

	// Tratar argumentos (req.Args) com channel

	// 	criar channel
	// 	recebe do channel envia pelo conn
	// 	recebe do conn envia para channel
	// 	(faz isso até fechar o channel em um dos lados)

	// substutui em req.Args os channels

	// Se existem channels enviar instancias

	err = s.mkChServer(conn, req.Args, enc)
	if err != nil {
		err = e.Forward(err)
		log.Tag("server", "gormethods").Errorf("Channel arguments setup failed: %v", err)
		return
	}

	method := inst.Instance().MethodByName(req.Method)
	if !method.IsValid() {
		err = e.Push(e.New(ErrMethodNotFound), e.New("method %v not found", req.Method))
		log.Tag("server", "gormethods").Errorf("Error in call %v/%v: %v", conn.SessionName(), conn.InstanceName(), err)
		return
	}
	log.ProtoLevel().Tag("server", "gormethods").Printf("Call %v/%v %v %v", conn.SessionName(), conn.InstanceName(), types.NameOf(inst.Instance().Type()), req.Method)
	var retvals []reflect.Value
	if method.Type().IsVariadic() {
		retvals = method.CallSlice(req.Args)
	} else {
		retvals = method.Call(req.Args)
	}
	log.ProtoLevel().Tag("server", "gormethods").Printf("Call returned %v/%v %v %v", conn.SessionName(), conn.InstanceName(), types.NameOf(inst.Instance().Type()), req.Method)
	for i := range retvals {
		var exp *Export
		exp, err = s.Insts.ExportGet(conn.SessionName(), conn.InstanceName(), req.Method, i)
		if err != nil {
			continue
		}
		var instname string
		instname, err = rand.Chars(16, rand.NumberLetters, "go")
		if err != nil {
			err = e.Push(err, "can't create the instance name for exported retval")
			log.Tag("server", "gormethods").Errorf("Error in call %v/%v: %v", conn.SessionName(), conn.InstanceName(), err)
			return
		}
		owners := auth.NewPlainTextCredentials()
		err = owners.Add(conn.Auth())
		if err != nil {
			err = e.Push(err, "can't authorize the exported retval")
			log.Tag("server", "gormethods").Errorf("Error in call %v/%v: %v", conn.SessionName(), conn.InstanceName(), err)
			return
		}
		err = s.Insts.New(conn.SessionName(), instname, retvals[i], owners)
		if err != nil {
			err = e.Push(err, "can't crete the instance for the exported retval")
			log.Tag("server", "gormethods").Errorf("Error in call %v/%v: %v", conn.SessionName(), instname, err)
			return
		}
		for _, to := range exp.ToExport {
			err = s.Insts.Export(conn.SessionName(), instname, to)
			if err != nil {
				err = e.Push(err, e.New("can't export %v/%v %v %v %v to %v", conn.SessionName(), instname, to.Method, to.RetvalPos, types.Name(retvals[i].Interface()), types.Name(exp.Client)))
				log.Tag("server", "gormethods").Errorf("Error in call %v/%v: %v", conn.SessionName(), conn.InstanceName(), err)
				return
			}
		}
		exp.Client.Associate(conn.SessionName(), instname, conn.Auth())
		retvals[i] = reflect.ValueOf(exp.Client)
		continue
	}
	log.ProtoLevel().Tag("server", "gormethods").Printf("Send returned values %v/%v %v %v", conn.SessionName(), conn.InstanceName(), types.NameOf(inst.Instance().Type()), req.Method)
	err = enc.Encode(&respCall{
		Vals: retvals,
		Err:  nil,
	})
	if err != nil {
		log.ProtoLevel().Tag("server", "gormethods").Printf("Encode %v -> %v (%v) error: %v", conn.RemoteAddr(), conn.LocalAddr(), conn.StreamNum(), err)
		err = e.Push(err, ErrWire)
		return
	}
	log.ProtoLevel().Tag("server", "gormethods").Printf("Send returned values done %v/%v %v %v", conn.SessionName(), conn.InstanceName(), types.NameOf(inst.Instance().Type()), req.Method)
	return
}