基于服务的架构不一定意味着分配?(services based architecture should not necessarily imply distribution?)

在我的工作场所(以及许多其他领域),人们非常重视围绕服务构建架构。 (我在电子商务初创公司工作)。 但是,我认为服务被隐含地视为分布式的。 我是第一个分配法则的信徒 - “不分发”。 所以,我认为我们不应该必然使架构复杂化。 它应该是一个可以发展的架构。 因此,解决问题的方法之一是创建定义良好的命名空间并围绕它构建代码,但通过java api保持通信。 (这使得监控要求低,可靠性/可用性问题低)。 通过将模块包装到Web服务中,可以轻松地将其演变为分布式体系结构,并且当规模要求启动时。 因此,问题是 - 将代码编写为单个应用程序并演变为分布式服务的缺点是什么,而不是直接跳入实现基于Web服务的体系结构? 我是否正确地假设服务应该暗示设计的基本原则(抽象,封装等),而不是通过网络分发?


In my workplace (and a lot of other areas), there is a lot of emphasis on building architecture around services. (I am working in an e-commerce startup). However, I think services are implicitly considered as distributed. I am a believer of the first law of distribution - "don't distribute". So, I believe that we should not un-necessarily complicate architecture. It should be an architecture which can evolve. So, one of the ways to approach the problem would be to create well defined namespaces and build code around it, but keep the communication via java api. (this keeps monitoring requirement low, and reliability/availability problems low). This can easily be evolved into a distributed architecture by wrapping modules into web service, as and when, the scale requirements kick-in. So, the question is - what are the cons of writing code as a single application and evolving into distributed services, rather than straight jumping into implementing web services based architecture? Am I right in assuming that services should imply the basic principles of design (abstraction, encapsulation etc), rather than distribution over network?


原文:https://stackoverflow.com/questions/7457160
2022-03-10 09:03

满意答案

func (o *MongoOps) AddToBsonMapElement(lstMap map[string]interface{},     Operation string, key string, value interface{}) (result map[string]interface{})     {
status, msg := EmptyStructCheck(o)
if status == true {
    LogError(msg)
    panic(msg)
}
if Operation == "$addToSetEach" {
    if _, ok := lstMap["$addToSet"]; ok {
        childmap := lstMap["$addToSet"]
        subchildmap := childmap.(map[string]interface{})
        var val map[string]interface{}
        val = make(map[string]interface{})
        val["$each"] = value
        subchildmap[key] = val
        lstMap["$addToSet"] = subchildmap

    } else {
        lstMap["$addToSet"] = bson.M{key: bson.M{"$each": value}}
    }

    fmt.Println(reflect.TypeOf(lstMap))
} else if _, ok := lstMap[Operation]; ok {
    childmap := lstMap[Operation]
    subchildmap := childmap.(map[string]interface{})
    subchildmap[key] = value
    lstMap[Operation] = subchildmap

} else {
    childmap := make(map[string]interface{}, 0)
    childmap[key] = value
    lstMap[Operation] = childmap
}

return lstMap
}

这是你可以尝试的


func (o *MongoOps) AddToBsonMapElement(lstMap map[string]interface{},     Operation string, key string, value interface{}) (result map[string]interface{})     {
status, msg := EmptyStructCheck(o)
if status == true {
    LogError(msg)
    panic(msg)
}
if Operation == "$addToSetEach" {
    if _, ok := lstMap["$addToSet"]; ok {
        childmap := lstMap["$addToSet"]
        subchildmap := childmap.(map[string]interface{})
        var val map[string]interface{}
        val = make(map[string]interface{})
        val["$each"] = value
        subchildmap[key] = val
        lstMap["$addToSet"] = subchildmap

    } else {
        lstMap["$addToSet"] = bson.M{key: bson.M{"$each": value}}
    }

    fmt.Println(reflect.TypeOf(lstMap))
} else if _, ok := lstMap[Operation]; ok {
    childmap := lstMap[Operation]
    subchildmap := childmap.(map[string]interface{})
    subchildmap[key] = value
    lstMap[Operation] = subchildmap

} else {
    childmap := make(map[string]interface{}, 0)
    childmap[key] = value
    lstMap[Operation] = childmap
}

return lstMap
}

This is what you can try

相关问答

更多

如何使用Go和mgo使用mongodb投影?(How can I use mongodb projections with Go and mgo?)

