锘??xml version="1.0" encoding="utf-8" standalone="yes"?>人妻无码αv中文字幕久久 ,热久久视久久精品18,久久久久久国产a免费观看不卡http://www.shnenglu.com/jinq0123/category/5141.htmlzh-cnSun, 24 Apr 2022 06:08:58 GMTSun, 24 Apr 2022 06:08:58 GMT60TortoiseGit is OK but GitExtensions failshttp://www.shnenglu.com/jinq0123/archive/2022/04/24/229292.html閲戝簡閲戝簡Sun, 24 Apr 2022 06:01:00 GMThttp://www.shnenglu.com/jinq0123/archive/2022/04/24/229292.htmlhttp://www.shnenglu.com/jinq0123/comments/229292.htmlhttp://www.shnenglu.com/jinq0123/archive/2022/04/24/229292.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/229292.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/229292.htmlTortoiseGit is OK but GitExtensions fails

GitExtensions and Git fail:

      "git" pull --progress "origin"
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Done
Press Enter or Esc to exit...

    

But TortoiseGit is OK.

      git.exe pull --progress -v --no-rebase "origin"
From github.com:jinq0123/recastnavigation
= [up to date]      master      -> origin/master
= [up to date]      release-2.0 -> origin/release-2.0
Already up to date.

    

ssh -T shows that the reason is there is no id files:

      PS d:\github> ssh -vT git@github.com
OpenSSH_for_Windows
debug1: Connecting to github.com [20.205.243.166] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\jinqing/.ssh/id_rsa type -1
debug1: identity file C:\\Users\\jinqing/.ssh/id_xmss-cert type -1
debug1: Authenticating to github.com:22 as 'git'
debug1: Host 'github.com' is known and matches the ED25519 host key.
debug1: Found key in C:\\Users\\jinqing/.ssh/known_hosts:2
debug1: Will attempt key: C:\\Users\\jinqing/.ssh/id_rsa
debug1: Will attempt key: C:\\Users\\jinqing/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: C:\\Users\\jinqing/.ssh/id_rsa
debug1: Trying private key: C:\\Users\\jinqing/.ssh/id_xmss
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
PS d:\github>

    

Copy my RSA key file rsa.ppk that TortoiseGit uses as ~/.ssh/id_rsa:

      PS D:\jinqing\github_jinq\recastnavigation> ssh -T git@github.com
Load key "C:\\Users\\jinqing/.ssh/id_rsa": invalid format
git@github.com: Permission denied (publickey).
PS D:\jinqing\github_jinq\recastnavigation>

    

Open TortoiseGit/bin/puttygen.exe, load rsa.ppk, then Convensionis->Export OpenSSH key as ~/.ssh/id_rsa:

      PS D:\jinqing\github_jinq\recastnavigation> ssh -T git@github.com
Hi jinq0123! You've successfully authenticated, ...

    

id_rsa begins with:

      -----BEGIN RSA PRIVATE KEY-----

    


閲戝簡 2022-04-24 14:01 鍙戣〃璇勮
]]>
DeathVoteExpirationTimeout in Orleanshttp://www.shnenglu.com/jinq0123/archive/2021/12/08/217872.html閲戝簡閲戝簡Wed, 08 Dec 2021 01:43:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/12/08/217872.htmlhttp://www.shnenglu.com/jinq0123/comments/217872.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/12/08/217872.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217872.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217872.htmlDeathVoteExpirationTimeout in Orleans

(Jin Qing's Column, Dec., 2021)

Try to find out why Orleans need a DeathVoteExpirationTimeout config.

https://dotnet.github.io/orleans/docs/implementation/cluster_management.html#extension-to-totally-order-membership-views

DeathVoteExpirationTimeout - Expiration time in seconds for death vote in the membership table. Default is 120 seconds
GetFreshVotes

DeathVoteExpirationTimeout is only used by GetFreshVotes(), which has 3 occurence:

    class ClusterHealthMonitor
    {
        ...
        private UpdateMonitoredSilos(...)
        {
            ...
            bool isSuspected = candidateEntry.GetFreshVotes(now, DeathVoteExpirationTimeout).Count > 0;
            ...
        }
    }
    class LocalSiloHealthMonitor
    {
        ...
        private int CheckSuspectingNodes(DateTime now, List<string> complaints)
        {
            ...
            var freshVotes = membershipEntry.GetFreshVotes(now, DeathVoteExpirationTimeout);
            ...
        }
        ...
    }
    class MembershipTableManager
    {
        ...
        public TryToSuspectOrKill(SiloAddress silo)
        {
            ...
            // get all valid (non-expired) votes
            var freshVotes = entry.GetFreshVotes(DateTime.UtcNow, DeathVoteExpirationTimeout);
            ...
        }
        ...
    }

GetFreshVotes() uses this expiration time to ignore old voter:

        internal GetFreshVotes(DateTime now, TimeSpan expiration)
        {
            ...
            foreach (var voter in this.SuspectTimes)
            {
                var otherVoterTime = voter.Item2;
                if (now.Subtract(otherVoterTime) < expiration)
                {
                    result.Add(voter);
                }
            }
            return result.ToImmutable();
        }


閲戝簡 2021-12-08 09:43 鍙戣〃璇勮
]]>
How to delete local branches of GitExtensionhttp://www.shnenglu.com/jinq0123/archive/2021/12/07/217870.html閲戝簡閲戝簡Tue, 07 Dec 2021 09:04:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/12/07/217870.htmlhttp://www.shnenglu.com/jinq0123/comments/217870.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/12/07/217870.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217870.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217870.htmlHow to delete local branches of GitExtension

(Jin Qing's Column, Dec., 2021)

GitExtension is a good tool. After a long time of usage, my branch list finally reaches over a full screen, and it is hard to select the branch I want.

GitExtension always remembers all the branches of remote and local, even they have been deleted.

I tried to find a way to delete these branches which are already merged, but resulted in futile.

It has a plugin names "Delete obsolete branches", but I don't know how to use it.

Finally I renamed the work directory, and cloned a new one, which clears all the branches. It seems that these branches are stored in local .git directory. If let GitExt open the renamed directory, these branches reappears.

Reference:



閲戝簡 2021-12-07 17:04 鍙戣〃璇勮
]]>
Clustering provider in Orleanshttp://www.shnenglu.com/jinq0123/archive/2021/11/03/217852.html閲戝簡閲戝簡Wed, 03 Nov 2021 05:36:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/11/03/217852.htmlhttp://www.shnenglu.com/jinq0123/comments/217852.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/11/03/217852.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217852.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217852.htmlClustering provider in Orleans

(Jin Qing's Column, Nov. 3, 2021)

When deployed to a cluster of nodes, Orleans internally implements a protocol to manage it's silos, including discovery, failure and reconfigure, which is called cluster membership management.

Orleans has clustering membership providers for: Azure, SQL server, Zookeeper.

Clustering provider is one of key aspects of silo configuration.

Orleans.Clustering.Kubernetes

OrleansContrib/Orleans.Clustering.Kubernetes is a clustering provider for running Orleans cluster on Kubernetes.

Tell silo to use Kubernetes as the Cluster Membership Provider:

var silo = new SiloBuilder()
        ...
        .UseKubeMembership()
        ...
        .Build();

Interface

UseKubeMembership() instantiates a KubeMembershipTable which implements IMembershipTable.

    public interface IMembershipTable
    {
        Task InitializeMembershipTable(bool tryInitTableVersion);
        Task DeleteMembershipTableEntries(string clusterId);
        Task CleanupDefunctSiloEntries(DateTimeOffset beforeDate);
        Task<MembershipTableData> ReadRow(SiloAddress key);
        Task<MembershipTableData> ReadAll();
        Task<bool> InsertRow(MembershipEntry entry, TableVersion tableVersion);
        Task<bool> UpdateRow(MembershipEntry entry, string etag, TableVersion tableVersion);
        Task UpdateIAmAlive(MembershipEntry entry);
    }

Implement

KubeMembershipTable access Kubernetes API server to read and write silo entry CRD.

  • InitializeMembershipTable()

    • TryInitClusterVersion()

      • _kubeClient.GetNamespacedCustomObjectAsync
      • _kubeClient.CreateNamespacedCustomObjectAsync
  • DeleteMembershipTableEntries(string clusterId)

    • _kubeClient.DeleteNamespacedCustomObjectAsync
  • InsertRow(...)

    • _kubeClient.GetNamespacedCustomObjectAsync
    • _kubeClient.ReplaceNamespacedCustomObjectAsync
    • _kubeClient.CreateNamespacedCustomObjectAsync
  • ReadAll()

    • GetClusterVersion()

      • _kubeClient.ListNamespacedCustomObjectAsync
    • GetSilos()

      • _kubeClient.ListNamespacedCustomObjectAsync
  • ReadRow(SiloAddress key)

    • _kubeClient.GetNamespacedCustomObjectAsync
  • UpdateIAmAlive(MembershipEntry entry)

    • _kubeClient.GetNamespacedCustomObjectAsync
    • _kubeClient.ReplaceNamespacedCustomObjectAsync
  • UpdateRow(...)

    • _kubeClient.ReplaceNamespacedCustomObjectAsync
  • CleanupDefunctSiloEntries(DateTimeOffset beforeDate)

    • _kubeClient.DeleteNamespacedCustomObjectAsync

The operators to NamespacedCustomObject are:

  • Delete
  • Get
  • Create
  • Replace
  • List

CRD

Two CRDs, ClusterVersion and Silo are defined in files:

  • ClusterVersionCRD.yaml
  • SiloEntryCRD.yaml

Custom resource objects are stored in etcd of Kubernetes.



閲戝簡 2021-11-03 13:36 鍙戣〃璇勮
]]>
Why Orleans' actor is virutalhttp://www.shnenglu.com/jinq0123/archive/2021/11/02/217850.html閲戝簡閲戝簡Tue, 02 Nov 2021 07:27:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/11/02/217850.htmlhttp://www.shnenglu.com/jinq0123/comments/217850.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/11/02/217850.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217850.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217850.htmlWhy Orleans' actor is virutal

(Jin Qing's Column, Nov. 2, 2021)

Virtual Actor is a concept invented by Microsoft Orleans, which is a framework of distributed actor.

Orleans: Distributed Virtual Actors for Programmability and Scalability describes the virtual programming model.

The virtual actor is analogous to virtual memory. Virtual actors are mapped to physical arctors instances in the running servers. Virtualization of actors in Orleans has 4 facets:

  1. Perpetual existence

    • Actors always exist, virtually
    • Actors can not be created or destroied explicitly
    • Server failure does not affect the actors' existence
  2. Automatic instantiation

    • Activation: Orleans automatically create an actor
    • A request triggers an activation if the actor doesn't exist
    • Unused actors are automatically reclaimed
  3. Location transparency

    • Applications don't know where the physical actor is
    • Similar to virtual memory's "paged out" and mapping
  4. Automatic scale out

    • 2 activation modes:

      • Single activation (default): Only one simultaneous actor is allowed

      • Stateless worker: Many activations of an actor are created

        • to increase throughput

Actor viruliaztion greatly simplifes the programming, since it gets rid of the burden of actor lifecycle control.

 

 



閲戝簡 2021-11-02 15:27 鍙戣〃璇勮
]]>
What comes after microservice?http://www.shnenglu.com/jinq0123/archive/2021/10/29/217843.html閲戝簡閲戝簡Fri, 29 Oct 2021 03:16:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/10/29/217843.htmlhttp://www.shnenglu.com/jinq0123/comments/217843.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/10/29/217843.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217843.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217843.htmlWhat comes after microservice?

