diff --git a/art_and_logic/1-efun/.gitignore b/art_and_logic/1-efun/.gitignore deleted file mode 100644 index 6998410..0000000 --- a/art_and_logic/1-efun/.gitignore +++ /dev/null @@ -1,70 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# pyenv, -.python-version - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# mypy -.mypy_cache/ - -# Others -.DS_Store diff --git a/art_and_logic/1-efun/AlpcPart1-190801.pdf b/art_and_logic/1-efun/AlpcPart1-190801.pdf deleted file mode 100644 index 7c81750..0000000 Binary files a/art_and_logic/1-efun/AlpcPart1-190801.pdf and /dev/null differ diff --git a/art_and_logic/2-epen/AlpcPart2-190801.pdf b/art_and_logic/2-epen/AlpcPart2-190801.pdf deleted file mode 100644 index 01ee27c..0000000 Binary files a/art_and_logic/2-epen/AlpcPart2-190801.pdf and /dev/null differ diff --git a/emotive.io/1.py b/emotive.io/1.py deleted file mode 100644 index 37d34b0..0000000 --- a/emotive.io/1.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 - -# Examples from the exercise. -id_list1 = [122, 144, 122, 144, 182] -id_list1_return = [122, 123, 144, 145, 182] -id_list2 = [13458, 13890, 13890, 144568, 144568] -id_list2_return = [13458, 13890, 13891, 144568, 144569] - -# Additional examples, -id_list3 = [] -id_list4 = [0, 0, 0, 0, 0] -id_list4_return = [0, 1, 2, 3, 4] - - -def deduplicate_copilots_ids(id_list): - ''' Take an array of unsorted integer IDs and use sequential - addition to deduplicate. Returns a sorted list of these IDs.''' - - aux_dict = {} - for k in id_list: - if k in aux_dict.keys(): - aux_dict[k] = aux_dict[k] + 1 - else: - aux_dict[k] = 1 - - new_list = [] - for key, value in aux_dict.items(): - for i in range(0, value): - new_list.append(key + i) - - # Note: sorted() used Timsort algorithm, which is nLog(n) - return sorted(new_list) - - -# Tests should pass. -assert(deduplicate_copilots_ids(id_list1) == id_list1_return) -assert(deduplicate_copilots_ids(id_list2) == id_list2_return) -assert(deduplicate_copilots_ids(id_list3) == []) -assert(deduplicate_copilots_ids(id_list4) == id_list4_return) diff --git a/emotive.io/2.py b/emotive.io/2.py deleted file mode 100644 index 88649e9..0000000 --- a/emotive.io/2.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python3 - -import sys -from pprint import pprint -from pymongo import MongoClient - - -class AWS_fail(object): - def __init__(self): - self.client = MongoClient('localhost', 27017) - self.db = self.client.aws_fail - - def print_collection(self): - ''' Print the entire items collection. Debug purposes.''' - for item in self.db.items.find(): - pprint(item) - - def item_exists(self, sku): - ''' Check whether a given sku entry exists in the collection.''' - return self.db.items.find_one({'sku_number': sku}) - - def add_item_db(self, sku): - ''' Add a new sku to the collection or increment its value.''' - if not self.item_exists(sku): - self.db.items.insert_one({'sku_number': sku, 'quantity': 1}) - else: - self.db.items.update_one({'sku_number': sku}, {'$inc': {'quantity': 1}}) - - def rm_item_db(self, sku): - ''' Remove a sku item from the database.''' - if self.item_exists(sku): - self.db.items.delete_one({'sku_number': sku}) - - def check_quantity_count(self, z): - ''' Check whether the sku item has the given z quantity.''' - z_found = self.db.items.find_one({'quantity': int(z)}) - if z_found: - pprint(1) - else: - pprint(0) - - def cleanup(self): - self.db.items.drop() - - -def load_input(filename): - ''' Load input file with list of db operations.''' - try: - with open(filename) as f: - input_data = f.readlines() - return input_data[0], input_data[1:] - except IOError: - pprint('Could not read file: {}. Exiting.').format(f) - sys.exit(1) - - -def run_operation(operation, aws_fail): - ''' Run the db operations for the given db collection.''' - if operation[0] == '1': - aws_fail.add_item_db(operation[1]) - elif operation[0] == '2': - aws_fail.rm_item_db(operation[1]) - elif operation[0] == '3': - aws_fail.check_quantity_count(operation[1]) - - -if __name__ == "__main__": - - aws_fail = AWS_fail() - - filename = 'input_for_2.txt' - num_operations, operation_list = load_input(filename) - - # We could use len(operation_list) here, but let's use the input info - # because len() is not optimized for a large number of operations - for i in range(int(num_operations)): - operation = operation_list[i].strip('\n').split(',') - run_operation(operation, aws_fail) - - aws_fail.cleanup() - \ No newline at end of file diff --git a/emotive.io/3.md b/emotive.io/3.md deleted file mode 100644 index 0ad925b..0000000 --- a/emotive.io/3.md +++ /dev/null @@ -1,83 +0,0 @@ -# Ex 3 - -``` -Bitly is an important service that basically maps and shortens long URLs and replaces them with a different URL of the form bit.ly/[Some Hashcode]. -Emotive uses Bitly to match URLs to a bitly link that gets sent out to customers and redirect to the longer link. - -The hashcode is usually of the form A-Z and 0-9. Assume Bitly is down for a week and you need to architect a system that functions like bitly. -Walk through the brief architecture of such a system, talk about the calls, the servers, and the design of the database. -Be prepared to talk about scaling such a system to higher levels. How would you handle one URL? How would you handle 10 million URLs? -``` - - -## Handling one URL - - -If we only need to handle a few URLs, we could simply have a web server (say in an AWS EC2 instance or in an AWS S3 bucket) that takes and process the given long URL, returning the short URL: - -- For each given long URL, we could create a simple HTML page with URL redirect tag in the head and add that to S3 bucket. The S3 bucket hosting the website would open the page which automatically redirects. -- Or we could have a web app running in EC2 with the algorithm that would do the encode/decoding. This would compute a unique hash (e.g. MD5) of the given long URL, and the hash then could be encoded to base36 or even base64 (depending on how we want the final short URL to look). - - -In any of the cases above, since we don’t need to worry about scalability, we would keep our data in a small key-value database. We could either use: - -- a RDBMS, which provides acid properties. We would have two tables: one for storing information about the URL mappings and other for the user info. -- a smaller key-value database such as AWS SimpleDB, or depending on the cases, an in-memory key-value database such as Redis or Memcached. The short URL is the key, the long URL (and any metadata such as date/time), the value. - - -The API should have the following methods: - -- **add new URL**: - - get long link URL - - encode the link URL to a small URL - - saves both URLs and metadata in a key-value database - - (optional) save or log request information (for analytics) - - (optional) add an expiration date for the URLs - -- **retrieve long URL, given the short URL** - - do a database lookup with the short URL: - - if the URL exists in the database, returns the long URL - - (optional) log or saves the request information (analytics) - - if URL does not exist (or expired) return error - -- **delete URL entry** - - do a database lookup with the shorter URL: - - if the URL exists in the database, delete the entry - - if URL does not exist (or expired) return error - - - -## Handling 10 million URLs - - -Now we are concerned about things such as high availability and avoiding URL collisions. Additionally, we might be interested in profit $$, so gathering and processing analytics/metadata/request info etc. is a must. - -If we are still using the EC2 or S3 architecture, we might horizontally scale it with a proxy or a pool of hosts (and manager of a pool of hosts). ZooKeeper is a distributed coordination service to manage a large set of hosts and offers key-value store. We could use AWS Elastic Load Balancing as well if we opted for EC2 instances. - -We would like to have a more scalable key/value database, such as AWS DynamoDB. - -We could have a cache (such as Redis or Memcached) with the most popular URLs, for quick retrieval (and we would take extra care with expiration). - -However, in nowadays applications, the architecture lined above is becoming obsolete. Best options have distinct asynchronous and synchronous pipelines. - - For synchronous requests, we can use microservices in containers (and orchestrated by Kubernetes). - -For asynchronous requests, depending on the volume of requests, we could either couple microservices with a distributed streaming platforms (such as Kafka), or create a pipeline with a queue (such as AWS SQS) and serverless functions (such as AWS Lambda), with the database. - -#### Microservices for URL conversion (synchronous) - -The URL conversion should be as faster as possible. We could process the information into backend microservices running into (Docker) containers in a Kubernetes cluster (such as AWS EK). This is ideal for: -- the URL shortener algorithm -- a Spam checker algorithm - -Vertical scaling is straightforward as well (in Kubernetes, we could scale by just adding more pods). - - -#### Distributed streaming platform and Event-driven serverless computing for Event Analytics (asynchronous) - -Whenever a link is shortened, we can send a message in a topic in a distributed streaming platform, such as Kafka or AWS Kinesis. Consumers would pick up the data and save into a database, or process the information into backend services running either in event-driven serverless computing platforms (such as AWS Lambda functions) or into microservices. This is ideal for: - -- Data analysis, process, machine learning -- Elasticsearch, log process -- extra-availability services, such as writing the short and long URLs into a S3 (say into HDFS format), and then connect a local Memcached instance to cache S3 lookups - diff --git a/emotive.io/Emotive Take Home 48 Hour Test.pdf b/emotive.io/Emotive Take Home 48 Hour Test.pdf deleted file mode 100644 index eed8888..0000000 Binary files a/emotive.io/Emotive Take Home 48 Hour Test.pdf and /dev/null differ diff --git a/emotive.io/README.md b/emotive.io/README.md deleted file mode 100644 index 2e47cfa..0000000 --- a/emotive.io/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# emotive.io take home test - -(Private) Repository with Emotive.io take home Project. - -## Ex 1: - -Run: - -``` -python3 1.py -``` - -Assertions should pass so nothing should be sent to STDOUT. - - -## Ex 2: - -Create a virtual env and install dependencies: - -``` -virtualenv venv -pip install -r requirements.txt -``` - -Run: - -``` -python3 2.py -``` - -Should print: - -``` -0 -1 -``` - -## Ex 3: - -Find solution in `3.md`. diff --git a/emotive.io/input_for_2.txt b/emotive.io/input_for_2.txt deleted file mode 100644 index abe4311..0000000 --- a/emotive.io/input_for_2.txt +++ /dev/null @@ -1,7 +0,0 @@ -6 -1, 114 -1, 115 -1, 116 -2, 115 -3, 2 -3, 1 \ No newline at end of file diff --git a/emotive.io/requirements.txt b/emotive.io/requirements.txt deleted file mode 100644 index 51a850c..0000000 --- a/emotive.io/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pymongo==3.9.0 diff --git a/netflix/problem.pdf b/netflix/problem.pdf deleted file mode 100644 index 255ecd0..0000000 Binary files a/netflix/problem.pdf and /dev/null differ diff --git a/art_and_logic/.gitkeep b/small-projects/enconding-decimals/.gitkeep similarity index 100% rename from art_and_logic/.gitkeep rename to small-projects/enconding-decimals/.gitkeep diff --git a/art_and_logic/1-efun/Makefile b/small-projects/enconding-decimals/Makefile similarity index 100% rename from art_and_logic/1-efun/Makefile rename to small-projects/enconding-decimals/Makefile diff --git a/art_and_logic/1-efun/README.md b/small-projects/enconding-decimals/README.md similarity index 72% rename from art_and_logic/1-efun/README.md rename to small-projects/enconding-decimals/README.md index 5a251cd..03ed063 100644 --- a/art_and_logic/1-efun/README.md +++ b/small-projects/enconding-decimals/README.md @@ -1,6 +1,11 @@ -# Efun: Art + Logic Enconding + Decoding +# Enconding decimals + +This program: + +i) converts and encodes a 14-bit decimal input value to a 2-byte hexadecimal, +ii) decodes hexadecimal representations to 14-bit decimal + -This program i) converts and encodes a 14-bit decimal input value to a 2-byte hexadecimal, ii) decodes hexadecimal representations to 14-bit decimal (as described in [this doc](https://github.com/bt3gl/PRIV-Interview_take_home_projects/blob/master/art_and_logic/1-efun/AlpcPart1-190801.pdf). ## Installing diff --git a/art_and_logic/1-efun/data/ConvertedData.txt b/small-projects/enconding-decimals/data/ConvertedData.txt similarity index 100% rename from art_and_logic/1-efun/data/ConvertedData.txt rename to small-projects/enconding-decimals/data/ConvertedData.txt diff --git a/art_and_logic/1-efun/main_test.py b/small-projects/enconding-decimals/main_test.py similarity index 100% rename from art_and_logic/1-efun/main_test.py rename to small-projects/enconding-decimals/main_test.py diff --git a/art_and_logic/1-efun/requirements.txt b/small-projects/enconding-decimals/requirements.txt similarity index 100% rename from art_and_logic/1-efun/requirements.txt rename to small-projects/enconding-decimals/requirements.txt diff --git a/art_and_logic/1-efun/setup.py b/small-projects/enconding-decimals/setup.py similarity index 100% rename from art_and_logic/1-efun/setup.py rename to small-projects/enconding-decimals/setup.py diff --git a/art_and_logic/1-efun/src/__init__.py b/small-projects/enconding-decimals/src/__init__.py similarity index 100% rename from art_and_logic/1-efun/src/__init__.py rename to small-projects/enconding-decimals/src/__init__.py diff --git a/art_and_logic/1-efun/src/main.py b/small-projects/enconding-decimals/src/main.py similarity index 100% rename from art_and_logic/1-efun/src/main.py rename to small-projects/enconding-decimals/src/main.py diff --git a/art_and_logic/1-efun/test/__init__.py b/small-projects/enconding-decimals/test/__init__.py similarity index 100% rename from art_and_logic/1-efun/test/__init__.py rename to small-projects/enconding-decimals/test/__init__.py diff --git a/art_and_logic/1-efun/tox.ini b/small-projects/enconding-decimals/tox.ini similarity index 100% rename from art_and_logic/1-efun/tox.ini rename to small-projects/enconding-decimals/tox.ini diff --git a/netflix/.gitignore b/small-projects/finding-blob-boundary/.gitignore similarity index 100% rename from netflix/.gitignore rename to small-projects/finding-blob-boundary/.gitignore diff --git a/netflix/Makefile b/small-projects/finding-blob-boundary/Makefile similarity index 100% rename from netflix/Makefile rename to small-projects/finding-blob-boundary/Makefile diff --git a/small-projects/finding-blob-boundary/README.md b/small-projects/finding-blob-boundary/README.md new file mode 100644 index 0000000..630fbbf --- /dev/null +++ b/small-projects/finding-blob-boundary/README.md @@ -0,0 +1 @@ +## Findng blob boundary diff --git a/netflix/find_glob_boundary.py b/small-projects/finding-blob-boundary/find_glob_boundary.py similarity index 100% rename from netflix/find_glob_boundary.py rename to small-projects/finding-blob-boundary/find_glob_boundary.py diff --git a/art_and_logic/2-epen/.env_example b/small-projects/magic-pen/.env_example similarity index 100% rename from art_and_logic/2-epen/.env_example rename to small-projects/magic-pen/.env_example diff --git a/art_and_logic/2-epen/.gitignore b/small-projects/magic-pen/.gitignore similarity index 100% rename from art_and_logic/2-epen/.gitignore rename to small-projects/magic-pen/.gitignore diff --git a/art_and_logic/2-epen/Makefile b/small-projects/magic-pen/Makefile similarity index 100% rename from art_and_logic/2-epen/Makefile rename to small-projects/magic-pen/Makefile diff --git a/art_and_logic/2-epen/README.md b/small-projects/magic-pen/README.md similarity index 87% rename from art_and_logic/2-epen/README.md rename to small-projects/magic-pen/README.md index 63707a8..386e8ff 100644 --- a/art_and_logic/2-epen/README.md +++ b/small-projects/magic-pen/README.md @@ -1,6 +1,7 @@ -# EPen: Art + Logic Pen Language +# Magic pen + +This program creates an interface for a digital pen for drawing. -This program creates an interface for a digital pen for drawing, as described on [this document](https://github.com/bt3gl/PRIV-Interview_take_home_projects/blob/master/art_and_logic/2-epen/AlpcPart2-190801.pdf). ---- diff --git a/art_and_logic/2-epen/data/ConvertedData.txt b/small-projects/magic-pen/data/ConvertedData.txt similarity index 100% rename from art_and_logic/2-epen/data/ConvertedData.txt rename to small-projects/magic-pen/data/ConvertedData.txt diff --git a/art_and_logic/2-epen/data/InputStream.txt b/small-projects/magic-pen/data/InputStream.txt similarity index 100% rename from art_and_logic/2-epen/data/InputStream.txt rename to small-projects/magic-pen/data/InputStream.txt diff --git a/art_and_logic/2-epen/requirements.txt b/small-projects/magic-pen/requirements.txt similarity index 100% rename from art_and_logic/2-epen/requirements.txt rename to small-projects/magic-pen/requirements.txt diff --git a/art_and_logic/2-epen/setup.py b/small-projects/magic-pen/setup.py similarity index 100% rename from art_and_logic/2-epen/setup.py rename to small-projects/magic-pen/setup.py diff --git a/art_and_logic/2-epen/src/Epen.py b/small-projects/magic-pen/src/Epen.py similarity index 100% rename from art_and_logic/2-epen/src/Epen.py rename to small-projects/magic-pen/src/Epen.py diff --git a/art_and_logic/2-epen/src/__init__.py b/small-projects/magic-pen/src/__init__.py similarity index 100% rename from art_and_logic/2-epen/src/__init__.py rename to small-projects/magic-pen/src/__init__.py diff --git a/art_and_logic/2-epen/src/encoder.py b/small-projects/magic-pen/src/encoder.py similarity index 100% rename from art_and_logic/2-epen/src/encoder.py rename to small-projects/magic-pen/src/encoder.py diff --git a/art_and_logic/2-epen/src/main.py b/small-projects/magic-pen/src/main.py similarity index 100% rename from art_and_logic/2-epen/src/main.py rename to small-projects/magic-pen/src/main.py diff --git a/art_and_logic/2-epen/src/settings.py b/small-projects/magic-pen/src/settings.py similarity index 100% rename from art_and_logic/2-epen/src/settings.py rename to small-projects/magic-pen/src/settings.py diff --git a/art_and_logic/2-epen/src/utils.py b/small-projects/magic-pen/src/utils.py similarity index 100% rename from art_and_logic/2-epen/src/utils.py rename to small-projects/magic-pen/src/utils.py diff --git a/art_and_logic/2-epen/tox.ini b/small-projects/magic-pen/tox.ini similarity index 100% rename from art_and_logic/2-epen/tox.ini rename to small-projects/magic-pen/tox.ini diff --git a/maze-puzzle/.gitkeep b/small-projects/maze-puzzle/.gitkeep similarity index 100% rename from maze-puzzle/.gitkeep rename to small-projects/maze-puzzle/.gitkeep diff --git a/maze-puzzle/README.md b/small-projects/maze-puzzle/README.md similarity index 100% rename from maze-puzzle/README.md rename to small-projects/maze-puzzle/README.md diff --git a/maze-puzzle/src/clients/product_detail_client.py b/small-projects/maze-puzzle/src/clients/product_detail_client.py similarity index 100% rename from maze-puzzle/src/clients/product_detail_client.py rename to small-projects/maze-puzzle/src/clients/product_detail_client.py diff --git a/maze-puzzle/src/clients/product_search_client.py b/small-projects/maze-puzzle/src/clients/product_search_client.py similarity index 100% rename from maze-puzzle/src/clients/product_search_client.py rename to small-projects/maze-puzzle/src/clients/product_search_client.py diff --git a/maze-puzzle/src/service.py b/small-projects/maze-puzzle/src/service.py similarity index 100% rename from maze-puzzle/src/service.py rename to small-projects/maze-puzzle/src/service.py diff --git a/maze-puzzle/tests/service_test.py b/small-projects/maze-puzzle/tests/service_test.py similarity index 100% rename from maze-puzzle/tests/service_test.py rename to small-projects/maze-puzzle/tests/service_test.py diff --git a/small-projects/medium/README.md b/small-projects/medium/README.md new file mode 100644 index 0000000..36ee454 --- /dev/null +++ b/small-projects/medium/README.md @@ -0,0 +1 @@ +## Parsing medium posts diff --git a/medium/posts.py b/small-projects/medium/posts.py similarity index 100% rename from medium/posts.py rename to small-projects/medium/posts.py diff --git a/zapata/.keep b/zapata/.keep deleted file mode 100644 index 8b13789..0000000 --- a/zapata/.keep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/zapata/example/.keep b/zapata/example/.keep deleted file mode 100644 index 8b13789..0000000 --- a/zapata/example/.keep +++ /dev/null @@ -1 +0,0 @@ - diff --git a/zapata/example/main/example.proto b/zapata/example/main/example.proto deleted file mode 100644 index 64c4bff..0000000 --- a/zapata/example/main/example.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; -package tutorial; - -import "google/protobuf/timestamp.proto"; -option go_package = "github.com/protocolbuffers/protobuf/examples/go/tutorialpb"; - -message Person { - string name = 1; - int32 id = 2; // Unique ID number for this person. - string email = 3; - - enum PhoneType { - MOBILE = 0; - HOME = 1; - WORK = 2; - } - - message PhoneNumber { - string number = 1; - PhoneType type = 2; - } - - repeated PhoneNumber phones = 4; - - google.protobuf.Timestamp last_updated = 5; -} - -// Our address book file is just one of these. -message AddressBook { - repeated Person people = 1; -} \ No newline at end of file diff --git a/zapata/example/main/github.com/protocolbuffers/protobuf/examples/go/tutorialpb/example.pb.go b/zapata/example/main/github.com/protocolbuffers/protobuf/examples/go/tutorialpb/example.pb.go deleted file mode 100644 index 0059071..0000000 --- a/zapata/example/main/github.com/protocolbuffers/protobuf/examples/go/tutorialpb/example.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.20.1-devel -// protoc v3.11.4 -// source: example.proto - -package tutorialpb - -import ( - proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type Person_PhoneType int32 - -const ( - Person_MOBILE Person_PhoneType = 0 - Person_HOME Person_PhoneType = 1 - Person_WORK Person_PhoneType = 2 -) - -// Enum value maps for Person_PhoneType. -var ( - Person_PhoneType_name = map[int32]string{ - 0: "MOBILE", - 1: "HOME", - 2: "WORK", - } - Person_PhoneType_value = map[string]int32{ - "MOBILE": 0, - "HOME": 1, - "WORK": 2, - } -) - -func (x Person_PhoneType) Enum() *Person_PhoneType { - p := new(Person_PhoneType) - *p = x - return p -} - -func (x Person_PhoneType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Person_PhoneType) Descriptor() protoreflect.EnumDescriptor { - return file_example_proto_enumTypes[0].Descriptor() -} - -func (Person_PhoneType) Type() protoreflect.EnumType { - return &file_example_proto_enumTypes[0] -} - -func (x Person_PhoneType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Person_PhoneType.Descriptor instead. -func (Person_PhoneType) EnumDescriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{0, 0} -} - -type Person struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` // Unique ID number for this person. - Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` - Phones []*Person_PhoneNumber `protobuf:"bytes,4,rep,name=phones,proto3" json:"phones,omitempty"` - LastUpdated *timestamp.Timestamp `protobuf:"bytes,5,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"` -} - -func (x *Person) Reset() { - *x = Person{} - if protoimpl.UnsafeEnabled { - mi := &file_example_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Person) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Person) ProtoMessage() {} - -func (x *Person) ProtoReflect() protoreflect.Message { - mi := &file_example_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Person.ProtoReflect.Descriptor instead. -func (*Person) Descriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{0} -} - -func (x *Person) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Person) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Person) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - -func (x *Person) GetPhones() []*Person_PhoneNumber { - if x != nil { - return x.Phones - } - return nil -} - -func (x *Person) GetLastUpdated() *timestamp.Timestamp { - if x != nil { - return x.LastUpdated - } - return nil -} - -// Our address book file is just one of these. -type AddressBook struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - People []*Person `protobuf:"bytes,1,rep,name=people,proto3" json:"people,omitempty"` -} - -func (x *AddressBook) Reset() { - *x = AddressBook{} - if protoimpl.UnsafeEnabled { - mi := &file_example_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddressBook) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddressBook) ProtoMessage() {} - -func (x *AddressBook) ProtoReflect() protoreflect.Message { - mi := &file_example_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddressBook.ProtoReflect.Descriptor instead. -func (*AddressBook) Descriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{1} -} - -func (x *AddressBook) GetPeople() []*Person { - if x != nil { - return x.People - } - return nil -} - -type Person_PhoneNumber struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Number string `protobuf:"bytes,1,opt,name=number,proto3" json:"number,omitempty"` - Type Person_PhoneType `protobuf:"varint,2,opt,name=type,proto3,enum=tutorial.Person_PhoneType" json:"type,omitempty"` -} - -func (x *Person_PhoneNumber) Reset() { - *x = Person_PhoneNumber{} - if protoimpl.UnsafeEnabled { - mi := &file_example_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Person_PhoneNumber) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Person_PhoneNumber) ProtoMessage() {} - -func (x *Person_PhoneNumber) ProtoReflect() protoreflect.Message { - mi := &file_example_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Person_PhoneNumber.ProtoReflect.Descriptor instead. -func (*Person_PhoneNumber) Descriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *Person_PhoneNumber) GetNumber() string { - if x != nil { - return x.Number - } - return "" -} - -func (x *Person_PhoneNumber) GetType() Person_PhoneType { - if x != nil { - return x.Type - } - return Person_MOBILE -} - -var File_example_proto protoreflect.FileDescriptor - -var file_example_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x08, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbb, 0x02, 0x0a, 0x06, 0x50, - 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, - 0x34, 0x0a, 0x06, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, - 0x6e, 0x2e, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x06, 0x70, - 0x68, 0x6f, 0x6e, 0x65, 0x73, 0x12, 0x3d, 0x0a, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x64, 0x1a, 0x55, 0x0a, 0x0b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x74, 0x75, 0x74, 0x6f, - 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x2e, 0x50, 0x68, 0x6f, 0x6e, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2b, 0x0a, 0x09, 0x50, - 0x68, 0x6f, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x4f, 0x42, 0x49, - 0x4c, 0x45, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x4f, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x02, 0x22, 0x37, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x28, 0x0a, 0x06, 0x70, 0x65, 0x6f, 0x70, 0x6c, - 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, - 0x61, 0x6c, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x52, 0x06, 0x70, 0x65, 0x6f, 0x70, 0x6c, - 0x65, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x73, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, - 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_example_proto_rawDescOnce sync.Once - file_example_proto_rawDescData = file_example_proto_rawDesc -) - -func file_example_proto_rawDescGZIP() []byte { - file_example_proto_rawDescOnce.Do(func() { - file_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_example_proto_rawDescData) - }) - return file_example_proto_rawDescData -} - -var file_example_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_example_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_example_proto_goTypes = []interface{}{ - (Person_PhoneType)(0), // 0: tutorial.Person.PhoneType - (*Person)(nil), // 1: tutorial.Person - (*AddressBook)(nil), // 2: tutorial.AddressBook - (*Person_PhoneNumber)(nil), // 3: tutorial.Person.PhoneNumber - (*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp -} -var file_example_proto_depIdxs = []int32{ - 3, // 0: tutorial.Person.phones:type_name -> tutorial.Person.PhoneNumber - 4, // 1: tutorial.Person.last_updated:type_name -> google.protobuf.Timestamp - 1, // 2: tutorial.AddressBook.people:type_name -> tutorial.Person - 0, // 3: tutorial.Person.PhoneNumber.type:type_name -> tutorial.Person.PhoneType - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_example_proto_init() } -func file_example_proto_init() { - if File_example_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_example_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Person); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddressBook); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Person_PhoneNumber); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_example_proto_rawDesc, - NumEnums: 1, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_example_proto_goTypes, - DependencyIndexes: file_example_proto_depIdxs, - EnumInfos: file_example_proto_enumTypes, - MessageInfos: file_example_proto_msgTypes, - }.Build() - File_example_proto = out.File - file_example_proto_rawDesc = nil - file_example_proto_goTypes = nil - file_example_proto_depIdxs = nil -} diff --git a/zapata/example/main/main.go b/zapata/example/main/main.go deleted file mode 100644 index 2b4dc18..0000000 --- a/zapata/example/main/main.go +++ /dev/null @@ -1,73 +0,0 @@ -// 1. transform the struct to protocol buffer -// 2. send protobuf message via HTTP to so some server -// 3. In the server side, read that message and transform back into that initial - -package main - -import ( - "fmt" - - "github.com/DeDiS/protobuf" -) - -type Person struct { - Name string - Id int32 - Email *string - Phone map[string]PhoneNumber -} - -type PhoneType uint32 - -const ( - MOBILE PhoneType = iota - HOME - WORK -) - -type PhoneNumber struct { - Number string - CountryCode string -} - -func main() { - email := "john.doe@example.com" - // mobile := MOBILE - // work := WORK - phoneNumbers := make(map[string]PhoneNumber) - phoneNumbers["mobile"] = PhoneNumber{ - Number: "00000", - CountryCode: "+1", - } - phoneNumbers["work"] = PhoneNumber{ - Number: "11111", - CountryCode: "+2", - } - - person := Person{ - Name: "John Doe", - Id: 123, - Email: &email, - Phone: phoneNumbers, - } - - //fmt.Println(person) - - buf, err := protobuf.Encode(&person) - if err != nil { - fmt.Println("hit first error") - fmt.Println(err.Error()) - } else { - //fmt.Println(string(buf)) - - var person2 Person - err = protobuf.Decode(buf, &person2) - if err != nil { - fmt.Println(err.Error()) - } else { - fmt.Printf("%+v\n", person2) - } - - } - -} diff --git a/zapata/example/main/tutorial/example.pb.go b/zapata/example/main/tutorial/example.pb.go deleted file mode 100644 index 188e1d7..0000000 --- a/zapata/example/main/tutorial/example.pb.go +++ /dev/null @@ -1,389 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.20.1-devel -// protoc v3.11.4 -// source: example.proto - -package main - -import ( - reflect "reflect" - sync "sync" - - proto "github.com/golang/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type Person_PhoneType int32 - -const ( - Person_MOBILE Person_PhoneType = 0 - Person_HOME Person_PhoneType = 1 - Person_WORK Person_PhoneType = 2 -) - -// Enum value maps for Person_PhoneType. -var ( - Person_PhoneType_name = map[int32]string{ - 0: "MOBILE", - 1: "HOME", - 2: "WORK", - } - Person_PhoneType_value = map[string]int32{ - "MOBILE": 0, - "HOME": 1, - "WORK": 2, - } -) - -func (x Person_PhoneType) Enum() *Person_PhoneType { - p := new(Person_PhoneType) - *p = x - return p -} - -func (x Person_PhoneType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Person_PhoneType) Descriptor() protoreflect.EnumDescriptor { - return file_example_proto_enumTypes[0].Descriptor() -} - -func (Person_PhoneType) Type() protoreflect.EnumType { - return &file_example_proto_enumTypes[0] -} - -func (x Person_PhoneType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Person_PhoneType.Descriptor instead. -func (Person_PhoneType) EnumDescriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{0, 0} -} - -type Person struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` // Unique ID number for this person. - Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` - Phones []*Person_PhoneNumber `protobuf:"bytes,4,rep,name=phones,proto3" json:"phones,omitempty"` - LastUpdated *timestamp.Timestamp `protobuf:"bytes,5,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"` -} - -func (x *Person) Reset() { - *x = Person{} - if protoimpl.UnsafeEnabled { - mi := &file_example_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Person) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Person) ProtoMessage() {} - -func (x *Person) ProtoReflect() protoreflect.Message { - mi := &file_example_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Person.ProtoReflect.Descriptor instead. -func (*Person) Descriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{0} -} - -func (x *Person) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Person) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Person) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - -func (x *Person) GetPhones() []*Person_PhoneNumber { - if x != nil { - return x.Phones - } - return nil -} - -func (x *Person) GetLastUpdated() *timestamp.Timestamp { - if x != nil { - return x.LastUpdated - } - return nil -} - -// Our address book file is just one of these. -type AddressBook struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - People []*Person `protobuf:"bytes,1,rep,name=people,proto3" json:"people,omitempty"` -} - -func (x *AddressBook) Reset() { - *x = AddressBook{} - if protoimpl.UnsafeEnabled { - mi := &file_example_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddressBook) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddressBook) ProtoMessage() {} - -func (x *AddressBook) ProtoReflect() protoreflect.Message { - mi := &file_example_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddressBook.ProtoReflect.Descriptor instead. -func (*AddressBook) Descriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{1} -} - -func (x *AddressBook) GetPeople() []*Person { - if x != nil { - return x.People - } - return nil -} - -type Person_PhoneNumber struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Number string `protobuf:"bytes,1,opt,name=number,proto3" json:"number,omitempty"` - Type Person_PhoneType `protobuf:"varint,2,opt,name=type,proto3,enum=tutorial.Person_PhoneType" json:"type,omitempty"` -} - -func (x *Person_PhoneNumber) Reset() { - *x = Person_PhoneNumber{} - if protoimpl.UnsafeEnabled { - mi := &file_example_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Person_PhoneNumber) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Person_PhoneNumber) ProtoMessage() {} - -func (x *Person_PhoneNumber) ProtoReflect() protoreflect.Message { - mi := &file_example_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Person_PhoneNumber.ProtoReflect.Descriptor instead. -func (*Person_PhoneNumber) Descriptor() ([]byte, []int) { - return file_example_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *Person_PhoneNumber) GetNumber() string { - if x != nil { - return x.Number - } - return "" -} - -func (x *Person_PhoneNumber) GetType() Person_PhoneType { - if x != nil { - return x.Type - } - return Person_MOBILE -} - -var File_example_proto protoreflect.FileDescriptor - -var file_example_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x08, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbb, 0x02, 0x0a, 0x06, 0x50, - 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, - 0x34, 0x0a, 0x06, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, - 0x6e, 0x2e, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x06, 0x70, - 0x68, 0x6f, 0x6e, 0x65, 0x73, 0x12, 0x3d, 0x0a, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x64, 0x1a, 0x55, 0x0a, 0x0b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x74, 0x75, 0x74, 0x6f, - 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x2e, 0x50, 0x68, 0x6f, 0x6e, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2b, 0x0a, 0x09, 0x50, - 0x68, 0x6f, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x4f, 0x42, 0x49, - 0x4c, 0x45, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x4f, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x02, 0x22, 0x37, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x28, 0x0a, 0x06, 0x70, 0x65, 0x6f, 0x70, 0x6c, - 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, - 0x61, 0x6c, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x52, 0x06, 0x70, 0x65, 0x6f, 0x70, 0x6c, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_example_proto_rawDescOnce sync.Once - file_example_proto_rawDescData = file_example_proto_rawDesc -) - -func file_example_proto_rawDescGZIP() []byte { - file_example_proto_rawDescOnce.Do(func() { - file_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_example_proto_rawDescData) - }) - return file_example_proto_rawDescData -} - -var file_example_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_example_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_example_proto_goTypes = []interface{}{ - (Person_PhoneType)(0), // 0: tutorial.Person.PhoneType - (*Person)(nil), // 1: tutorial.Person - (*AddressBook)(nil), // 2: tutorial.AddressBook - (*Person_PhoneNumber)(nil), // 3: tutorial.Person.PhoneNumber - (*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp -} -var file_example_proto_depIdxs = []int32{ - 3, // 0: tutorial.Person.phones:type_name -> tutorial.Person.PhoneNumber - 4, // 1: tutorial.Person.last_updated:type_name -> google.protobuf.Timestamp - 1, // 2: tutorial.AddressBook.people:type_name -> tutorial.Person - 0, // 3: tutorial.Person.PhoneNumber.type:type_name -> tutorial.Person.PhoneType - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_example_proto_init() } -func file_example_proto_init() { - if File_example_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_example_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Person); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddressBook); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Person_PhoneNumber); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_example_proto_rawDesc, - NumEnums: 1, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_example_proto_goTypes, - DependencyIndexes: file_example_proto_depIdxs, - EnumInfos: file_example_proto_enumTypes, - MessageInfos: file_example_proto_msgTypes, - }.Build() - File_example_proto = out.File - file_example_proto_rawDesc = nil - file_example_proto_goTypes = nil - file_example_proto_depIdxs = nil -}