如果文档声明这样可以选择哪些字段应该被检索以找到结果,那么将使用Select方法,因此使用$elemMatch运算符的投影可以与Select结合使用,最终查询如下所示: c.Find(bson.M{ "_id": bson.ObjectIdHex(p.ByName("id")) }).Select(bson.M{ "races": bson.M{ "$elemMatch": bson.M{ "_id": bson.ObjectIdHex(p....

如何根据输入创建bson地图(how to create bson map based on input)

这个怎么样: func buildBsonObject(value_1 string, value_2 string) bson.M { m := bson.M{ "$match": bson.M{ "xyz": "abc", }, } if value_1 != "" { m["$id_1"] = value_1 } if value_2 != "" { m["$id_2"] = value_2 } return m }...

使用golang和mongodb进行顺序查询(Sequential queries with golang & mongodb)

以下是如何使用从其他查询返回的文档的ID来构造查询。 var docs []bson.M if err := c.Find(query).All(&docs); err != nil { // handle error } docIDs := make([]interface{}, len(docs)) for i := range docs { docIds[i] = docs[i]["_id"] } query = bson.M{"_id": bson.M{"$in"...

Golang获取特定结构字段名称的字符串表示(Golang get string representation of specific struct field name)

我真的不觉得有。 您可以通过反射来加载一组类型,并为字段名称生成一组常量。 所以: type Test struct { Field string `bson:"Field" json:"field"` OtherField int `bson:"OtherField" json:"otherField"` } 可能会生成如下内容: var TestFields = struct{ Field string OtherField strin...

mgo具有聚合和分组功能(mgo with aggregation and grouping)

你获得NULL的原因是你的$match过滤器在$group阶段之后过滤掉所有文件。 在$group的第一阶段之后,文档仅如下例所示: {"_id": { "user": "foo"}}, {"_id": { "user": "bar"}}, {"_id": { "user": "baz"}} 它们不再包含其他字段,即user , date_updated和organization 。 如果您想保留其值,可以使用Group Accumulator Operator 。 根据您的使用情况...

使用预先构建的字符串作为bson.M以便在mgo中进行查询(Use a pre-constructed string as bson.M for mgo query in go)

我通过Unmarshalling finalbody找到了解决方案[string] interface {},然后将其用作更新映射。 所以, finalbody, err := json.Marshal(body) var finalbodymap map[string]interface{} json.Unmarshal(finalbody, &finalbodymap) 当然,你需要添加一些错误处理,所以最终的代码看起来像这样 - finalbody, err := json.Marshal...

Golang BSON转换(Golang BSON conversion)

就你而言,这将是: bson.M{"$or": []bson.M{ {"dependencies.provider_id": "abc"}, {"actions.provider_id": "abc"}, }} In your case, it would be: bson.M{"$or": []bson.M{ {"dependencies.provider_id": "abc"}, {"actions.provider_id": "abc"}, }}

golang中的Mongodb聚合(Mongodb aggregation in golang)

更改 err1 := pipe.One(&results) 至 err1 := pipe.All(&results) Change err1 := pipe.One(&results) to err1 := pipe.All(&results)

如何将bson.M元素列表合并到golang中的mongo中的单个bson.M中?(How do i combine list of bson.M elements into a single bson.M in mongo in golang?)

func (o *MongoOps) AddToBsonMapElement(lstMap map[string]interface{}, Operation string, key string, value interface{}) (result map[string]interface{}) { status, msg := EmptyStructCheck(o) if status == true { LogError(msg) panic(msg) } ...

用户搜索Golang mgo(User search with Golang mgo)

例如,mongo过滤器可以采用正则表达式; bson.M{"title": bson.M{"$regex": bson.RegEx{Pattern: title, Options: "i"}}} 所以在这种情况下,标题变量将是这样的; .*abc*. 。 选项:“i”使案例不敏感。 至于匹配子字符串(方案2),我不确定如何在正则表达式中实现。 The mongo filter can take regex, for example; bson.M{"title":...

相关文章

更多

Stack Overflow Architecture Update - Now At 95 Million Page Views A Month

A lot has happened since my first article on theSta ...

Java-based 实现的索引复制

solr 包含一个基于 Java-based 实现的索引复制,通过http方式完成。 这 ...

Solr Architecture[转]

Lucene/Solr plugins •RequestHandlers – handle a r ...

hadoop发行版本

Azure HDInsight Azure HDInsight is Microsoft's dis ...

铁杆Java开发者不一定最适合Hadoop

导读:一位朋友两年前参加在纽约举办的Hadoop会议时只有寥寥200余人,而两年后的6月,还是同样的时 ...

网站架构之分库设计

转自http://www.infoq.com/cn/articles/yupoo-partition- ...

Yupoo网站架构学习总结(转)

来源:http://www.itivy.com/ivy/archive/2011/8/16/the-a ...

[How to] Make custom search with Nutch(v 1.0)?(转)

http://puretech.paawak.com/2009/04/29/how-to-make-c ...

(转)云计算核心论文

Google 1. nosqldbs-NOSQL Introduction and Overview ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本