(Jin Qing's Column, Oct. 25, 2021)

Reading "The Evolution of Distributed Systems on Kubernetes" from Bilgin Ibryam.

https://www.infoq.com/articles/distributed-systems-kubernetes/

What are the purpose of projects like Dapr, Istio, Knative? How can they change the world?

Modern distributed systems

The needs of distributed systems:

  • Business logic

  • Other

    • Lifecycle: deploy, rollback, upgrade, scale, stop, isolate, config
    • Network: connect, circuit break, retry, timeout, load balance, discover, security, trace
    • Resource binding: to API, protocol, message, data format
    • State: stateless, stateful, store

Monolithic architecture

enterprise service bus (ESB): not distributed

Cloud-native architecture

Kubernetes: Lifecycle

Service Mesh

Istio: Networking

Serverless

Knative: scale

Dapr

Networking, resource binding, state

  • Lifecycle: Kubernetes + operator
  • Networking: Envoy
  • Binding: Apache Camel
  • State: Cloudstate

Multi-runtime microservice

Write business logic as another runtime. Here runtime is a process?

What comes after microservice

Faas is not the best. Multi-runtime microservice maybe is.

Mecha architecture

 



閲戝簡 2021-10-29 11:16 鍙戣〃璇勮
]]>
Rust Deref coercion examplehttp://www.shnenglu.com/jinq0123/archive/2021/08/22/217786.html閲戝簡閲戝簡Sun, 22 Aug 2021 04:31:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/08/22/217786.htmlhttp://www.shnenglu.com/jinq0123/comments/217786.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/08/22/217786.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217786.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217786.html
https://doc.rust-lang.org/std/ops/trait.Deref.html

```
use std::ops::Deref;

struct DerefExample<T> {
    value: T
}

impl<T> Deref for DerefExample<T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        &self.value
    }
}

let x = DerefExample { value: 'a' };
assert_eq!('a', *x);
```

Deref coercion can be used in newtype:
```
struct MyI32(i32)

impl Deref for MyI32 {
    type Target = i32;
    
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
```


閲戝簡 2021-08-22 12:31 鍙戣〃璇勮
]]>
Rust Error Return Check Policyhttp://www.shnenglu.com/jinq0123/archive/2021/08/09/217775.html閲戝簡閲戝簡Mon, 09 Aug 2021 09:08:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/08/09/217775.htmlhttp://www.shnenglu.com/jinq0123/comments/217775.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/08/09/217775.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217775.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217775.htmlError Return Check Policy
  • Never use unwrap on Result. If the type is Err, it will panic and crash the program. The only exception is if it has already been checked for error previously or in test code.
  • Never use unwrap on Option for the same reason if the type is None as Result is Err.


閲戝簡 2021-08-09 17:08 鍙戣〃璇勮
]]>
Rust visibilityhttp://www.shnenglu.com/jinq0123/archive/2021/08/09/217774.html閲戝簡閲戝簡Mon, 09 Aug 2021 05:45:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/08/09/217774.htmlhttp://www.shnenglu.com/jinq0123/comments/217774.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/08/09/217774.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217774.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217774.htmlVisibility and privacy - The Rust Reference (rust-lang.org)

pub(in path)pub(crate)pub(super), and pub(self)

In addition to public and private, Rust allows users to declare an item as visible only within a given scope. The rules for pub restrictions are as follows:

  • pub(in path) makes an item visible within the provided pathpath must be an ancestor module of the item whose visibility is being declared.
  • pub(crate) makes an item visible within the current crate.
  • pub(super) makes an item visible to the parent module. This is equivalent to pub(in super).
  • pub(self) makes an item visible to the current module. This is equivalent to pub(in self) or not using pub at all.


閲戝簡 2021-08-09 13:45 鍙戣〃璇勮
]]>
Why does Rust check borrow even in single threadhttp://www.shnenglu.com/jinq0123/archive/2021/08/07/217773.html閲戝簡閲戝簡Sat, 07 Aug 2021 08:05:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/08/07/217773.htmlhttp://www.shnenglu.com/jinq0123/comments/217773.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/08/07/217773.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217773.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217773.html
# Why does Rust check borrow even in single thread

(Jin Qing's Column, Aug. 7, 2021)

The Rust book says borrow checking is to prevent data race.
But the borrow checker forbids multiply mutable borrows even in the same thread.
Is there data race in single thread?
Why does the borrow checker forbid it in the same thread?

[The Problem With Single-threaded Shared Mutability](https://manishearth.github.io/blog/2015/05/17/the-problem-with-shared-mutability/)
answers this question.

It gaves 2 cases that shared mutability causes prolem.
One is Rust enum variable, which can has different inner type.
If the inner type changed, the references to the old data would be invalidated.
Another case is Iterator invalidation that the container's change can invalidate the Iterator.




閲戝簡 2021-08-07 16:05 鍙戣〃璇勮
]]>
UE4 Blueprint Multiple Event BeginPlayhttp://www.shnenglu.com/jinq0123/archive/2021/07/31/217765.html閲戝簡閲戝簡Sat, 31 Jul 2021 07:19:00 GMThttp://www.shnenglu.com/jinq0123/archive/2021/07/31/217765.htmlhttp://www.shnenglu.com/jinq0123/comments/217765.htmlhttp://www.shnenglu.com/jinq0123/archive/2021/07/31/217765.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217765.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217765.html
(閲戝簡鐨勪笓鏍?2021.7)

How to do multiple actions on Event BeginPlay in UE4 Blueprints?

Sams-Teach-Yourself-Unreal-Engine-4-Game-Development-in-24-Hours says:
```
Q. When I try to add a second event node, BeginPlay, the Editor shows me the first one already
placed in the Event Graph. Why does this happen?

A. Some events, such as Event Tick and the BeginPlay event, can have only one instance per
Blueprint.
```

https://forums.unrealengine.com/t/do-multiple-things-on-event-begin-play/411/10
```
The Sequence node allows for a single execution pulse to trigger a series of events in order. The node may have any number of outputs, all of which get called as soon as the Sequence node receives an input. They will always get called in order, but without any delay. To a typical user, the outputs will likely appear to have been triggered simultaneously.
```

