Go Context原理及其典型适用场景# Context原理及其适用场景 随手记 李帅(飞雪无情) ___ ¥ 随手记 👨👩👧👦 卡牛 📸 随管家 ___ ## 大纲 常见并发模式 ■ Context实现原理 ☑ TLS VS Context ☑ 典型适用场景 ## Channel func add(a,b int) <-chan int{ sum:=make(chan int) go ## Context ● 一个任务,需要多个goroutine完成 ● 一个请求,会触发好多个goroutine做不同的事情 ● 如果我们的任务终止了,请求取消了,这些正在运行的goroutine怎么办? ● 使用Context来简化这些操作 ## Context能做什么 ## ☑ 手动、定时、超时发出取消信号 ◆ 跨API传值 ☑ 控制生成Context树结构(Context链) func rootctx := context.Background() ctx, cancel := context.WithCancel(rootctx) go watch(ctx) go watch(ctx) time.Sleep(1 * time.Second) cancel() } func watch(ctx context.Context) { for0 码力 | 32 页 | 4.62 MB | 2 年前3
1.5 Go 业务开发中 Error & Context - 毛剑Go业务开发中Error&Context 毛剑 bilibili iammao@vip.qq.com 探探 Gopher China 2019 Agenda Error o Background o Handle Error o Best Practice • Context o Background o Context With API o Best Practice • Conclusion Error - Best Practice 集中处理错误:errorgroup 容易用错返回的context 扇出没有控制 业务代码容易panic type Group func WithContext(ctx context.Context) (*Group, context.Context) func (g *Group) Go(f func() error) func (g *Group) +Go(f func(ctx context.Context) error) +Wait() : error -do(f func(ctx context.Context) error) [functions] +WithCancel(ctx context.Context) : *Group +WithContext(ctx context.Context) : *Group var0 码力 | 26 页 | 10.58 MB | 1 月前3
DeepSeek-V4: Towards Highly Efficient Million-Token Context IntelligenceDeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence DeepSeek-AI research@deepseek.com Abstract We present a preview version of DeepSeek-V4 series, including two strong Mixture-of- parameters (49B activated) and DeepSeek-V4-Flash with 284B parameters (13B activated) both supporting a context length of one million tokens. DeepSeek-V4 series incorporate several key upgrades in architecture combines Compressed Sparse Attention (CSA) and Heavily Compressed Attention (HCA) to improve long-context efficiency; (2) Manifold- Constrained Hyper-Connections (mHC) that enhance conventional residual0 码力 | 58 页 | 4.27 MB | 1 月前3
Falcon v2.0.0 Documentationresource, and method hooks • Idiomatic HTTP error responses • Full Unicode support • Intuitive request and response objects • Works great with async libraries like gevent • Minimal attack surface for Installation - Quickstart - Tutorial - FAQ - Classes and Functions - The API Class - Request & Response - Cookies - Status Codes - Error Handling - Media - Redirection Steps • Hosting Your App • Creating Resources • Testing.your application • Request and Response Objects • Refactoring for testability • Functional tests • Serving0 码力 | 265 页 | 299.57 KB | 2 年前3
Falcon v1.4.1-post-1 Documentationresource, and method hooks • Idiomatic HTTP error responses • Full Unicode support • Intuitive request and response objects • Works great with async libraries like gevent • Minimal attack surface for Installation - Quickstart - Tutorial - FAQ - Classes and Functions - The API Class - Request & Response - Cookies - Status Codes - Error Handling - Media - Redirection Steps • Hosting Your App • Creating Resources • Testing.your application • Request and Response Objects • Refactoring for testability • Functional tests • Serving0 码力 | 229 页 | 273.39 KB | 2 年前3
Guzzle PHP 6.5 DocumentationMaking a Request 1.2.2 Using Responses 1.2.3 Query String Parameters 1.2.4 Uploading Data 1.2.5 Cookies 1.2.6 Redirects 1.2.7 Exceptions 1.2.8 Environment Variables 1.3 Request Options asynchronous requests? 44 1.7.3 How can I add custom cURL options? 44 1.7.4 How can I add custom stream context options? 45 1.7.5 Why am I getting an SSL verification error? 45 1.7.6 What is this Maximum function you to augment and compose client behavior. $client = new GuzzleHttp\Client(); $res = $client->request('GET', 'https://api.github.com/user', ['auth' => ['user', 'pass']]);0 码力 | 50 页 | 237.04 KB | 1 年前3
Guzzle PHP 5.3 Documentationtcpdf.org) ## Contents 1 User guide 3 1.1 Overview 3 1.2 Quickstart 5 1.3 Clients 12 1.4 Request and Response Messages 32 1.5 Event System 39 1.6 Streams 46 1.7 RingPHP Handlers 50 1.8 Testing "User..." var_export($res->json()); // Outputs the JSON decoded data // Send an asynchronous request. $req = $client->createRequest('GET', 'http://httpbin.org', ['future' If you have not already installed, Guzzle, head over to the Installation page. #### 1.2.1 Make a Request You can send requests with Guzzle using a GuzzleHttp\ClientInterface object. ## Creating a Client0 码力 | 63 页 | 275.75 KB | 1 年前3
Spring Framework 1.2.2 Changelogmatch beans with factory method / "factory-bean" definition Package org.springframework.context * added "alwaysUseMessageFormat" property to AbstractMessageSource, enforcing MessageFormat core * fixed ClassPathResource to fall back to its ClassLoader if none specified and no thread context ClassLoader available * deprecated ResourcePatternResolver's "CLASSPATH_URL_PREFIX" scenarios (with database access) from Countries sample application * revised all XML application context definition files to use Spring 1.2 shortcut attributes as far as possible Package org.springframework0 码力 | 72 页 | 205.76 KB | 2 年前3
Guzzle PHP 5.3 Documentation..." var_export($res->json()); // Outputs the JSON decoded data // Send an asynchronous request. $req = $client->createRequest('GET', 'http://html.org', ['future' => • License • Contributing • Reporting a security vulnerability. • Quickstart • Make a Request • Using Responses • Query String Parameters • Uploading Data • Cookies • Redirects • Exceptions Sending Requests • Sending Requests With a Pool • Request Options • Event Subscribers • Environment Variables • Request and Response Messages • Headers • Body •0 码力 | 72 页 | 312.62 KB | 1 年前3
Spring Framework 1.2.1 Changelogregisters BeanFactoryAware as default ignored dependency interface Package org.springframework.context * AbstractApplicationContext registers MessageSourceAware/ApplicationContextAware/etc as ignored DefaultXmlBeanDefinitionParser to correctly parse null keys for XML map entries Package org.springframework.context * reworked LocaleContextHolder to use an InheritableThreadLocal, also exposing the thread-bound removed JndiBeanFactoryLocator, in favor of the existing default ContextJndiBeanFactoryLocator in the context package * deprecated SingletonBeanFactoryLocator's alias-through-String-bean feature, in favor0 码力 | 69 页 | 197.87 KB | 2 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100
相关搜索词
ContextgoroutineTLS并发模式取消信号Errorerrgrouppkg/errorsCodesDeepSeek-V4Compressed Sparse Attention (CSA)Heavily Compressed Attention (HCA)hybrid attentionMixture-of-Experts (MoE)Falcon框架Response classMiddlewareRequest contextCPythonFalconRequestResponseCookieHooksGuzzlePHPHTTP clientrequestresponseHandlerSpring FrameworkBeanFactoryAOPTransactionrequest handlingasynchronous requestsstreamingException Handling













