This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// StartConsumerHandler defined | |
func StartConsumerHandler(w http.ResponseWriter, r *http.Request) { | |
// to consume messages | |
// make a new reader that consumes from sampleOne | |
fmt.Println("Consumer started") | |
go func() { | |
reader := kafka.NewReader(kafka.ReaderConfig{ | |
Brokers: []string{"broker:9092", "broker:9093", "broker:9093"}, | |
GroupID: "consumer-Sample-One", | |
Topic: "sampleOne", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
nginx: | |
container_name: rainbowtext_proxy | |
depends_on: | |
- server | |
image: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/rainbowtext_nginx | |
logging: | |
driver: awslogs | |
options: | |
awslogs-group: rainbowtext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Script defined to create helper functions for graphql schema.""" | |
from graphql_relay.node.node import from_global_id | |
def get_object(object_name, relayId, otherwise=None): | |
try: | |
return object_name.objects.get(pk=from_global_id(relayId)[1]) | |
except: | |
return otherwise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateBook(relay.ClientIDMutation): | |
class Input: | |
# BookCreateInput class used as argument here. | |
book = graphene.Argument(BookCreateInput) | |
new_book = graphene.Field(BookNode) | |
@classmethod | |
def mutate_and_get_payload(cls, args, context, info): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from graphene_django.views import GraphQLView | |
urlpatterns = [ | |
... | |
url(r'^graphql', GraphQLView.as_view(graphiql=True)), | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = [ | |
... | |
'graphene_django', | |
] | |
GRAPHENE = { | |
'SCHEMA': 'bookmeapi.schema.schema', # Where your Graphene schema lives | |
'MIDDLEWARE': ( | |
'graphene_django.debug.DjangoDebugMiddleware', | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
// Name of the struct tag used in examples | |
const tagName = "validate" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pigLatin(word): | |
""" | |
Translate a single lowercase word to pig Latin. | |
if w begins with a consonant, | |
move the leading consonant to the end of the word | |
add 'ay' as a suffix | |
if w begins with a vowel, | |
add 'yay' as a suffix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_consonant(char): | |
return char not in "aeiouAEIOU" | |
def pigLatin(word): | |
""" | |
Translate a single lowercase word to pig Latin. | |
if w begins with a consonant, |