Youtube video: [How to do Multiple Actions on Event Begin Play Unreal Engine 4 Blueprints](https://www.youtube.com/watch?v=nqG-ztbs230)

閲戝簡 2021-07-31 15:19 鍙戣〃璇勮
]]>
絎?浠f父鎴忎富鏈?/title><link>http://www.shnenglu.com/jinq0123/archive/2021/05/09/217680.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Sun, 09 May 2021 12:44:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2021/05/09/217680.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/217680.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2021/05/09/217680.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/217680.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/217680.html</trackback:ping><description><![CDATA[# 絎?浠f父鎴忎富鏈?br /><br />鍘熸枃錛歔Ninth generation of video game consoles](https://en.wikipedia.org/wiki/Ninth_generation_of_video_game_consoles)<br /><br />2020.11錛屽井杞?MS) Xbox Series X/S 鍜?Sony PlayStation 5 (PS5) 鍙戝竷錛屾爣蹇楃潃娓告垙涓繪満榪涘叆絎?浠c?br /><br />鍜屽墠浠g殑 Xbox One 鍜?PS4 鐩告瘮錛屾柊涓浠d富鏈烘湁鍙鐨勬ц兘鎻愬崌錛屾敮鎸佸疄鏃跺厜綰胯窡韙紝4K鍒嗚鯨鐜囷紝鐩爣甯х巼涓?0銆?br />鍐呴儴閮戒嬌鐢ㄤ簡鍥烘佺‖鐩?SSD)銆備綆閰嶇増娌℃湁鍏夐┍錛屼粎鏀寔緗戠粶鍜孶SB銆?br /><br />瀹氫綅涓婅鑳滆繃浠誨ぉ鍫係witch鍜屼簯娓告垙鏈嶅姟濡?Stadia 鍜?Amazon Luna.<br /><br />## 鑳屾櫙<br /><br />絎?浠f椂闂磋緝闀褲傚洜涓烘懇灝斿畾寰嬶紝榪囧幓鍑犱唬涓鑸瘡浠d負5騫存椂闂達紝浣嗘槸 MS 鍜?Sony 鍑轟簡涓棿浠d駭鍝?Xbox One X 鍜?PS4 Pro.<br /><br />2020.3 寮濮嬬殑 COVID-19 鐤儏褰卞搷涔熶嬌鏂頒竴浠d富鏈虹殑鍙戝竷寤跺悗浜嗐?br /><br />## 涓昏涓繪満<br /><br />### PS5<br /><br />鏈?涓満鍨嬶紝鍩烘湰鍨嬪拰鏁板瓧鍨嬶紝鏁板瓧鍨嬫病鏈夊厜椹辮緝渚垮疁錛屽叾浠栦竴鏍楓?br />PS5鍜孭S4鐨勬父鎴忓吋瀹癸紝鍙湁灝戦噺娓告垙涓嶆敮鎸侊紝浣嗘槸鍙互閫氳繃 PS Now 浜戞父鎴忔湇鍔$帺 PS4 娓告垙銆?br /><br />### Xbox Series X/S<br /><br />MS 寤剁戶浜嗗弻涓繪満妯″紡錛氶珮绔殑X緋誨垪鍜屼綆绔殑S緋誨垪銆係緋誨垪娌℃湁鍏夐┍銆?br />涓よ呴兘鏀寔澶栭儴瀛樺偍鍜孹box Live鍦ㄧ嚎鍒嗗彂銆傚悜鍚庡吋瀹逛互鍓嶇殑娓告垙錛屼絾涓嶅寘鎷琄inect娓告垙銆?br />MS榧撳姳寮鍙戝晢浣跨敤 Smart Delivery錛屾妸Xbox One娓告垙鍗囩駭鍒癤box Series X/S銆?br /><br />## 鍏朵粬涓繪満<br /><br />* 浠誨ぉ鍫?Switch<br />* 浜戞父鎴忓鉤鍙幫細Stadia, Amazon Luna, GeForce Now<img src ="http://www.shnenglu.com/jinq0123/aggbug/217680.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">閲戝簡</a> 2021-05-09 20:44 <a href="http://www.shnenglu.com/jinq0123/archive/2021/05/09/217680.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C#寮傛鏂規硶榪斿洖void鍜孴ask鐨勫尯鍒?/title><link>http://www.shnenglu.com/jinq0123/archive/2021/02/25/217618.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Thu, 25 Feb 2021 02:38:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2021/02/25/217618.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/217618.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2021/02/25/217618.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/217618.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/217618.html</trackback:ping><description><![CDATA[# C#寮傛鏂規硶榪斿洖void鍜孴ask鐨勫尯鍒?br /><br />(閲戝簡鐨勪笓鏍?2021.2)<br /><br />濡傛灉寮傛(async鍏抽敭瀛?鏂規硶鏈夎繑鍥炲鹼紝榪斿洖綾誨瀷涓篢鏃訛紝榪斿洖綾誨瀷蹇呯劧鏄?`Task<T>`銆?br />浣嗘槸濡傛灉娌℃湁榪斿洖鍊鹼紝寮傛鏂規硶鐨勮繑鍥炵被鍨嬫湁2縐嶏紝涓涓槸榪斿洖 Task, 涓涓槸榪斿洖 void錛?br />```<br />    public async Task CountDownAsync(int count)<br />    {<br />        for (int i = count; i >= 0; i--)<br />        {<br />            await Task.Delay(1000); <br />        }<br />    }<br /><br />    public async void CountDown(int count)<br />    {<br />        for (int i = count; i >= 0; i--)<br />        {<br />            await Task.Delay(1000);<br />        }<br />    }<br />```<br /><br />璋冪敤鏃訛紝濡傛灉榪斿洖 Task, 浣嗚繑鍥炲艱蹇界暐鏃訛紝VS 浼氱敤緇胯壊娉㈡氮綰胯鍛婏細<br />```<br />    CountDownAsync(3);<br />    ~~~~~~~~~~~~~~~~~<br />```<br /><br />淇℃伅涓猴細<br />```<br />(awaitable) Task AsyncExample.CountDownAsync(int count)<br /><br />Usage:<br /> await CountDownAsync(...);<br /><br />Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.<br />```<br /><br />涓枃涓猴細<br />```<br />CS4014:鐢變簬姝よ皟鐢ㄤ笉浼氱瓑寰咃紝鍥犳鍦ㄦ璋冪敤瀹屾垚涔嬪墠灝嗕細緇х畫鎵ц褰撳墠鏂規硶銆傝鑰冭檻灝?await"榪愮畻絎﹀簲鐢ㄤ簬璋冪敤緇撴灉銆?br />```<br /><br />娣誨姞 await 鍚庡氨姝e父浜嗭細<br />```<br />    await CountDownAsync(3);<br />```<br /><br />濡傛灉璋冪敤鑰呬笉鏄竴涓紓姝ユ柟娉曪紝鍥犱負鍙湁鍦ㄥ紓姝ユ柟娉曚腑鎵嶅彲浠ヤ嬌鐢?await,<br />鎴栬呭茍涓嶆兂鍦ㄦ絳夊緟錛屽鎯沖悓鏃舵墽琛屽涓?CountDownAsync(),<br />灝變笉鑳藉簲鐢?await 鏉ユ秷闄よ鍛娿?br /><br />姝ゆ椂鍙互鏀圭敤 void 榪斿洖鍊肩殑鐗堟湰錛?br />```<br />void Test()<br />{<br />    ...<br />    CountDown(3);<br />    CountDown(3);<br />    ...<br />}<br /><br />async void CountDown(int count)<br />{<br />    for (int i = count; i >= 0; i--)<br />    {<br />        await Task.Delay(1000);<br />    }<br />}<br />```<br /><br />> Never call `async Task` methods without also awaiting on the returned Task. If you don’t want to wait for the async behaviour to complete, you should call an `async void` method instead.<br /><br />鎽樿嚜錛歨ttp://www.stevevermeulen.com/index.php/2017/09/using-async-await-in-unity3d-2017/<br /><br />CountDown() 鍙互鐩存帴璋冪敤 CountDownAsync() 瀹炵幇錛?br />```<br />async void CountDown(int count)<br />{<br />    await CountDownAsync(count);<br />}<br />```<br /><br />浣跨敤涓嬪垝綰垮彉閲忓拷鐣ュ紓姝ユ柟娉曠殑榪斿洖鍊間篃鍙互娑堥櫎璀﹀憡錛?br />```<br />void Test()<br />{<br />    ...<br />    _ = CountDownAsync(3);<br />    _ = CountDownAsync(3);<br />    ...<br />}<br />```<br /><br />浣嗘槸榪欐牱鍚屾椂涔熶細蹇界暐 CountDownAsync() 涓殑寮傚父銆傚浠ヤ笅寮傚父浼氳蹇界暐銆?br /><br />```<br />void Test()<br />{<br />    ...<br />    _ = CountDownAsync(3);<br />    ...<br />}<br /><br />async Task CountDownAsync(int count)<br />{<br />    for (int i = count; i >= 0; i--)<br />    {<br />        await Task.Delay(1000); <br />    }<br />    throw new Exception();<br />}<br />```<br /><br />濡傛灉鏄皟鐢ㄨ繑鍥?void 鐨勫紓姝ユ柟娉曪紝Unity 浼氭姤閿欙細<br />```<br />Exception: Exception of type 'System.Exception' was thrown.<br />```<br /><br />## 瀵?Async 鍚庣紑鐨勮鏄?br /><br />```<br />You could say that the Async suffix convention is to communicate to the API user that the method is awaitable. For a method to be awaitable, it must return Task for a void, or Task<T> for a value-returning method, which means only the latter can be suffixed with Async.<br />```<br /><br />鎽樿嚜錛歨ttps://stackoverflow.com/questions/15951774<br /><br />grpc 鐢熸垚鐨勪唬鐮佷腑錛屽紓姝ヨ姹傝繑鍥炰簡涓涓?AsyncCall 瀵硅薄錛孉syncCall 瀹炵幇浜?GetAwaiter() 鎺ュ彛錛?br />```<br />      public virtual grpc::AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, ...)<br />```<br /><br />鍙互榪欐牱璋冪敤騫剁瓑寰咃細<br />```<br />    var resp = await client.GetFeatureAsync(req);<br />```<br /><br />铏界劧榪斿洖綾誨瀷涓嶆槸`Task<>`, 浣嗘槸鍙瓑寰咃紝鎵浠ユ坊鍔犱簡 Async 鍚庣紑銆?br /><img src ="http://www.shnenglu.com/jinq0123/aggbug/217618.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">閲戝簡</a> 2021-02-25 10:38 <a href="http://www.shnenglu.com/jinq0123/archive/2021/02/25/217618.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>閬垮厤RPC鍥炶皟姝婚攣http://www.shnenglu.com/jinq0123/archive/2020/09/19/217455.html閲戝簡閲戝簡Sat, 19 Sep 2020 05:56:00 GMThttp://www.shnenglu.com/jinq0123/archive/2020/09/19/217455.htmlhttp://www.shnenglu.com/jinq0123/comments/217455.htmlhttp://www.shnenglu.com/jinq0123/archive/2020/09/19/217455.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217455.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217455.html 閬垮厤RPC鍥炶皟姝婚攣
(閲戝簡鐨勪笓鏍?2020.9)

浠婂ぉ鍙戠幇涓渚?RPC 鍥炶皟姝婚攣錛岀幇璞′負涓涓茬浉鍏崇殑 RPC 璋冪敤鍏ㄩ儴瓚呮椂澶辮觸銆?br />
A 璋冪敤 B 鐨?RPC, B 鍐嶅洖璋?A, 褰㈡垚涓涓?RPC 璋冪敤鐜悗錛?br />濡傛灉 A 璋冪敤 B 鏃跺厛鍔犱簡涓涓攣錛岀劧鍚?B 鍥炶皟 A 鏃跺張闇瑕佽繖涓攣錛?br />鑰屾鏃?A 姝e湪絳夊緟 B 鐨?RPC 榪斿洖錛屼箣鍚庢墠浼氶噴鏀鵑攣錛?br />榪欐牱灝卞艦鎴愪簡姝婚攣銆傝繖涓?RPC 璋冪敤鐜渶緇堜細鍏ㄩ儴瓚呮椂澶辮觸銆?br />
榪欎釜璋冪敤鐜彲鑳戒細娑夊強澶氫釜鏈嶅姟錛屽 A->B->C->...->A銆?br />
閬垮厤鍥炶皟姝婚攣鏈変互涓嬫柟娉曘?br />
## 閬垮厤鍥炶皟錛屼笉瑕佹湁 RPC 璋冪敤鐜?br />
涓鑸殑鏈嶅姟渚濊禆搴旇閮芥槸鏃犵幆鐨勩?br />鍙互鐢諱竴涓湇鍔′緷璧栧浘錛屽鏋滄病鏈夊艦鎴愯皟鐢ㄧ幆錛屽氨鍙互鏀懼績涓嶄細鏈夋閿併?br />
## RPC 璋冪敤鏃朵笉瑕佸姞閿?br />
涓鑸繘鍏ユ煇涓?RPC 澶勭悊鏃訛紝浼氶攣浣忕浉鍏崇殑璧勬簮錛岀洿鍒板鐞嗗畬鎴愩?br />濡傛灉澶勭悊榪囩▼涓渶瑕佸悜澶栧彂鍑?RPC 璇鋒眰錛屽簲璇ュ厛閲婃斁閿侊紝寰呰姹傚畬鎴愬悗鍐嶆鑾峰彇閿併?br />濡傛灉璇鋒眰榪囩▼涓渶瑕佺姝㈠叾浠栧崗紼嬫搷浣滅浉鍏寵祫婧愶紝涔熷彲浠ヤ笉閲婃斁閿侊紝
浣嗛攣鐨勪嬌鐢ㄤ笂搴旇鍏佽鍔犻攣澶辮觸錛屼笉瑕佺瓑寰呴攣銆?br />
閿佸簲璇ユ槸鑳藉蹇熼噴鏀劇殑銆傚鏋滈渶瑕佸姞閿佸幓鎵ц涓涓暱鏃墮棿鐨勬搷浣滐紝
榪欎釜閿佺殑璁捐鍙兘闇瑕侀噸鏂拌冭檻銆?br />
## 鎵撴柇璋冪敤閾?br />
鏈夋椂鍊?RPC 璋冪敤閾句笉蹇呮槸闃誨絳夊緟鐨勩?br />濡傞氱煡鎬х殑錛屾棤榪斿洖鍊肩殑RPC, 涓嶉渶瑕佺瓑寰呬粬榪斿洖錛屽彲浠ュ紑涓涓柊鐨勫崗紼嬪幓鎵ц RPC.
鐖禦PC絳夊緟瀛怰PC榪斿洖錛屾敼涓虹埗RPC鐩存帴榪斿洖錛屽瓙RPC鍚庡彴鎵ц錛屽嵆鏂紑 RPC 鐨勮皟鐢ㄤ緷璧栥?br />RPC 璋冪敤閾炬柇寮鎴愬孌靛悗錛岃皟鐢ㄥ驚鐜殑鍙兘鎬у氨澶уぇ涓嬮檷浜嗐?br />

閲戝簡 2020-09-19 13:56 鍙戣〃璇勮
]]>
C# tolua 涔嬮棿浜掍紶 byte[]http://www.shnenglu.com/jinq0123/archive/2020/08/19/217426.html閲戝簡閲戝簡Wed, 19 Aug 2020 01:03:00 GMThttp://www.shnenglu.com/jinq0123/archive/2020/08/19/217426.htmlhttp://www.shnenglu.com/jinq0123/comments/217426.htmlhttp://www.shnenglu.com/jinq0123/archive/2020/08/19/217426.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217426.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217426.html
(閲戝簡鐨勪笓鏍?2020.8)

lua涓笉鍖哄垎 string 鍜?byte[], 鑰屽湪 C# 涓?string 鍜?byte[] 涔嬮棿杞崲娑夊強緙栫爜銆?br />
C# 涓竴鑸繖鏍瘋漿錛?br />
string綾誨瀷杞垚byte[]錛?br />```
byte[] byteArray = System.Text.Encoding.Default.GetBytes(str);
```
byte[]杞垚string錛?br />```
string str = System.Text.Encoding.Default.GetString(byteArray);
```

