GithubHelp home page GithubHelp logo

module-grpc's Introduction

Overview

This module provides gRPC entry point for Magento. Additionally, it provides possibility to expose gRPC APIs for other Magento modules

Installation

  • Run bin/magento storefront:grpc:init \\Magento\\CatalogStorefrontApi\\Api\\CatalogProxyServer \\Magento\\CatalogStorefrontApi\\Api\\VariantServiceProxyServer CLI command. The command does the following actions:
    • Copies certain bin files to vendor/bin directory
    • Register services for later use in gRPC sever
  • Install rr-grpc server - https://github.com/spiral/php-grpc. Put the binary in some directory registered in PATH system variable You can also run the following script to install rr-grpc:
curl -LJO https://github.com/spiral/php-grpc/releases/download/v1.4.0/rr-grpc-1.4.0-linux-amd64.tar.gz
tar -xzf rr-grpc-1.4.0-linux-amd64.tar.gz
cp rr-grpc-1.4.0-linux-amd64/rr-grpc /usr/bin
rm -rf rr-grpc-1.4.0-linux-amd64 rr-grpc-1.4.0-linux-amd64.tar.gz 
  • Install protoc-gen-php-grpc protoc plugin - https://github.com/spiral/php-grpc. Put the binary in some directory registered in PATH system variable. You can also run the following script to install protoc-gen-php-grpc:
curl -LJO https://github.com/spiral/php-grpc/releases/download/v1.4.0/protoc-gen-php-grpc-1.4.0-linux-amd64.tar.gz
tar -xzf protoc-gen-php-grpc-1.4.0-linux-amd64.tar.gz
cp protoc-gen-php-grpc-1.4.0-linux-amd64/protoc-gen-php-grpc /usr/bin/grpc_php_plugin
rm -rf protoc-gen-php-grpc-1.4.0-linux-amd64 protoc-gen-php-grpc-1.4.0-linux-amd64.tar.gz
apt update
apt install -y protobuf-compiler
  • Alternatively module module-grpc can be installed via composer if not installed via git yet. composer require magento/module-grpc:0.0.1. Please make sure the package is present in packagist.

Usages

  • Launch /bin/magento proto:marshal CLI command. The command is doing the following actions:

    • Scaffold protobuf classes and interfaces
    • Creates unified protobuf messages and services (magento.proto)
    • Creates protoset file that could be used as a replacement for reflection API (magento.protoset)
    • Register services for later use in gRPC sever
  • Launch ./vendor/bin/grpc-server in Magento root. You can also use this file as a reference for your gRPC configuration.

  • In case of any code changes repeat all steps from Usage section

gRPC services development

  • Declare your proto files in proto3 syntax. The tooling is able to find proto files in /etc directory of Magento modules.
  • Launch /bin/magento proto:marshal in order to get autogenerated interfaces and DTOs
  • Implement interfaces generated by previous step in your module and add appropriate preferences to di.xml file

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the OSL-3.0 License. See LICENSE for more information.

module-grpc's People

Contributors

buskamuza avatar joni-jones avatar kokoc avatar mslabko avatar ruslankostiv1 avatar yaroslavgoncharuk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.