grpc | PHP gRPC based on Swoole coroutine

 by   mix-php PHP Version: binary-210714 License: Apache-2.0

kandi X-RAY | grpc Summary

kandi X-RAY | grpc Summary

grpc is a PHP library typically used in Web Services applications. grpc has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

由于 PHP-FPM 的特殊生命周期,导致 PHP 的 gRPC 官方代码生成器只能生成数据结构和客户端代码,无法像 golang/node.js/python 一样能同时生成服务器代码;传统方式如果要搭建 PHP gRPC 服务器只能借助 nginx+h2+phpfpm 来搭建,这样就不需要 server 代码了,但是短生命周期又无法很好的支持服务注册,因为这些原因导致 PHP 在 gRPC 中一直都是充当 Client 的角色,Mix gRPC 提供了基于 Swoole 的方案:. 让 PHP 编写 gRPC 和 Golang 一样方便快捷,同时性能强劲.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              grpc has a low active ecosystem.
              It has 46 star(s) with 8 fork(s). There are 5 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 1 have been closed. On average issues are closed in 4 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of grpc is binary-210714

            kandi-Quality Quality

              grpc has 0 bugs and 0 code smells.

            kandi-Security Security

              grpc has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              grpc code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              grpc is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              grpc releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed grpc and discovered the below as its top functions. This is intended to give you an instant insight into grpc implemented functionality, and help decide if they suit your requirements.
            • Dispatches the request
            • Registers a service .
            • Sends a request to the server
            • Sends a grpc request
            • Short description of method initOnce
            • Connect to the server
            • Unpack a binary data
            • Get request headers .
            • The error message .
            • Create Context from swoole request .
            Get all kandi verified functions for this library.

            grpc Key Features

            No Key Features are available at this moment for grpc.

            grpc Examples and Code Snippets

            Mix gRPC,编写一个 gRPC 服务
            PHPdot img1Lines of Code : 43dot img1License : Permissive (Apache-2.0)
            copy iconCopy
            // 编写一个服务,实现 protoc-gen-mix 生成的接口
            class SayService implements Php\Micro\Grpc\Greeter\SayInterface
            {
            
                public function Hello(Mix\Grpc\Context $context, Php\Micro\Grpc\Greeter\Request $request): Php\Micro\Grpc\Greeter\Response
                {
                    $respons  
            Mix gRPC,通过 .proto 生成 PHP 代码
            PHPdot img2Lines of Code : 33dot img2License : Permissive (Apache-2.0)
            copy iconCopy
            syntax = "proto3";
            
            package php.micro.grpc.greeter;
            
            service Say {
            	rpc Hello(Request) returns (Response) {}
            }
            
            message Request {
            	string name = 1;
            }
            
            message Response {
            	string msg = 1;
            }
            
            protoc --php_out=. --mix_out=. greeter.proto
            
            |-- GPBMetadat  
            Mix gRPC,客户端调用一个 gRPC 服务
            PHPdot img3Lines of Code : 14dot img3License : Permissive (Apache-2.0)
            copy iconCopy
            Swoole\Coroutine\run(function () {
                $client = new Mix\Grpc\Client('127.0.0.1', 9595); // 推荐复用该客户端
                $say  = new Php\Micro\Grpc\Greeter\SayClient($client);
                $request = new Php\Micro\Grpc\Greeter\Request();
                $request->setName('xiaoming');  

            Community Discussions

            QUESTION

            How to refer to type of impl output in Rust?
            Asked 2022-Mar-28 at 22:40

            I'm trying to implement a stream in Rust for use in a tonic GRPC handler and encountered this difficulty: most ways of creating streams don't have easily-expressible types, yet the GRPC trait I need to implement requires a specific Stream type. Something like this (simplified):

            ...

            ANSWER

            Answered 2022-Mar-28 at 22:40

            Unfortunately there is no good way in stable Rust to do that without dynamic dispatch. You have to use dyn Stream, and futures provides BoxStream for that:

            Source https://stackoverflow.com/questions/71654388

            QUESTION

            android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported
            Asked 2022-Mar-24 at 15:30

            I have added android:exported="true" to my only activity in manifest but still getting below error after updating compile sdk and target sdk version to 31.I also tried rebuilding the project , invalidating cache and restart but that didn't helped

            Error- Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

            AndroidManifest File ...

            ANSWER

            Answered 2021-Oct-05 at 10:38

            After the build has failed go to AndroidManifest.xml and in the bottom click merged manifest see which activities which have intent-filter but don't have exported=true attribute. Or you can just get the activities which are giving error.

            Add these activities to your App manifest with android:exported="true" and app tools:node="merge" this will add exported attribute to the activities giving error.

            Example:

            Source https://stackoverflow.com/questions/69287478

            QUESTION

            grpc.WithInsecure is deprecated: use insecure.NewCredentials() instead
            Asked 2022-Feb-28 at 15:01

            Hey I'm trying make a small test client with Go and Grpc,

            ...

            ANSWER

            Answered 2022-Feb-28 at 15:01

            The function insecure.NewCredentials() returns an implementation of credentials.TransportCredentials.

            You can use it as a DialOption with grpc.WithTransportCredentials:

            Source https://stackoverflow.com/questions/70482508

            QUESTION

            Unable to call gRPC service from Angular client
            Asked 2022-Feb-27 at 01:25

            I am trying to call a gRPC service from Angular application.

            If I host the server locally and call it from Anuglar application then it works.

            ...

            ANSWER

            Answered 2022-Feb-26 at 16:38

            This is most likely caused by the common CORS Browser restrictions, and not exactly by angular. This question contains great guidance on CORS.

            Calling HTTP services from a Node app (or from postman) will not enforce CORS, while calling it from a market standard browser certainly would.

            I know there is far more to it than my next simplified comments but this should give you a starting point (a deeper dive is in the links I shared above)

            For browsers to execute XMLHttpRequest's from one website to other domains (or other ports of the same domain):

            1. the browser will send an OPTIONS HTTP request before every real request to the other domain and only allow the actual request when the OPTIONS response headers authorize it.
            2. the "other" website must be configure to reply to OPTIONS requests with specific Headers (Access-Control-Allow-Origin, Access-Control-Request-* ...).

            ==> If the other server does not reply to OPTIONS requests or does not provide the appropriate headers in the OPTIONS response, you can get a range of different errors, and "Response closed without headers" is one of them.

            I believe your gRPC web application is not configured with the proper CORS to authorize communications from the website where you are hosting your angular application (even if it is localhost, you would still need to configure it).

            This article has practical guidance on how to configure CORS on .netcore applications

            and finally, This github issue / responses contains some more info about a similar error some people faced with gRPC, you might have stepped into the same one. If you have already configured your CORS rules.

            Source https://stackoverflow.com/questions/71176329

            QUESTION

            Could not resolve com.google.guava:guava:30.1-jre - Gradle project sync failed. Basic functionality will not work properly - in kotlin project
            Asked 2022-Feb-14 at 19:47

            It was a project that used to work well in the past, but after updating, the following errors appear.

            ...

            ANSWER

            Answered 2021-Sep-17 at 11:03

            Add mavenCentral() in Build Script

            Source https://stackoverflow.com/questions/69205327

            QUESTION

            Android emulator on apple silicon (arm64) could be run only using sudo mode
            Asked 2022-Feb-03 at 21:53

            I'm trying to start android emulator on apple silicon mac and I'm always getting the same results:

            1. Running emulator directly through Android Studio (the latest stable version, Arctic Fox 2020.3.1 Patch 4) causes a problem, when the process qemu-system-arch64 stucks and uses 99% CPU (there is no emulator's screen or something like than). Such behavior produces some logs:

            internal-error-msg.txt says:

            ...

            ANSWER

            Answered 2022-Feb-03 at 21:53

            Issue was successfully fixed in Android Emulator revision 31.2.7. Just go to Android SDK Manager and update it!

            According to android emulator release notes:

            Source https://stackoverflow.com/questions/70713301

            QUESTION

            Intermittent authentication error when posting to a pubsub topic
            Asked 2022-Jan-27 at 17:18

            We have a data pipeline built in Google Cloud Dataflow that consumes messages from a pubsub topic and streams them into BigQuery. In order to test that it works successfully we have some tests that run in a CI pipeline, these tests post messages onto the pubsub topic and verify that the messages are written to BigQuery successfully.

            This is the code that posts to the pubsub topic:

            ...

            ANSWER

            Answered 2022-Jan-27 at 17:18

            We had the same error. Finally solved it by using a JSON Web Token for authentication per Google's Quckstart. Like so:

            Source https://stackoverflow.com/questions/70172317

            QUESTION

            Http response at 400 or 500 level
            Asked 2021-Dec-21 at 11:45

            I'm novice in gRPC. My program is written with ‍‍nuxtjs and is a simple login page that receives the username and password and sends it to the server using gRPC. Everything is fine when I submit a request with BloomRPC. But when using the browser, the request is not sent to the server.

            My auth class is as follow:

            ...

            ANSWER

            Answered 2021-Dec-17 at 14:00

            According to chrome screenshot you trying to access to 5005 port in JS, but according to BloomRPC, screenshot your service listening 50051.

            Source https://stackoverflow.com/questions/70393465

            QUESTION

            How to configure GKE Autopilot w/Envoy & gRPC-Web
            Asked 2021-Dec-14 at 20:31

            I have an application running on my local machine that uses React -> gRPC-Web -> Envoy -> Go app and everything runs with no problems. I'm trying to deploy this using GKE Autopilot and I just haven't been able to get the configuration right. I'm new to all of GCP/GKE, so I'm looking for help to figure out where I'm going wrong.

            I was following this doc initially, even though I only have one gRPC service: https://cloud.google.com/architecture/exposing-grpc-services-on-gke-using-envoy-proxy

            From what I've read, GKE Autopilot mode requires using External HTTP(s) load balancing instead of Network Load Balancing as described in the above solution, so I've been trying to get that to work. After a variety of attempts, my current strategy has an Ingress, BackendConfig, Service, and Deployment. The deployment has three containers: my app, an Envoy sidecar to transform the gRPC-Web requests and responses, and a cloud SQL proxy sidecar. I eventually want to be using TLS, but for now, I left that out so it wouldn't complicate things even more.

            When I apply all of the configs, the backend service shows one backend in one zone and the health check fails. The health check is set for port 8080 and path /healthz which is what I think I've specified in the deployment config, but I'm suspicious because when I look at the details for the envoy-sidecar container, it shows the Readiness probe as: http-get HTTP://:0/healthz headers=x-envoy-livenessprobe:healthz. Does ":0" just mean it's using the default address and port for the container, or does indicate a config problem?

            I've been reading various docs and just haven't been able to piece it all together. Is there an example somewhere that shows how this can be done? I've been searching and haven't found one.

            My current configs are:

            ...

            ANSWER

            Answered 2021-Oct-14 at 22:35

            Here is some documentation about Setting up HTTP(S) Load Balancing with Ingress. This tutorial shows how to run a web application behind an external HTTP(S) load balancer by configuring the Ingress resource.

            Related to Creating a HTTP Load Balancer on GKE using Ingress, I found two threads where instances created are marked as unhealthy.

            In the first one, they mention the necessity to manually enable a firewall rule to allow http load balancer ip range to pass health check.

            In the second one, they mention that the Pod’s spec must also include containerPort. Example:

            Source https://stackoverflow.com/questions/69560536

            QUESTION

            Android Emulator keeps quitting when taking screenshots
            Asked 2021-Dec-04 at 02:28

            I can't recall if I have ever tinkered with the settings of Android Emulator, but I've been testing my app on an Android Emulator using Android Studio, and every time I take a screenshot, it crashes.

            I tried deleting, and wiping, and creating a new Emulator. None of it works. I tried also to take a screenshot without running my app, with a fresh emulator, and the same problem occurs. It just crashes whenever I try to take a picture.

            Android Studio reports this error:

            Blockquote WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator. WARNING | cannot add library /Users/sbenati/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed INFO | configAndStartRenderer: setting vsync to 60 hz INFO | added library /Users/sbenati/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib WARNING | cannot add library /Users/sbenati/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed INFO | added library /Users/sbenati/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib INFO | Started GRPC server at 127.0.0.1:8554, security: Local INFO | Advertising in: /Users/sbenati/Library/Caches/TemporaryItems/avd/running/pid_935.ini

            My machine is a Mac with 32GB of RAM and i7 CPU, so I can't imaging this an issue with system performance.

            If no one has any suggestions, I will have to just reinstall everything. Thanks for the tips everyone.

            Edit:

            I ran this on a new Mac mini I recently acquired, and got this really helpful message. I traced it down to a suggested solution about switching off Vulcan, but it did not work for me.

            ...

            ANSWER

            Answered 2021-Dec-04 at 02:28

            I've been having the same problem (I'm on macOS Monterey), each time I try to take a screenshot the emulator crashes.

            Sadly I haven't found a direct solution to this problem, that is a solution fixing the issue in the simulator. But I have learned that it is possible to take screenshots of the app from inside Android Studio, using Logcat.

            Essentially, when you're running your app, if you go to the Logcat tab, there is a screenshot option which does seem to work without crashing. I've added a link to developer.android.com which explains how to do it.

            Even thought this doesn't exactly fix the problem I hope it helps!

            Take a screenshot (through android studio)

            Edit:

            I am happy to report that after a recent update for the emulator released by the developers, the issue no longer exists for me! The screenshot button has now started working again.

            So if someone has the issue, I believe it can now be fixed by just updating your emulator to the latest version available.

            Source https://stackoverflow.com/questions/69654531

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install grpc

            Swoole >= 4.4.4: https://wiki.swoole.com/#/environment
            需要开启 --enable-http2

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/mix-php/grpc.git

          • CLI

            gh repo clone mix-php/grpc

          • sshUrl

            git@github.com:mix-php/grpc.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular PHP Libraries

            laravel

            by laravel

            SecLists

            by danielmiessler

            framework

            by laravel

            symfony

            by symfony

            Try Top Libraries by mix-php

            mix

            by mix-phpPHP

            swoolefor

            by mix-phpPHP

            mix-phar-skeleton

            by mix-phpPHP

            vega

            by mix-phpPHP

            guzzle

            by mix-phpPHP