Default 緙栫爜鏄湰鏈哄綋鍓嶆墍鐢ㄧ紪鐮侊紝榪樺彲浠ョ敤 ASCII, UTF8 絳夊叾浠栫紪鐮併?br />
嫻嬩簡鍦?lua 涓鍏ヤ竴鍧?榪涘埗鏁版嵁錛岃皟鐢?tolua 瀵煎嚭鐨勪竴涓柟娉曪紝濡傦細
```
public void Print(string s)
{
    byte[] buf = Systen.Text.Encoding.Default.GetBytes(s);
    Debug.Log(Bitconvert.ToString(buf));
}
```
嫻嬩簡 Default, ASCII, UTF8, ISO-8859-1(Latin-1), Unicode 鍙戠幇寰楀埌鐨?byte[] 浼氬嚭閿欍?br />
涔熻瘯浜?[C#涓嬌鐢˙uffer.BlockCopy()鏂規硶灝唖tring杞崲涓篵yte array鐨勬柟娉昡(https://www.cnblogs.com/ChineseMoonGod/p/5689526.html)
鍙戠幇 tolua 浼犲埌 C# 鐨?string 宸茬粡鏄紪鐮佽繃鐨勶紝鐩存帴澶嶅埗涔熸槸閿欑殑銆?br />
xlua 涔熸湁鐩稿悓闂錛孾Unity xlua 浠巐ua浼犻抌yte[]鏁版嵁鍒癈#](https://www.jianshu.com/p/63987134c1ba)
浣跨敤 MemoryStream瀵硅薄鏉ヤ紶閫抌yte[]鏁版嵁錛岀‘瀹炴湁鐐圭粫銆?br />
tolua 涓湁涓?LuaByteBuffer錛屽彲浠ョ敤鏉ヤ紶閫?byte[].
[tolua#涓殑LuaByteBuffer綾籡(http://bbs.ulua.org/article/ulua/toluazhongdeluabytebufferlei.html)

浠?lua 浼?byte[] 鍒?C#, 鍙渶瑕佸皢鍙傛暟 string 鏀逛負 LuaByteBuffer:
```
public void Print(LuaByteBuffer luaByteBuffer)
{
    byte[] buf = luaByteBuffer.buffer;
    Debug.Log(Bitconvert.ToString(buf));
}
```

鏇存紜張綆鍗曠殑鏂規硶鏄敤 LuaByteBufferAttribute:
```
[LuaByteBufferAttribute]
public void Print(byte[] buf)
{
    Debug.Log(Bitconvert.ToString(buf));
}
```

鏈緇堝彂鐜頒笉闇瑕?LuaByteBufferAttribute錛岀洿鎺ョ敤 byte[] 灝辮錛?br />```
public void Print(byte[] buf)
{
    Debug.Log(Bitconvert.ToString(buf));
}
```

C# 浼?byte[] 鍒?lua, 榛樿涓?"System.Byte[]"(userdata)錛屽彲浠ョ敤 tostring() 杞負 lua string:
```Lua
s = tolua.tolstring(result)
```

濡傛灉鍙互錛屽簲璇ョ粰鏁版嵁鍔犱笂鏍囩[LuaByteBufferAttribute]錛岃繖鏍蜂紶鍒?lua 灝辨槸 string銆?br />鎴栬呭湪C#寤轟竴涓狶uaByteBuffer鎶奲yte[]浼犵粰lua銆?br />


閲戝簡 2020-08-19 09:03 鍙戣〃璇勮
]]>
Unity浣跨敤寮傛grpchttp://www.shnenglu.com/jinq0123/archive/2020/06/22/217366.html閲戝簡閲戝簡Mon, 22 Jun 2020 07:19:00 GMThttp://www.shnenglu.com/jinq0123/archive/2020/06/22/217366.htmlhttp://www.shnenglu.com/jinq0123/comments/217366.htmlhttp://www.shnenglu.com/jinq0123/archive/2020/06/22/217366.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/217366.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/217366.html
(閲戝簡鐨勪笓鏍?2020.6)

Unity 淇濊瘉 async 鏂規硶榪愯鍦ㄤ富綰跨▼涓紝鎵浠ョ敤寮傛鏂瑰紡璋冪敤 grpc 鍙互澶уぇ綆鍖栫綉緇滈氫俊鐨勪唬鐮併?br />
浠ヤ笅紺轟緥涓皢 grpc 鐨?RouteGuide 紺轟緥縐誨埌 Unity 涓繍琛屻?br />https://github.com/grpc/grpc/tree/master/examples/csharp/RouteGuide

鍏朵腑 Main() 涓殑浠g爜縐誨埌 Start() 涓繍琛岋紝闃誨璋冪敤鏀規垚寮傛璋冪敤, GetFeature() 鏀規垚 GetFeatureAsync()銆?br />
瀹屾暣浠g爜瑙侊細https://gitee.com/jinq0123/unity-grpc-async

```
using Grpc.Core;
using Routeguide;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static Routeguide.Program;

public class Test : MonoBehaviour
{
    // Start is called before the first frame update
    async void Start()
    {
        var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
        var client = new RouteGuideClient(new RouteGuide.RouteGuideClient(channel));

        // Looking for a valid feature
        await client.GetFeatureAsync(409146138, -746188906);

        // Feature missing.
        await client.GetFeatureAsync(0, 0);

        // Looking for features between 40, -75 and 42, -73.
        await client.ListFeatures(400000000, -750000000, 420000000, -730000000);

        // Record a few randomly selected points from the features file.
        await client.RecordRoute(RouteGuideUtil.LoadFeatures(), 10);

        // Send and receive some notes.
        await client.RouteChat();

        await channel.ShutdownAsync();

        Debug.Log("End of test.");
    }
}
```


閲戝簡 2020-06-22 15:19 鍙戣〃璇勮
]]>
SVN閲嶅懡鍚嶆椂涓嶈鏇存敼鍐呭http://www.shnenglu.com/jinq0123/archive/2019/09/20/216848.html閲戝簡閲戝簡Fri, 20 Sep 2019 06:45:00 GMThttp://www.shnenglu.com/jinq0123/archive/2019/09/20/216848.htmlhttp://www.shnenglu.com/jinq0123/comments/216848.htmlhttp://www.shnenglu.com/jinq0123/archive/2019/09/20/216848.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/216848.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/216848.html
(閲戝簡鐨勪笓鏍?2019.9)

svn rename 鏌愪釜鏂囦歡騫舵洿鏀瑰唴瀹瑰悗鎻愪氦錛屽巻鍙插氨浼氫涪澶便?br />濡傛灉 svn rename 鍚庝笉鏀瑰唴瀹癸紝绔嬪嵆鎻愪氦錛屽氨鍙互寤剁畫鍘熸湁鍘嗗彶銆?br />鎵浠ユ敼鍚嶈繖鏍風殑鎿嶄綔搴旇鐙珛鎻愪氦涓嬈°?br />
git 鏀瑰悕灝卞己澶у浜嗭紝浼氭瘮杈冨唴瀹圭‘瀹氬叾鍘熸潵鐨勬枃浠躲備絾鏇存敼澶涔熶細鍒ゆ柇鍑洪敊銆?br />

閲戝簡 2019-09-20 14:45 鍙戣〃璇勮
]]>
瑙e喅vs2017鏃犳硶瀹夎闂http://www.shnenglu.com/jinq0123/archive/2018/11/12/216052.html閲戝簡閲戝簡Mon, 12 Nov 2018 02:19:00 GMThttp://www.shnenglu.com/jinq0123/archive/2018/11/12/216052.htmlhttp://www.shnenglu.com/jinq0123/comments/216052.htmlhttp://www.shnenglu.com/jinq0123/archive/2018/11/12/216052.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/216052.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/216052.html瑙e喅vs2017鏃犳硶瀹夎闂

(閲戝簡鐨勪笓鏍?2018.11)

浠庡畼緗戜笅杞戒簡 vs_community__1600125377.1541561546.exe錛屼絾鏄繍琛屽畨瑁呮椂鏃犳硶鍑虹幇浜у搧閫夋嫨鐣岄潰銆?br />
鏌ョ湅 Temp 鐩綍涓嬬殑鏃ュ織錛屾病鏈夊彂鐜伴敊璇?br />
鎼滅儲涓涓嬶紝鍙戠幇鏈夊ぇ閲忕殑鍚岀被閿欒錛?br />
* VS : How to fix stuck Visual Studio Community installation problem
    https://www.howtosolutions.net/2015/08/solving-installation-is-stuck-problem-in-visual-studio-community-edition/
* Resolving Installation Issues with Visual Studio 2017
    http://rion.io/2017/02/17/resolving-installation-issues-with-visual-studio-2017/
* Unable to start vs_installer.exe to install VS2017 Community
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/fc8f5a04-8687-48dd-987e-1cfac67566a1/unable-to-start-vsinstallerexe-to-install-vs2017-community?forum=vssetup
* VS 2017 Installer quits before starting
    https://developercommunity.visualstudio.com/content/problem/8993/vs-2017-installer-quits-before-starting.html
* VS2017鏃犳硶榪涘叆瀹夎鐣岄潰闂鐨勮В鍐蟲柟娉?- 鍘氱Н钖勫彂錛屾寔涔嬩互鎭?- CSDN鍗氬
    https://blog.csdn.net/qq951127336/article/details/71036868
* VS2017瀹夎鏃惰嚜鍔ㄩ鍑篲yanggy_鏂版氮鍗氬
    http://blog.sina.com.cn/s/blog_702b606a0102y6n3.html

浣嗘槸閮芥病鏈夌敤銆?br />
浠庝互涓婃柟妗堜腑浜嗚В鍒幫紝`C:\Program Files (x86)\Microsoft Visual Studio\Installer`鍙兘瀛樺湪鍧忔枃浠訛紝鎵浠ユ棤娉曞畨瑁呫?br />浣嗘槸娓呯悊涔嬪悗閲嶆柊涓嬭澆錛屼粛鐒舵槸鍚屾牱鎯呭喌銆?br />
璇曠潃榪愯浜嗗叾涓殑 vs_installer.exe錛屽脊鍑虹晫闈㈣鏈夊吋瀹規ч敊璇紝鍙互閫夋嫨淇銆?br />淇涔嬪悗錛寁s_installer.exe 灝卞嚭鐜頒駭鍝侀夋嫨鐣岄潰浜嗐?br />
鐒跺悗鍐嶈繍琛?vs_community__1600125377.1541561546.exe錛屽氨鍙互鍑虹幇浜у搧閫夋嫨鐣岄潰浜嗐?br />
闂鍙兘鏄繖涓?Installer 瀹夎涓嶅錛屽彲鑳芥槸閫夋嫨浜嗛敊璇殑鐗堟湰錛屽垹闄ゅ悗閲嶆柊涓嬭澆榪樻槸涓鏍鳳紝榪樺ソ鍙互鎵嬪姩淇涓涓嬨?br />
鐜板湪姝e湪瀹夎 vs2017.


閲戝簡 2018-11-12 10:19 鍙戣〃璇勮
]]>
docker build 璁劇疆浠g悊http://www.shnenglu.com/jinq0123/archive/2018/09/26/215949.html閲戝簡閲戝簡Wed, 26 Sep 2018 09:37:00 GMThttp://www.shnenglu.com/jinq0123/archive/2018/09/26/215949.htmlhttp://www.shnenglu.com/jinq0123/comments/215949.htmlhttp://www.shnenglu.com/jinq0123/archive/2018/09/26/215949.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215949.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215949.htmldocker build 璁劇疆浠g悊

(閲戝簡鐨勪笓鏍?2018.9)

Dockerfile.frontendapi 涓湁 `RUN go get`, 闇瑕佽緗唬鐞嗐?br />
docker build . -f Dockerfile.frontendapi \
    -t registry.cn-shanghai.aliyuncs.com/jinq0123/openmatch-frontendapi:dev \
    --network host \
    --build-arg HTTP_PROXY=http://127.0.0.1:1080 \
    --build-arg HTTPS_PROXY=http://127.0.0.1:1080

