Score
0
Watch 27 Star 37 Fork 18

loogn / StardustC#

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
.net微服务架构 spread retract

Clone or download
Loading...
README.md

#Stardust

Stardust是一个.net微服务架构的一个简单实现。

http://www.cnblogs.com/loogn/p/6664594.html

JAVA版

##Service:

public class User
{
    public string Name { get; set; }
}

//[StardustName("User")] //默认是类名,如果类名以Service结尾,会把Service去掉
public class UserService : IStardustService
{
    //[StardustName("hello")] //默认是方法名,可以StardustNameAttribute来自定义
    public string Hello(string name, int count = 1)
    {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < count; i++)
        {
            sb.AppendFormat("Hello,{0}!{1}", name, Environment.NewLine);
        }
        return sb.ToString();
    }
    public Task<string> HelloAsync()
    {
        return new Task<string>(() =>
        {
            return "Hello World";
        });
    }

    public List<User> UpdateUsers(List<User> list)
    {
        foreach (var user in list)
        {
            user.Name = "Updated:" + user.Name;
        }
        return list;
    }
}

##Client:

var client = new StardustClient("server1", "1.1");
var str = client.Invoke<string>("user", "hello", new { name = "Jack", count = 2 });
//var task=client.InvokeAsync<string>("user", "hello", new { name = "Jack", count = 2 }); // 或者异步调用

Comments ( 0 )

Sign in for post a comment

C#
1
https://git.oschina.net/loogn/Stardust.git
git@git.oschina.net:loogn/Stardust.git
loogn
Stardust
Stardust
master

Search