• Events

    Friday Open House Lunches
    Stop by on Fridays for lunch and see what's new, ask questions, brainstorm or just get to know us. If would like to join us, please RSVP at our Eventbrite site.

    API Hackday Salt Lake city Sept 24th
    Join us with Mashery, Zappos, SendGrid and Doba for this all-day hackathon

  • Categories

  • Library

  • Introducing the Kynetx kCast series

  • Jan 03 2012

    Static Scoping of Persistents in KRL Modules

    With a title like that, I’m sure you just can’t wait to dig into this blog post. The bottom line: I made a scoping mistake in designing modules and it’s time for KRL to come clean about that. This post describes the problem and what’s changing to fix it.

    When I implemented KRL modules over a year ago, I was careful to ensure that module variables are statically scoped. For example, conside the following meta and global blocks from a KRL module:

    meta {
      provides b
    }
    global {
      a = 5;
      b = function(x) { x + a };
    }

    Now suppose this module gets used with the alias test like so:

    global {
      a = 16;
      p = test:b(5);
    }

    Will p have the value 10 or 21? If module variables are statically scoped, it will have the value 10 because the variable reference a in the function bound to b will refer to the a in play when it was declared (static) rather than when it is run (dynamic). You’ve probably surmised that if variables are dynamically bound then p will have the value 21.

    There’s only one tiny problem: regular variables are not the only things that can be bound to values in KRL. KRL also has a special kind of variable called a persistent variable that holds it’s value across invocations of the ruleset. When I implemented modules, I more or less ignored and forgot about persistents. The result was that they ended up being dynamically scoped. This causes confusion for developers because not only don’t KRL modules that reference persistents behave the way that we’ve come to expect from other programming languages, but they don’t behave consistent with module variables in KRL. The’s poor language design and I’m sorry.

    Here’s a detailed look at what I mean. Supposed, we had the following ruleset:

    ruleset foo {
        meta {
            provides get_item
        }
    
        global {
            get_item = function (k) {
                ent:elements{k};
            };
        }
        rule add_item {
            select when pds new_data_available
    	noop();
            always {
                set ent:elements{event:attr("key")} event:attr("value");
                raise pds event new_item_added;
            }
        }
    }

    The provides declaration in the meta section clues us in that this ruleset is intended to be used as a module. Note thatget_item() references an entity variable (ent:elements). An entity variable with the same name is mutated in the ruleadd_item. The idea is that this ruleset will function as a closure over the value in ent:elements allows the value to be set when the event pds:new_data_available is raised and retrieved via a function made available to other rulesets thatuse this one.

    The problem is that persistent variables in modules are dynamically scoped whereas they’re statically scoped when the ruleset is run because it contains a rule that responds to an event. Thus the two references to ent:elements in the preceding ruleset do not refer to the same place. The one inget_item() refers to the persistent ent:elements in the ruleset it runs in while the reference to ent:elements in the rule postlude refers to the persistent ent:elements in ruleset foo. That is clearly not what developers looking at this ruleset would expect and thus poor design.

    In my defense, when I designed modules, I didn’t even consider that some enterprising developer (yeah, I’m looking at you Sam Curren) would put rules in their modules. But they did and it proved to be very useful.

    So, what we’re going to do is fix this. We will make persisent variable references in modules statically scoped. If you’re a Kynetx developer and you’ve written a module, you should ensure you haven’t used persistents in module functions. If you have you’re going to have to change your module to pass that value in as a function parameter, rather than simply referring to it. I doubt many people are relying on this, so we’re just going to change it and help people fix their code later. Let me know if this is going to cause you too much heartburn.

    Nov 30 2011

    Sky: The New Kynetx Event API

    Lately, I’ve been talking a lot about personal clouds and personal event networks. The power of a personal event network is harmonizing your various lives: business, personal, and social. Having a personal valet that thinks about you—-your needs, your quirks, your life. A personal event network puts you into a position of just making go—no go decisions, rather than having to get involved in all the gritty details of how they get done. A real personal assistant is only for the realms of Kings, Presidents & CEOs. A personal event network provides that same luxury to the rest of us. Personal event networks will enable new kinds of commerce that are not only more efficient, but also more gratifying.

    The release of the Sky API brings the vision of personal event networks closer to reality on the Kynetx platform. Our previous event API, Blue, required that the ruleset IDs be specified, Sky does not. Rather Sky uses saliance data—information saying which rulesets are listening to which events—to determine the rulesets that see any given event. Of course, this is done on an entity-by-entity basis, making it personal. You will have activated a different collection of rulesets than I and therefore an event raised on your behalf will fire different rules than an event raised for me—automatically. Sky is compatible with the Evented API specification.

    For now, most KRL programmers won’t notice any difference since the Blue API is still supported and most endpoints are still using it. However, as endpoints—particularly KBX—begin using Sky, all kinds of new behaviors will open up. I’ll have an example up on this blog in a few days.

    There are several changes to default behavior that will take place immediately, regardless of endpoint, and could affect your KRL rulesets if you’re made heavy use of explicit events.

    The first change affects what rulesets see an explicit event. Previously, if you didn’t specify a ruleset in the raise statement in the rule postlude, the explicit event was only seen by the current ruleset. With this release, an explicit event that does not specify the ruleset will be seen by any ruleset that the user has activated if saliance data indicates that it listens for that event.

    For most developers and apps, this won’t be a problem because even if you use explicit events, you’ve likely used different event names in different rulesets. However, if you experience problems, there is a work around. You’ve always been able to specify the rulesets for which an explicit event is being raised. You can specify the current ruleset using the Meta library to retrieve it’s ruleset ID like so:

    always {
      raise explicit event foo for meta:rid()
    }

    The second change involves the default version for rulesets specified in a raise statement. Previously, if you didn’t specify the version, KRE used the version of the ruleset where the raise statement was executed to determine the version of the ruleset that saw the explicit event. This was handy when developing an app that comprised multiple rulesets since you didn’t have to keep pushing things to production or change the version in a lot of files when you were done.

    We believe that the correct default behavior is to default to production if no version is specified since this makes sharing rulesets between users easier. The work around for this if you want the old behavior is to specify that the target ruleset should use the source ruleset’s version by constructing the target ruleset identifier like so:

    raise explicit event foo for "a16x56.#{meta:version()}"

    Of course, you don’t need to use the meta library, you could set the version in a configuration module and then just use that value in constructing the target RID.

    I’m very excited about Sky because it opens up new possibilities for creating personal event systems. Watch for a blog post in a few days that shows why this is so.

    -Phil

    Nov 18 2011

    Planned outage 8pm MST November 18th

    Beginning on Friday, November 18th at 8:00 PM MST, the Kynetx Network Services platform will be offline for approximately four (4) hours. This outage is being taken in order to relocate our servers to a new data center. The new data center facility is a upgrade from our current facility and will provide us with greater security, fault tolerance and bandwidth availability and speed.

    Sep 30 2011

    API Hackday SLC Wrapup

    The first API Hackday SLC was a huge success! Over 40 developers came and spent the entire day working on their projects, integrating new APIs and playing with cool new technology. Here is a list of the apps:

    Grand Prize winner ($750 Apple Gift Card):

    SendGrid for Salesforce - Use SendGrid to send all of your emails to customers right within Salesforce.com. By Jon Jessup

    Kynetx Winners:

    FriendPix - Replace obnoxious ads with pictures from your Facebook news feed powered by Kynetx. By Ed Orcutt

    Foo Foo What's New - This app uses Kynetx to filter eBay search results you've already seen. That way you don't have to wade through the same results over and over again. by Justin Shakespear

    Mashery Winner:

    WTFISPLAYINGTONIGHT - Call a Twilio powered number to get a list of bands playing tonight near you. By Alex Swan

    SendGrid Winner:

    Sales Genie Sucker Trap - An iPad application for real estate agents to ask potential buyers for their contact information and email the results to the agent on submit using SendGrid. By Annica Burns

    Doba Winner:

    AloneSharks - Loan your stuff to strangers and monitor its return date using email + social media. If they aren't returned on time use Zappos/Doba to buy/replace the item. by Robert Johnson

    Zappos Winner:

    FlyMyShoes - Get your shoes ordered from Zappos delivered by AR Drone. Using Kynetx, this app adds the AR Drone delivery option. By Loic Devaux

    Honorable Mentions:

    Sprinkler Controller - Arduino, Kynetx, Google Calendar, Twilio and SendGrid powered sprinkler system. by Sam Curren and Randall Bohn

    wedgi.es - Simple Social Surveys with geotagging and maps. By Jimmy Jacobson and Porter Haney

    SendGrid send to friend - Kynetx App that easily connects to your gmail account to get your friend's email addresses and email them details for Web 2.0 Expo. By Aaron Frost

    Big thanks to the sponsors: Mashery, Zappos, Doba and SendGrid. Also a special thanks to Neumont University for providing the venue. We will organize another one of these hackdays for Salt Lake City soon!

    Sep 22 2011

    PresenTweet – TwilioCon Hackathon winner!

    PresenTweet is a handy app that lets a presenter schedule tweets for their presentation right inside of Google Presentation. PresentTweet developer, Thomas Karren from MokiNetworks is the proud winner of the AR Drone for last night's hackathon.

    Here's how it works: When editing a presentation, this app adds a Tweet button next to each slide thumbnail. If you click on that button, a dialog opens up and lets you author your tweet and (optionally) a text message to any number (you know, so you can warn your Ops guy so your servers don't fallover in your demo). When the presentation is given the tweets and text messages will be sent with the slide they are assigned to.

    You can play with an early version of PresenTweet from here.

    Congrats Thomas and all the other developers at the TwilioCon Hackathon.

    Sep 21 2011

    Hack at TwilioCon, win an AR Drone

    I'm here at TwilioCon and the Hackathon starts tonight. As a proud sponsor of TwilioCon, we are giving away an AR Drone for the best use of Kynetx in an app at the Hackathon. You could build something with Twilio, Twitter, Facebook, Google+, Netflix...whatever you want. Get a developer account and start hacking

    Here are some resources to help you get started:

    SayIt - Sample code

    Customer Feedback - Sample code

    SMS Quiz game - Sample code

    Twilio Phone Menu - Sample code

    I have some app ideas in mind, so come find me if you'd like to get creative. email me: bjh@kynetx.com on twitter: @bradhintze

    Here's a video to get you excited about the AR Drone:

    -Brad

    Sep 01 2011

    API Hackday Salt Lake City – Sept 24th

    API Hackday is coming to Salt Lake City! Join Kynetx, Mashery, Zappos, SendGrid and Doba for this all-day hackathon on Sept 24th at Neumont University. Come build that killer app you've been thinking about, work on your existing projects or find other developers to work on cool stuff with.

    API Hackdays are light on yaking and heavy on the coding, here's the agenda:

    • 9am - 9:30am | Registration / Coffee
    • 9:30am -10am | Intro / API Workshops
    • 10am - 1pm | Hacking
    • 1pm - 2pm | Lunch
    • 2pm - 6pm | Hacking
    • 6pm | Submission Deadline
    • 6:30pm - 7pm | Presentations
    • 7pm- 7:30pm |  Judging (Awards shortly following)
    • 7pm - 8pm | Dinner & Revelry

    Awesome prizes make it even more interesting including a $750 Apple Gift Card, a JAMBOX wireless speaker, $250 prepaid Doba account, service credits and more. RSVP for the event here.

    Aug 08 2011

    kySQL: a MySQL Module for Kynetx

    Today Kynetx rockstar Ed Orcutt released the first version of KySQL, a module for easily using an external MySQL database in a KRL ruleset. He has made this module available publicly, so you can easily add it to your projects. He's also provided the source code, so you can inspect exactly what he's built or build your own module using his code as a starting point.

    Ed explains the genesis for the module here:

    For the current Kynetx project that I am working on there is a need to remeber information about items and also individual opionins about those items. Based on my past experience with KRL my first choice would be to use entity variables. However, since the volume of data is expected to become rather large another solutions for data storage is needed since entity variables where not designed to be used as a database replacement. In addition, other components of the project will require access to the data from traditional programming languages (e.g. Rails, PHP).

    Go check out KySQL and let us know how it fits into your projects.

    -Brad

    Jul 27 2011

    2011-07-27 KNS Incident Report

    Date: 2011/07/27

    Start Time: 05:00:00 MST on 2011/07/27

    Stop Time: 05:11:00 MST on 2011/07/27

    Duration: 00:00:11 (DD:HH:MM)

    Severity: Sev1 - KNS Unavailable

    Incident Summary:

    The Kynetx platform experienced a brief period of unavailability today due to a failure of the primary load balancer

    Services Impacted:

    Kynetx Network Services (KNS) Platform

    - Evaluation Servers
    - Initialization Servers
    - Callback Servers
    - Marketplace and Apps Servers

    Root Cause Analysis:

    The root cause of the load balancer failure was identified as a full / (root) filesystem. Because the filesystem was full, the load balancing process was unable to log and this state caused the load balancing process to become unresponsive.

    Recovery Steps:

    Space on the filesystem was freed up and the load balancing process was restarted.

    Remediation Steps:

    In light of this incident, the Kynetx team is taking the following steps to remedy the situation:

    * Created an automated process that will free up disk space
    * Evaluate other load balancing software.

    Jul 12 2011

    Build for Google+ win Kindle 3G + eBooks (ends Jul 17th)

    For those of you living under a rock, Google just started opening up their new efforts in social, called Google+. While the project is still invitation only (let us know if you would like an invite), users are joining very rapidly. With the excitement around this new way of connecting online, everyone is clamoring for the best tools and ways to get the most out of Google+ and also to integrate it with their existing social media activities.

    As an example, Phil Windley built an app that simply rolls comments up underneath a post and the app continues to gain momentum among users as one of the fastest growing Kynetx apps yet. You can find the code after the shark.

    Build and Win

    Build an app for Google+ and you could win an Amazon Kindle 3G + $150 Amazon Gift Card to stock it full of books. While Phil's app is getting popular, in order to win you will need to be more creative/sophisticated. Here's a list of extensions that have been quickly thrown together by other developers (most are limited to Chrome).

    Get crackin', we are excited to see what you build! If you have questions or need help ask on StackOverflow tagged KRL or the Convore Kynetx Group. Once you're done, submit your app here by July 17th at 11:59pm PST.

    -Brad

    Read more »