鍥犱負 docker build 浼氬湪涓涓鍣ㄥ唴鎵ц錛屾墍浠ラ』鎸囧畾 network 涓?host, 浣夸箣鍙互榪炴帴鏈満鐨勪唬鐞嗐?br />
鍙傝冿細
https://stackoverflow.com/questions/22179301/how-do-you-run-apt-get-in-a-dockerfile-behind-a-proxy

[root@pppdc9prda2y java]# docker build
  --build-arg https_proxy=$HTTP_PROXY --build-arg http_proxy=$HTTP_PROXY
  --build-arg HTTP_PROXY=$HTTP_PROXY --build-arg HTTPS_PROXY=$HTTP_PROXY
  --build-arg NO_PROXY=$NO_PROXY  --build-arg no_proxy=$NO_PROXY -t java .


閲戝簡 2018-09-26 17:37 鍙戣〃璇勮
]]>
kubernetes瀵煎嚭鏈夌姸鎬佹湇鍔?/title><link>http://www.shnenglu.com/jinq0123/archive/2018/07/14/215783.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Sat, 14 Jul 2018 03:43:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2018/07/14/215783.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/215783.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2018/07/14/215783.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/215783.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/215783.html</trackback:ping><description><![CDATA[<div>kubernetes瀵煎嚭鏈夌姸鎬佹湇鍔?br /><br />(閲戝簡鐨勪笓鏍?2018.7)<br /><br />緗戞父鏈嶅姟鍣ㄤ腑鐨勬埧闂存湇鍔″櫒鏄湁鐘舵佹湇鍔″櫒錛屽彲浠ョ敤 kubernetes statefulset 寮鍚涓疄渚嬨?br /><br />涓轟簡璁╁鎴風鑳藉鐩磋繛鎴塊棿鏈嶅姟鍣紝闄や簡 statefulset 瑕佹眰鐨?headless 鏈嶅姟錛?br />榪橀』涓烘瘡涓疄渚嬪垱寤?NodePort 綾誨瀷鐨勬湇鍔? 騫朵笖閫夋嫨Pod鍜岀姝㈣漿鍙戙?br /><br />涓嬮潰 bootcamp.yml 鍏堝垱寤轟簡 bootcamp headless 鏈嶅姟(clusterIP: None), <br />鍙堝垱寤轟簡 bootcamp StatefulSet, 瀹炰緥涓暟涓?2.<br />鐒跺悗鍒涘緩 bootcamp-0,1,2 鏈嶅姟錛屽垎鍒搴?bootcamp-0,1,2 pod.<br /><br />鏈嶅姟涓暟澶т簬瀹炰緥涓暟錛屾槸鎯蟲祴璇曚笅鏈嶅姟娌℃湁瀵瑰簲鐨勫疄渚嬫椂鐨勮〃鐜般?br /><br />緗戞父涓殑鍖歸厤鏈嶅姟鍣ㄥ皢鍒嗛厤涓涓埧闂寸粰瀹㈡埛绔紝鍒椾婦 bootcamp-0,1,2 pod 鎵鍦ㄨ妭鐐圭殑澶栫綉 IP,<br />榪炲悓瀵瑰簲鏈嶅姟鐨勭鍙o紝鍙戦佺粰瀹㈡埛绔紝璁╁鎴風鐩磋繛銆?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ cat bootcamp.yml </span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">  labels:</span><br /><span style="color: #0000ff; font-family: Courier;">    name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">    - port: 8080</span><br /><span style="color: #0000ff; font-family: Courier;">  clusterIP: None  # StatefulSet瑕佹眰Headless鏈嶅姟</span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp  # 閫夋嫨 bootcamp 搴旂敤</span><br /><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: apps/v1beta1</span><br /><span style="color: #0000ff; font-family: Courier;">kind: StatefulSet</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  serviceName: bootcamp  # 涓婇潰鐨?Headless 鏈嶅姟鍚?/span><br /><span style="color: #0000ff; font-family: Courier;">  replicas: 2</span><br /><span style="color: #0000ff; font-family: Courier;">  template:</span><br /><span style="color: #0000ff; font-family: Courier;">    metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">      labels:</span><br /><span style="color: #0000ff; font-family: Courier;">        app: bootcamp  # 搴旂敤鍚嶏紝涓庢湇鍔′腑鐨?selector 瀵瑰簲</span><br /><span style="color: #0000ff; font-family: Courier;">    spec:</span><br /><span style="color: #0000ff; font-family: Courier;">      containers:</span><br /><span style="color: #0000ff; font-family: Courier;">      - name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">        image: docker.io/jocatalin/kubernetes-bootcamp:v1</span><br /><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp-0</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  type: NodePort  # 瀵瑰鏈嶅姟</span><br /><span style="color: #0000ff; font-family: Courier;">  externalTrafficPolicy: Local  # 涓嶈杞彂鍒板叾浠栬妭鐐?/span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">    statefulset.kubernetes.io/pod-name: bootcamp-0  # 閫夋嫨 pod</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">  - protocol: TCP</span><br /><span style="color: #0000ff; font-family: Courier;">    nodePort: 30880  # 瀵瑰绔彛</span><br /><span style="color: #0000ff; font-family: Courier;">    port: 8080</span><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp-1</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  type: NodePort</span><br /><span style="color: #0000ff; font-family: Courier;">  externalTrafficPolicy: Local</span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">    statefulset.kubernetes.io/pod-name: bootcamp-1</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">  - protocol: TCP</span><br /><span style="color: #0000ff; font-family: Courier;">    nodePort: 30881</span><br /><span style="color: #0000ff; font-family: Courier;">    port: 8080</span><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp-2</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  type: NodePort</span><br /><span style="color: #0000ff; font-family: Courier;">  externalTrafficPolicy: Local</span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">    statefulset.kubernetes.io/pod-name: bootcamp-2</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">  - protocol: TCP</span><br /><span style="color: #0000ff; font-family: Courier;">    nodePort: 30882</span><br /><span style="color: #0000ff; font-family: Courier;">    port: 8080</span><br /><br />鍥犱負 statefulset 鐨勬瘡涓疄渚嬫湁涓嶅悓鐨勬爣絳撅紝鎵浠ュ彲浠ヤ負鏈嶅姟閫夋嫨涓涓疄渚嬨?br /><br />鍒╃敤 externalTrafficPolicy: Local 璁劇疆鏉ョ姝㈣漿鍙戙?br />鍙傝?service.spec.externalTrafficPolicy 鐨勮鏄庯細<br /><br />https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-type-nodeport<br /><br />Setting service.spec.externalTrafficPolicy to the value Local will only proxy requests to local endpoints, never forwarding traffic to other nodes and thereby preserving the original source IP address. If there are no local endpoints, packets sent to the node are dropped, ...<br /><br />鍥犱負鏈夊彲鑳藉涓狿od寮鍦ㄥ悓涓鑺傜偣涓婏紝鎵浠ュ澶栫鍙h鎴愪簡涓嶅悓鐨?30880-30882銆?br />濡傛灉闄愬埗姣忎釜鑺傜偣鍙紑涓涓疄渚嬶紝鍒欏澶栫鍙e彲浠ヨ鎴愬悓涓涓?br /><br />鍒涘緩鏈嶅姟錛?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl apply -f bootcamp.yml </span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp" created</span><br /><span style="color: #0000ff; font-family: Courier;">statefulset.apps "bootcamp" created</span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp-0" created</span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp-1" created</span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp-2" created</span><br /><br />鏈嶅姟濡備笅錛?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get service -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp     ClusterIP   None             <none>        8080/TCP         3m</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-0   NodePort    10.96.128.137    <none>        8080:30880/TCP   3m</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-1   NodePort    10.109.2.56      <none>        8080:30881/TCP   3m</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-2   NodePort    10.102.181.193   <none>        8080:30882/TCP   3m</span><br /><br />2涓疄渚嬶細<br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get pod -n jq -o wide</span><br /><span style="color: #0000ff; font-family: Courier;">NAME         READY     STATUS    RESTARTS   AGE       IP            NODE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-0   1/1       Running   0          4m        10.244.0.42   host-10-240-79-10</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-1   1/1       Running   0          4m        10.244.1.63   host-10-240-79-11</span><br /><br />璁塊棶鏈嶅姟蹇呴』鎸囧畾鑺傜偣錛屼笉浼氳嚜鍔ㄨ漿鍙戯細<br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30880</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-0 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30881</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.10:30881; Connection timed out</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30880</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.11:30880; Connection timed out</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><br />娌℃湁璐熻澆鍧囪 錛?0881绔彛鎬繪槸璁塊棶 bootcamp-1錛?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><br />涔熷彲浠ヤ粠澶栫綉璁塊棶.<br /><br />30882 绔彛鏃犳硶榪炴帴錛?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30882</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.11:30882; Connection refused</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30882</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.10:30882; Connection refused</span><br /><br />3涓鍙i兘鏈夌洃鍚細<br /><br /><span style="color: #0000ff; font-family: Courier;">[root@host-10-240-79-11 tmp]# netstat -ntl | grep 3088</span><br /><span style="color: #0000ff; font-family: Courier;">tcp6       0      0 :::30881                :::*                    LISTEN     </span><br /><span style="color: #0000ff; font-family: Courier;">tcp6       0      0 :::30882                :::*                    LISTEN     </span><br /><span style="color: #0000ff; font-family: Courier;">tcp6       0      0 :::30880                :::*                    LISTEN     </span><br /><br />iptables-save 杈撳嚭濡備笅, 鍏朵腑 10.244鏄疨od鐨勭綉孌點?br /><br />娌℃湁瀹炰緥榪愯鐨勮妭鐐逛笂錛屼細涓㈠純璇鋒眰錛?br /><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-MARK-MASQ</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-XLB-LJXDQ4W47M42IZBH</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-MARK-MASQ</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-XLB-U5NEOQT6R5WSBVOH</span><br /><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-LJXDQ4W47M42IZBH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-LJXDQ4W47M42IZBH</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-LJXDQ4W47M42IZBH -m comment --comment "jq/bootcamp-1: has no local endpoints" -j KUBE-MARK-DROP</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-U5NEOQT6R5WSBVOH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-U5NEOQT6R5WSBVOH</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-U5NEOQT6R5WSBVOH -m comment --comment "jq/bootcamp-0: has no local endpoints" -j KUBE-MARK-DROP</span><br /><br />鏈夊疄渚嬭繍琛岀殑鑺傜偣涓婁細杞彂緇?Pod 8080錛?br /><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-MARK-MASQ</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-XLB-U5NEOQT6R5WSBVOH</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-MARK-MASQ</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-XLB-LJXDQ4W47M42IZBH</span><br /><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-LJXDQ4W47M42IZBH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-LJXDQ4W47M42IZBH</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-LJXDQ4W47M42IZBH -m comment --comment "Balancing rule 0 for jq/bootcamp-1:" -j KUBE-SEP-LJQA4WUIKJUQ5ALU</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-U5NEOQT6R5WSBVOH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-U5NEOQT6R5WSBVOH</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-U5NEOQT6R5WSBVOH -m comment --comment "jq/bootcamp-0: has no local endpoints" -j KUBE-MARK-DROP</span><br /><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-SEP-LJQA4WUIKJUQ5ALU -s 10.244.1.63/32 -m comment --comment "jq/bootcamp-1:" -j KUBE-MARK-MASQ</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-SEP-LJQA4WUIKJUQ5ALU -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp -j DNAT --to-destination 10.244.1.63:8080</span><br /><br />30882 绔彛鏃犳硶榪炴帴<br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-EXTERNAL-SERVICES -p tcp -m comment --comment "jq/bootcamp-2: has no endpoints" -m addrtype --dst-type LOCAL -m tcp --dport 30882 -j REJECT --reject-with icmp-port-unreachable</span><br /><br />嫻嬭瘯涓嬫墿瀹癸細<br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get statefulset -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">NAME       DESIRED   CURRENT   AGE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp   2         2         45m</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl scale --replicas=3 statefulset/bootcamp -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">statefulset.apps "bootcamp" scaled</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get statefulset -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">NAME       DESIRED   CURRENT   AGE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp   3         3         47m</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get pod -n jq -o wide</span><br /><span style="color: #0000ff; font-family: Courier;">NAME         READY     STATUS    RESTARTS   AGE       IP            NODE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-0   1/1       Running   0          48m       10.244.0.42   host-10-240-79-10</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-1   1/1       Running   0          48m       10.244.1.63   host-10-240-79-11</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-2   1/1       Running   0          45s       10.244.2.60   host-10-240-79-12</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.12:30882</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-2 | v=1</span><br /></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/215783.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">閲戝簡</a> 2018-07-14 11:43 <a href="http://www.shnenglu.com/jinq0123/archive/2018/07/14/215783.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>grpc-go涓巃ctor妯″紡http://www.shnenglu.com/jinq0123/archive/2018/06/12/215720.html閲戝簡閲戝簡Tue, 12 Jun 2018 03:15:00 GMThttp://www.shnenglu.com/jinq0123/archive/2018/06/12/215720.htmlhttp://www.shnenglu.com/jinq0123/comments/215720.htmlhttp://www.shnenglu.com/jinq0123/archive/2018/06/12/215720.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215720.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215720.htmlgrpc-go涓巃ctor妯″紡

