import pickle


def encode_message(topic, data):
    """Encode a message for sending via 0MQ

    Given a string topic name and a pickle-able data object, encode and prep
    the data for sending via `send_multipart`

    Returns a list of the form:
        [
            Bytes object of String (UTF-8),
            Pickled data object
        ]

    If encoding fails None will be returned.

    """
    try:
        enc = [bytes(topic, 'utf-8'), pickle.dumps(data)]
    except:
        enc = None

    return enc