Create your Gitee Account
Explore and code with more than 6 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.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
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

About

Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more