(閲戝簡鐨勪笓鏍?2018.6)

grpc-go鏈嶅姟鍣ㄧ殑姣忎釜璇鋒眰閮藉湪涓涓嫭绔嬬殑鍗忕▼涓墽琛屻?br />緗戞父鏈嶅姟鍣ㄤ腑錛屼竴鑸姹備細璋冪敤娓告垙鎴塊棿鐨勬柟娉曪紝鑰屾埧闂存槸涓涓嫭绔嬬殑鍗忕▼銆?br />鍙互灝嗘埧闂村疄鐜頒負actor錛実rpc璇鋒眰閫氳繃Call()鎴朠ost()鏂規硶鏉ユ墽琛屻?br />鍏朵腑Call()浼氱瓑寰呰繑鍥烇紝鑰孭ost()浼氬紓姝ユ墽琛屾棤榪斿洖鍊箋?br />
type Room struct {
    // actC 鏄叾浠栧崗紼嬪悜Room鍗忕▼鍙戦佸姩浣滅殑Channel錛屽崗紼嬩腑灝嗕緷嬈℃墽琛屽姩浣溿?/span>
    // Action 鍔ㄤ綔, 鏄棤鍙傛暟鏃犺繑鍥炲肩殑鍑芥暟.
    actC chan func()

    ...
}

// Run 榪愯鎴塊棿鍗忕▼.
func (r *Room) Run() {
    ticker := time.NewTicker(20 * time.Millisecond)
    defer ticker.Stop()

    for r.running {
        select {
        case act := <-r.actC:
            act()
        case <-ticker.C:
            r.tick()
        }
    }
}

// Call calls a function f and returns the result.
// f runs in the Room's goroutine.
func (r *Room) Call(f func() interface{}) interface{} {
    // 緇撴灉浠巆h榪斿洖
    ch := make(chan interface{}, 1)
    r.actC <- func() {
        ch <- f()
    }
    // 絳夊緟鐩村埌榪斿洖緇撴灉
    return <-ch
}

// Post 灝嗕竴涓姩浣滄姇閫掑埌鍐呴儴鍗忕▼涓墽琛?
func (r *Room) Post(f func()) {
    r.actC <- f
}

grpc鏈嶅姟鏂規硶濡傦細

func (m *RoomService) Test(ctx context.Context, req *pb.TestReq) (*pb.TestResp, error) {
    conn := conn_mgr.GetConn(ctx)
    if conn == nil {
        return nil, fmt.Errorf("can not find connection")
    }

    room := conn.GetRoom()
    resp := room.Call(func() interface{} {
        return room.Test(req)
    })

    return resp.(*pb.TestResp), nil
}

閲戝簡 2018-06-12 11:15 鍙戣〃璇勮
]]>
鎺ㄨ崘Golang鐨刟ssert搴?/title><link>http://www.shnenglu.com/jinq0123/archive/2018/05/14/215637.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Mon, 14 May 2018 02:42:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2018/05/14/215637.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/215637.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2018/05/14/215637.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/215637.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/215637.html</trackback:ping><description><![CDATA[<div>鎺ㄨ崘Golang鐨刟ssert搴?br /><br />(閲戝簡鐨勪笓鏍?2018.5)<br /><br />https://github.com/aurelien-rainone/assertgo<br /><br />Conditionally compiled assertions in Go <br /><br />鍜孋++涓殑assert()涓鏍鳳紝榪欎釜鏄甫鏉′歡緙栬瘧鐨勶紝蹇呴』浣跨敤 debug 鎵嶈兘鍚敤銆?br /><br />濡傦細<br /><br />$ go run -tags debug main.go<br /><br />浣跨敤紺轟緥錛?br /><br />assert.True(true, "never printed")<br /><br /></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/215637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">閲戝簡</a> 2018-05-14 10:42 <a href="http://www.shnenglu.com/jinq0123/archive/2018/05/14/215637.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>consul鍛戒護涓殑鍑犱釜鍦板潃http://www.shnenglu.com/jinq0123/archive/2018/05/09/215627.html閲戝簡閲戝簡Wed, 09 May 2018 10:32:00 GMThttp://www.shnenglu.com/jinq0123/archive/2018/05/09/215627.htmlhttp://www.shnenglu.com/jinq0123/comments/215627.htmlhttp://www.shnenglu.com/jinq0123/archive/2018/05/09/215627.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215627.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215627.htmlconsul鍛戒護涓殑鍑犱釜鍦板潃

(閲戝簡鐨勪笓鏍?2018.5)

consul鍛戒護琛屼腑鏈変互涓嬪嚑涓湴鍧鍙傛暟錛?br />
* -bind
    緇戝畾鍦板潃錛岀敤浜庨泦緹ら氫俊錛岀己鐪?0.0.0.0
* -clint
    緇戝畾鍦板潃錛岀敤浜?RPC, DNS, HTTP and HTTPS錛岀己鐪?127.0.0.1
* -serf-lan-bind
    緇戝畾鍦板潃錛岀敤浜庡唴緗戦泦緹ら氫俊錛岀己鐪佷嬌鐢?-bind 鍦板潃
* -serf-wan-bind
    緇戝畾鍦板潃錛岀敤浜庤法鏈烘埧閫氫俊錛岀己鐪佷嬌鐢?-bind 鍦板潃
* -advertise
    閫氬憡鍦板潃錛岄氬憡緇欓泦緹や腑鍏朵粬鑺傜偣錛岀己鐪佷嬌鐢?-bind 鍦板潃
* -advertise-wan
    閫氬憡鍦板潃錛岄氬憡緇欏叾浠栨満鎴跨殑鏈嶅姟鑺傜偣錛岀己鐪佷嬌鐢?-advertise 鍦板潃
* -join -retry-join
    鍔犲叆闆嗙兢鐨勭洰鏍囧湴鍧
* -join-wan -retry-join-wan
    璺ㄦ満鎴塊偊鑱旂殑鐩爣鍦板潃
* -recursor
    涓婃父DNS鍦板潃

瀹樻柟鏂囨。錛?https://www.consul.io/docs/agent/options.html#command-line-options


閲戝簡 2018-05-09 18:32 鍙戣〃璇勮
]]>
鏈嶅姟鍙戠幇鐨勭粍浠?/title><link>http://www.shnenglu.com/jinq0123/archive/2018/05/04/215617.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Fri, 04 May 2018 08:07:00 GMT</pubDate><guid>http://www.shnenglu.com/jinq0123/archive/2018/05/04/215617.html</guid><wfw:comment>http://www.shnenglu.com/jinq0123/comments/215617.html</wfw:comment><comments>http://www.shnenglu.com/jinq0123/archive/2018/05/04/215617.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jinq0123/comments/commentRss/215617.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jinq0123/services/trackbacks/215617.html</trackback:ping><description><![CDATA[<div><div> <p>鏈嶅姟鍙戠幇鐨勭粍浠?/p> <p>(閲戝簡鐨勪笓鏍?2018.5)</p> <p>鏈嶅姟鍙戠幇鏈変互涓嬬粍浠訛細</p> <ul><li><p>Service Registry 鏈嶅姟娉ㄥ唽涓績</p> <p>緇存姢鏈嶅姟鐨勫垪琛紝鎻愪緵鏌ヨ銆備竴鑸疄鐜頒負鍒嗗竷寮忛敭鍊煎瓨鍌ㄦ暟鎹簱銆?/p></li><li><p>Registrator 娉ㄥ唽鍣?/p> <p>鐩戝惉鏈嶅姟鍒涘緩鍜屽垹闄や簨浠訛紝騫跺湪鏈嶅姟娉ㄥ唽涓績鍔ㄦ佹敞鍐屾垨娉ㄩ攢鏈嶅姟銆?/p></li><li><p>Health Checker 鍋ュ悍媯鏌ュ櫒</p> <p>鐩戣鏈嶅姟鏄惁鍋ュ悍錛屽茍鍦ㄦ湇鍔℃敞鍐屼腑蹇冨姩鎬佹洿鏂版湇鍔°?/p></li><li><p>Load balancer 璐熻澆鍧囪 鍣?/p> <p>灝嗘湇鍔¤姹傚垎鏁e埌鍚勪釜鏈嶅姟鍣ㄣ?/p></li></ul> </div></div><img src ="http://www.shnenglu.com/jinq0123/aggbug/215617.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jinq0123/" target="_blank">閲戝簡</a> 2018-05-04 16:07 <a href="http://www.shnenglu.com/jinq0123/archive/2018/05/04/215617.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>grpc-lua 紺轟緥http://www.shnenglu.com/jinq0123/archive/2018/04/13/215587.html閲戝簡閲戝簡Fri, 13 Apr 2018 07:41:00 GMThttp://www.shnenglu.com/jinq0123/archive/2018/04/13/215587.htmlhttp://www.shnenglu.com/jinq0123/comments/215587.htmlhttp://www.shnenglu.com/jinq0123/archive/2018/04/13/215587.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215587.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215587.htmlgrpc-lua 紺轟緥

(閲戝簡鐨勪笓鏍?2018.4)

