码迷,mamicode.com
首页 > 其他好文 > 详细

Orleans学习总结(一)

时间:2018-02-14 11:43:50      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:rom   一个   containe   业务逻辑   building   sof   syn   定位   services   

最近这段时间接触了些新的东西:Orleans框架。今天是春节前最后一天班,把我这段时间学习的东西总结一下分享给大家。

 

一、什么是Orleans

文档地址。这里我就直接翻译官方的介绍,有点地方翻译的有些蹩脚大家见谅。后面在使用场景上我会结合我们自己项目来说)

 

A straightforward approach to building distributed, high-scale applications in .NET

一个简单直接的大规模分布式的.Net应用

 

Orleans is a framework that provides a straightforward approach to building distributed high-scale computing applications, without the need to learn and apply complex concurrency or other scaling patterns. It was created by Microsoft Research and designed for use in the cloud.

Orleans 是一个提供简单直接的大规模分布式的计算应用,而不需要去了解复杂的高并发和其他相关。由微软研究和设计用于云端。

 

Orleans has been used extensively in Microsoft Azure by several Microsoft product groups, most notably by 343 Industries as a platform for all of Halo 4 and Halo 5 cloud services, as well as by a growing number of other companies.

Orleans 已经被几个微软的产品组用在Microsoft Azure云。值得一提的就是343公司《光环4》和《光环5》的云平台服务,和越来越多的其他公司

 

Orleans as a Stateful Middle Tier

Orleans 作为一个有状态的中间层

 

Orleans provides an intuitive way of building a stateful middle tier, where various business logic entities appear as sea of isolated globally addressable .NET objects (grains) of different application defined types distributed across a cluster of servers (silos).

Orleans提供一个直观的方式建造一个有状态的中间层,各种业务逻辑对象存在于一个可以全局定位的独立的不通应用类型.NET对象 的集群海洋里。

技术分享图片

二、用法

In Orleans, grains are the building blocks of application code. Grains are instances of .NET classes that implement a conforming interface. Asynchronous methods of the interface are used to indicate which operations the grain can perform:
在Orleans里,谷物是用来建造应用程序的基础(大概是一个基础单位的意思)。谷物是一个实现了一个确定的.Net接口的类的实例。接口的异步方法用来指明这个谷物能提供哪些操作。
public interface IMyGrain : IGrainWithStringKey
{
    Task<string> SayHello(string name);
}

 

The implementation is executed inside the Orleans framework:

实现是在Orleans框架里执行的

public class MyGrain : IMyGrain
{
    public Task<string> SayHello(string name)
    {
        return Task.FromResult($"Hello {name}");
    }
}

 

You can then invoke the grain by obtaining a proxy object (a grain reference), and calling the methods:

你可以通过获取一个代理对象(一个谷物的接口)触发一个grain,并且掉用他的方法。

var grain = GrainClient.GrainFactory.GetGrain<IMyGrain>("grain1");
await grain.SayHello("World");

 

三、总结

Orleans就是一个把高并发等复杂的细节隐藏在后面的分布式框架,让我们能快速的实现一个大规模可扩展的分布式应用。

在Orleans编程的世界里,你最主要有两个关注点:

1、定义接口

2、所有方法皆异步

当然还有很多其他的feature和注意点,需要我们去探索

 

Orleans学习总结(一)

标签:rom   一个   containe   业务逻辑   building   sof   syn   定位   services   

原文地址:https://www.cnblogs.com/mrblue/p/8447978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!