grpc-lua (https://github.com/jinq0123/grpc-lua) 鏄?grpc 鐨?lua 緇戝畾搴擄紝
搴旂敤浜?luapbintf , 涓嶉渶瑕佺敓鎴愪唬鐮侊紝鐩存帴璇誨彇 proto 鏂囦歡銆?br />
濡傦細
    -- Sync request.
    local request = { name = "world" }
    local response = assert(stub:sync_request("SayHello", request))
    print("Greeter received: " .. response.message)

瀹屾暣鐨勭ず渚嬩唬鐮佽 examples 鐩綍銆?br />
鏈嶅姟鍣ㄥ拰瀹㈡埛绔兘鏀寔鍚屾鍜屽紓姝ヨ皟鐢ㄣ?br />
灝?examples/conan_install.bat.example 鍘婚櫎 .example 鍚庣紑錛岀劧鍚庤繍琛岋紝
灝嗗畨瑁呮墍鏈夌殑渚濊禆搴? 欏誨厛瀹夎 conan 鍖呯鐞嗗伐鍏?(http://docs.conan.io/en/latest/installation.html)銆?br />榪橀渶瑕佽緗?git 浠g悊錛屽洜涓?grpc 鐨勫瓙搴撻渶瑕佺炕榪濆銆?br />
conan_install.bat 瀹為檯涓婃槸涓嬭澆渚濊禆搴撲唬鐮佸茍緙栬瘧銆傜粨鏋滃湪鐢ㄦ埛鐩綍 .conan/data/銆?br />鍦ㄥ叾涓悳绱?lua-cpp.exe, lua-cpp.dll, luapbintf.dll, grpc_lua.dll 騫跺鍒跺埌 examples/helloworld/ 鐩綍涓嬨?br />
鐒跺悗鍦?helloworld 鐩綍涓嬪垎鍒繍琛?run_server.bat 鍜?run_client.bat 嫻嬭瘯銆?br />
宸茬紪璇戞祴璇曞彲琛岀殑瀹屾暣鍖呭彲涓嬭澆錛?br />grpc-lua 浠g爜鍙婄ず渚媁indows鎵ц紼嬪簭錛歨ttps://download.csdn.net/download/jq0123/10346554
grpc-lua 紺轟緥 CentOS 7.4 鎵ц紼嬪簭鎵撳寘錛歨ttps://download.csdn.net/download/jq0123/10346003

CentOS 7.4 瀹炴祴錛?br />
[jinqing@localhost helloworld]$ ls
greeter_client.lua   grpc_lua.so       lua-cpp         run_server.bat
greeter_server.lua   helloworld.proto  luapbintf.so
greeter_service.lua  liblua-cpp.so     run_client.bat
[jinqing@localhost helloworld]$ ./lua-cpp greeter_server.lua
Server listening on 0.0.0.0:50051
Got hello from world
Got hello from world

[jinqing@localhost helloworld]$ ./lua-cpp greeter_client.lua
Greeter received: Hello world
Async greeter received: Hello world
[jinqing@localhost helloworld]$

[jinqing@localhost route_guide]$ ./lua-cpp route_guide_server.lua
RecordRoute reader end.
RouteChat reader end.

[jinqing@localhost route_guide]$ ./lua-cpp route_guide_client.lua
-------------- Sync get feature --------------
Found feature: {
...


閲戝簡 2018-04-13 15:41 鍙戣〃璇勮
]]>
鐢?DocFetcher 鍏ㄦ枃鎼滅儲http://www.shnenglu.com/jinq0123/archive/2018/04/08/215577.html閲戝簡閲戝簡Sun, 08 Apr 2018 07:17:00 GMThttp://www.shnenglu.com/jinq0123/archive/2018/04/08/215577.htmlhttp://www.shnenglu.com/jinq0123/comments/215577.htmlhttp://www.shnenglu.com/jinq0123/archive/2018/04/08/215577.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215577.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215577.html鐢?DocFetcher 鍏ㄦ枃鎼滅儲

(閲戝簡鐨勪笓鏍?2018.4)

浠ュ墠鐢?Notepad++ 鐨勫叏鏂囨悳绱紝娌℃湁绱㈠紩錛屾瘡嬈℃悳绱㈤兘欏葷瓑寰呬竴浼氬効銆?br />
鑰?DocFetcher 鏄紑婧愮殑妗岄潰鎼滅儲搴旂敤錛屽緩濂界儲寮曞悗錛屾悳绱細绔嬪嵆鍑虹粨鏋溿?br />
鍏堥』涓烘煇涓洰褰曞垱寤虹儲寮曪紝閫夋嫨鏌愪簺鍚庣紑鍚嶇殑鏂囦歡銆傜劧鍚庨変腑璇ョ儲寮曡繘琛屾悳绱€?br />

閲戝簡 2018-04-08 15:17 鍙戣〃璇勮
]]>
gRPC-go 榪炴帴綆$悊http://www.shnenglu.com/jinq0123/archive/2017/12/25/215444.html閲戝簡閲戝簡Mon, 25 Dec 2017 11:00:00 GMThttp://www.shnenglu.com/jinq0123/archive/2017/12/25/215444.htmlhttp://www.shnenglu.com/jinq0123/comments/215444.htmlhttp://www.shnenglu.com/jinq0123/archive/2017/12/25/215444.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215444.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215444.htmlgRPC-go 榪炴帴綆$悊

(閲戝簡鐨勪笓鏍?2017.12)

鎶?example greeter 鏀逛竴涓嬶紝澶勭悊 SayHello() 璇鋒眰鏃訛紝涓嶄粎浠呰繑鍥炴湰嬈¤姹傝呯殑鍚嶅瓧錛?br />榪樿繑鍥炰笂嬈¤姹傜殑鍚嶅瓧錛屽錛?br />```
λ go run greeter_client/main.go
2017/12/25 17:59:13 Greeting: Hello 'world' (prev '')
2017/12/25 17:59:15 Greeting: Hello 'world2' (prev 'world')
```

鍏堝皢瀹㈡埛绔崟嬈¤姹傛敼涓哄嬈¤姹傦細

```go
    r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name})
    log.Printf("Greeting: %s", r.Message)
    time.Sleep(2 * time.Second)

    r, err = c.SayHello(context.Background(), &pb.HelloRequest{Name: name + "2"})
    log.Printf("Greeting: %s", r.Message)
    ...
```

鏈嶅姟鍣ㄩ渶瑕佷負姣忎釜榪炴帴淇濆瓨鍚勮嚜鐨勬暟鎹傝繛鎺ュ垱寤烘椂鍒濆鍖栨暟鎹紝榪炴帴鏂紑鏃舵竻鐞嗘暟鎹?br />榪欓噷鍒╃敤浜嗚繛鎺ョ粺璁$殑鎺ュ彛錛屼笉鐭ラ亾鏄惁鏄渶閫傚綋鐨勫疄鐜版柟寮?

鏈嶅姟鍣ㄥ垱寤烘椂娣誨姞 StatsHandler 閫夐」錛岃緭鍏ヤ竴涓?stats.Handler 鐨勫疄鐜般?br />```
-    s := grpc.NewServer()
+    s := grpc.NewServer(grpc.StatsHandler(&statshandler{}))
```

statshandler 闇瀹炵幇4涓柟娉曪紝鍙敤鍒?涓繛鎺ョ浉鍏崇殑鏂規硶錛孴agConn() 鍜?HandleConn(),
鍙﹀2涓?TagRPC() 鍜?HandleRPC() 鐢ㄤ簬RPC緇熻, 瀹炵幇涓虹┖銆?br />
```go
type statshandler struct{}

// TagConn 鐢ㄦ潵緇欒繛鎺ユ墦涓爣絳撅紝浠ユ鏉ユ爣璇嗚繛鎺?瀹炲湪鏄壘涓嶅嚭榪樻湁浠涔堝姙娉曟潵鏍囪瘑榪炴帴).
// 榪欎釜鏍囩鏄釜鎸囬拡錛屽彲淇濊瘉姣忎釜榪炴帴鍞竴銆?/span>
// 灝嗚鎸囬拡娣誨姞鍒頒笂涓嬫枃涓幓錛岄敭涓?connCtxKey{}.
func (h *statshandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context {
    return context.WithValue(ctx, connCtxKey{}, info)
}

// TagRPC 涓虹┖.
func (h *statshandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
    return ctx
}

// HandleConn 浼氬湪榪炴帴寮濮嬪拰緇撴潫鏃惰璋冪敤錛屽垎鍒細杈撳叆涓嶅悓鐨勭姸鎬?
func (h *statshandler) HandleConn(ctx context.Context, s stats.ConnStats) {
    tag, ok := getConnTagFromContext(ctx)
    if !ok {
        log.Fatal("can not get conn tag")
    }

    connsMutex.Lock()
    defer connsMutex.Unlock()

    switch s.(type) {
    case *stats.ConnBegin:
        conns[tag] = ""
        log.Printf("begin conn, tag = (%p)%#v, now connections = %d\n", tag, tag, len(conns))
    case *stats.ConnEnd:
        delete(conns, tag)
        log.Printf("end conn, tag = (%p)%#v, now connections = %d\n", tag, tag, len(conns))
    default:
        log.Printf("illegal ConnStats type\n")
    }
}

// HandleRPC 涓虹┖.
func (h *statshandler) HandleRPC(ctx context.Context, s stats.RPCStats) {
}
```

鐢ㄤ竴涓猰ap鏉ョ鐞嗘墍鏈夎繛鎺ワ紝浠ヨ繛鎺ョ殑鏍囩(鏄釜鎸囬拡)涓洪敭錛屽間負涓婃璇鋒眰鑰呯殑鍚嶅瓧銆?br />鍥犱負鏈夊綰跨▼璁塊棶錛屾墍鏈夊姞涓?Mutex 鏉ヤ繚鎶ゃ?br />榪炴帴緇撴潫鏃訛紝灝嗕粠 conns 涓垹闄よ繛鎺ョ浉鍏崇殑鏁版嵁銆?br />
```go
var connsMutex sync.Mutex
var conns map[*stats.ConnTagInfo]string = make(map[*stats.ConnTagInfo]string)
```

getConnTagFromContext() 浠庝笂涓嬫枃涓彇榪炴帴鏍囩錛?br />
```go
type connCtxKey struct{}

func getConnTagFromContext(ctx context.Context) (*stats.ConnTagInfo, bool) {
    tag, ok := ctx.Value(connCtxKey{}).(*stats.ConnTagInfo)
    return tag, ok
}
```

鏈鍚庡皢 SayHello() 鏀逛負璁板綍璇鋒眰鑰呭悕瀛楋紝騫惰繑鍥炰笂嬈¤姹傝呯殑鍚嶅瓧銆?br />
```go
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
    tag, _ := getConnTagFromContext(ctx)
    log.Printf("SayHello(), conn tag = (%p)%#v\n", tag, tag)

    connsMutex.Lock()
    defer connsMutex.Unlock()
    prev := conns[tag]
    conns[tag] = in.Name

    return &pb.HelloReply{Message: fmt.Sprintf("Hello '%s' (prev '%s')", in.Name, prev)}, nil
}
```

嫻嬭瘯澶氫釜瀹㈡埛绔繛鎺ワ紝鍙互鐪嬪埌姣忎釜瀹㈡埛绔湁鑷繁鐨勭姸鎬侊紝浜掍笉褰卞搷銆?br />
```
E:\Git\grpc-go\examples\helloworld (master)
λ go run greeter_server/main.go
2017/12/25 18:39:03 start
2017/12/25 18:39:11 begin conn, tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}, now connections = 1
2017/12/25 18:39:11 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}
2017/12/25 18:39:13 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}
2017/12/25 18:39:13 begin conn, tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}, now connections = 2
2017/12/25 18:39:13 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}
2017/12/25 18:39:15 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}
2017/12/25 18:39:15 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}
2017/12/25 18:39:17 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}
2017/12/25 18:39:17 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}
2017/12/25 18:39:19 end conn, tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}, now connections = 1
2017/12/25 18:39:19 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}
2017/12/25 18:39:21 end conn, tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}, now connections = 0
```


閲戝簡 2017-12-25 19:00 鍙戣〃璇勮
]]>
鐢?Lile 鍒涘緩 gRPC-go 鏈嶅姟http://www.shnenglu.com/jinq0123/archive/2017/11/28/215377.html閲戝簡閲戝簡Tue, 28 Nov 2017 10:47:00 GMThttp://www.shnenglu.com/jinq0123/archive/2017/11/28/215377.htmlhttp://www.shnenglu.com/jinq0123/comments/215377.htmlhttp://www.shnenglu.com/jinq0123/archive/2017/11/28/215377.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215377.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215377.html鐢?Lile 鍒涘緩 gRPC-go 鏈嶅姟

(閲戝簡鐨勪笓鏍?2017.11)

Lile 鏄竴涓伐鍏鳳紝鐢ㄤ簬 Go 璇█蹇熷垱寤?gRPC 鏈嶅姟銆?br />https://github.com/lileio/lile

浼氳嚜鍔ㄦ坊鍔?Prometheus, Zipkin 鍜?Google PubSub 鏀寔銆?br />
go get -u github.com/lileio/lile/...
灝嗗畨瑁呮墍鏈変緷璧栧寘錛屽茍鐢熸垚 bin/lile.exe, bin/protoc-gen-lile-server.exe.
鍙﹀榪橀渶瑕佸畨瑁?protoc.exe.

鎸夌収紺轟緥鍒涘緩 users 鏈嶅姟錛?br />
E:\gopath\src\github.com
λ lile new jinq0123/users
Creating project in E:\gopath\src\github.com\jinq0123\users
Is this OK? [y]es/[n]o
y
.
├── server
│   ├── server.go
│   └── server_test.go
├── subscribers
│   └── subscribers.go
├── users
│   ├── cmd
│   │   ├── root.go
│   │   ├── serve.go
│   │   ├── subscribe.go
│   │   └── up.go
│   └── main.go
├── users.proto
├── Makefile
├── Dockerfile
├── .travis.yml
└── .gitignore

鏌ョ湅 Makefile, 澶嶅埗鍏朵腑 protoc 鑴氭湰錛屽皢 $$GOPATH 鏀逛負 %GOPATH%錛岃繍琛岋細

E:\gopath\src\github.com\jinq0123\users
λ protoc -I . users.proto --lile-server_out=. --go_out=plugins=grpc:%GOPATH%/src
2017/11/28 16:59:24 [Creating] server\read.go
2017/11/28 16:59:24 [Creating test] server\read_test.go

protoc-gen-lile-server.exe 灝嗙敓鎴?server\read.go, 瀵瑰簲 user.proto 涓殑鏂規硶 Users::Read().
grpc鐨勬彃浠跺皢鐢熸垚 users.pb.go錛屼笌浠呬粎鐢?grpc 鐢熸垚鐨勪唬鐮佺浉鍚屻?br />
D:/Go/bin/go.exe install -v [E:/gopath/src/github.com/jinq0123/users/users]
github.com/jinq0123/users/users
鎴愬姛: 榪涚▼閫鍑轟唬鐮?0.

鍙洿鎺ョ紪璇戠敓鎴?user.exe.

鏃犲弬鏁拌繍琛屽垯鏄劇ず鍛戒護琛屽府鍔╋細

E:\gopath\src\github.com\jinq0123\users
λ users
A gRPC based service

Usage:
  users [command]

Available Commands:
  help        Help about any command
  serve       Run the RPC server
  subscribe   Subscribe to and process queue messages
  up          up runs both RPC and pubub subscribers

Flags:
  -h, --help   help for users

Use "users [command] --help" for more information about a command.

鐢ㄥ瓙鍛戒護serve鍚姩鏈嶅姟錛?br />
E:\gopath\src\github.com\jinq0123\users
λ users serve
INFO[0000] Serving gRPC on :8000
INFO[0000] Using Zipkin Global tracer
INFO[0000] Prometheus metrics at :9000/metrics

http://localhost:9000/metrics 浼氭樉紺?br />
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
...

鐢?grpc-lua 鏉ユ祴璇曚笅錛?br />
E:\Git\grpc-lua\examples\helloworld (master)
λ lua-cpp.exe
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> package.path = "../../src/lua/?.lua;" .. package.path
> grpc = require("grpc_lua.grpc_lua")
> grpc.import_proto_file("users.proto")
> stub = grpc.service_stub("localhost:8000", "users.Users")
D1128 17:28:13.711000000  4612 dns_resolver.c:301] Using native dns resolver
> request = {id = "abcd"}
> response, err, cod = stub:sync_request("Read", request)
> cod
2
> insp = require("inspect")
> insp(resonse)
nil
> insp(err)
"not yet implemented"

緙虹渷瀹炵幇榪斿洖 "not yet implemented" 閿欒銆傛洿鏀瑰疄鐜頒唬濡備笅錛?br />
func (s UsersServer) Read(ctx context.Context, r *users.Request) (*users.Response, error) {
    // return nil, errors.New("not yet implemented")
    return &users.Response{Id: "Hello, " + r.Id}, nil
}

鍐嶆璇鋒眰錛?br />
> response, err, cod = stub:sync_request("Read", request)
> err
Endpoint read failed
...
> response, err, cod = stub:sync_request("Read", request)
> err
nil
> insp(response)
{
  id = "Hello, abcd"
}


閲戝簡 2017-11-28 18:47 鍙戣〃璇勮
]]>
protobuf涓殑鏋氫婦緙虹渷鍊煎簲璇ヤ負ENUN_TYPE_UNSPECIFIEDhttp://www.shnenglu.com/jinq0123/archive/2017/11/22/215364.html閲戝簡閲戝簡Wed, 22 Nov 2017 02:45:00 GMThttp://www.shnenglu.com/jinq0123/archive/2017/11/22/215364.htmlhttp://www.shnenglu.com/jinq0123/comments/215364.htmlhttp://www.shnenglu.com/jinq0123/archive/2017/11/22/215364.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215364.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215364.htmlprotobuf涓殑鏋氫婦緙虹渷鍊煎簲璇ヤ負ENUN_TYPE_UNSPECIFIED

(閲戝簡鐨勪笓鏍?2017.11)

Googol 鍏竷鐨?API Design 瑙勮寖涓紝*.proto 涓殑鏋氫婦緙虹渷鍊煎緩璁負 ENUN_TYPE_UNSPECIFIED銆?br />
https://mp.weixin.qq.com/s?__biz=MzA5ODg4Mzk2OQ==&mid=2247483705&idx=1&sn=cc2ffef9ac431510c1791dbe6e774b85

The first value should be named ENUM_TYPE_UNSPECIFIED as it is returned when an enum value is not explicitly specified.

enum FooBar {
  // The first value represents the default and must be == 0.
  FOO_BAR_UNSPECIFIED = 0;
  FIRST_VALUE = 1;
  SECOND_VALUE = 2;
}

鍙傝冿細protobuf涓殑鏋氫婦緙虹渷鍊煎簲璇ヤ負UNKNOWN
http://blog.csdn.net/jq0123/article/details/52219597


閲戝簡 2017-11-22 10:45 鍙戣〃璇勮
]]>
鐢?dep 浠f浛 go get 鏉ヨ幏鍙栫鏈夊簱http://www.shnenglu.com/jinq0123/archive/2017/11/06/215328.html閲戝簡閲戝簡Mon, 06 Nov 2017 06:27:00 GMThttp://www.shnenglu.com/jinq0123/archive/2017/11/06/215328.htmlhttp://www.shnenglu.com/jinq0123/comments/215328.htmlhttp://www.shnenglu.com/jinq0123/archive/2017/11/06/215328.html#Feedback0http://www.shnenglu.com/jinq0123/comments/commentRss/215328.htmlhttp://www.shnenglu.com/jinq0123/services/trackbacks/215328.html

鐢?dep 浠f浛 go get 鏉ヨ幏鍙栫鏈夊簱


(閲戝簡鐨勪笓鏍?2017.11)


go get 鍔熻兘姣旇緝寮憋紝鏃犳硶鑾峰彇鍒嗘敮錛屾爣絳撅紝鐗瑰畾鐗堟湰錛宖ork, 鑰?dep 鍙互鍋氬埌銆?code>dep 榪樺彲浠ヨ幏鍙栫鏈夊簱銆?/p>

鐢?gitee.com 縐佹湁搴撲綔嫻嬭瘯銆傚垱寤?gogettest 搴撱?/p>

鍙敤錛?/p>

go get -u gitee.com/jinq0123/gogettest

濡傛灉鏀逛負縐佹湁搴撳垯澶辮觸錛?/p>

λ go get -v gitee.com/jinq0123/gogettest
Fetching https://gitee.com/jinq0123/gogettest?go-get=1
Parsing meta tags from https://gitee.com/jinq0123/gogettest?go-get=1 (status code 403)
package gitee.com/jinq0123/gogettest: unrecognized import path "gitee.com/jinq0123/gogettest" (parse https://gitee.com/jinq0123/gogettest?go-get=1: no go-import meta tags ())

鐢?dep 宸ュ叿鍙栫鏈夊簱

https://github.com/golang/dep

瀹夎dep

go get -u github.com/golang/dep/cmd/dep1

鍒濆鍖?/h3>

鍦ㄩ」鐩洰褰曚笅榪愯錛?/p>

dep init

鐢熸垚 Gopkg.toml 鍜?Gopkg.lock

娣誨姞寮哄埗(constraint)

鍦?Gopkg.toml 涓坊鍔狅細

 

[[constraint]]
  branch = "master"
  name = "gitee.com/jinq012345/gogettest"
  source = "https://gitee.com/jinq0123/gogettest.git"
source 寮哄埗浣跨敤 https 鏉ヨ幏鍙?gotgettest 搴撱?

 

娉ㄦ剰搴撳悕鏀規垚浜?jinq012345, 榪欐牱瀵煎叆錛?
imort "gitee.com/jinq012345/gogettest"

name鍜宻ource鐨勮緗彲鏀寔浠?fork 搴撹幏鍙栥?/p>

鑾峰彇gogettest搴?/h3>
dep ensure

浼氬脊鍑?https 鐨勭櫥褰曠敤鎴峰悕鍜屽瘑鐮佽緭鍏ユ銆?/p>

閲戝簡 2017-11-06 14:27 鍙戣〃璇勮
]]> 精品无码久久久久久国产| 成人久久免费网站| 99久久综合狠狠综合久久| 欧美午夜精品久久久久久浪潮| 色8激情欧美成人久久综合电| 亚洲国产欧美国产综合久久| 99久久免费国产精精品| 女同久久| 久久久青草久久久青草| 久久久久久免费视频| 精品久久久久久亚洲精品| 久久国产精品一区| 成人资源影音先锋久久资源网| 日韩一区二区三区视频久久| 国产精品久久久天天影视| 欧美日韩精品久久久久| 久久97久久97精品免视看秋霞| 无码日韩人妻精品久久蜜桃 | 99久久99这里只有免费费精品| 四虎国产永久免费久久| 色综合久久久久久久久五月| 欧美亚洲另类久久综合婷婷| 蜜桃麻豆www久久| 国产精品岛国久久久久| 久久亚洲AV成人无码国产| 99精品国产免费久久久久久下载| 激情五月综合综合久久69| 99久久精品日本一区二区免费| 无码人妻精品一区二区三区久久久 | 少妇久久久久久被弄到高潮 | 性欧美大战久久久久久久久| 人妻系列无码专区久久五月天| 天天久久狠狠色综合| 女人香蕉久久**毛片精品| 97久久精品午夜一区二区| 久久国产乱子伦免费精品| 久久久久久国产精品免费无码 | 日产精品99久久久久久| 一本一道久久a久久精品综合| 国产成人无码精品久久久久免费| 久久婷婷五月综合97色直播|